package org.wordpress.aztec.demo;

import android.support.test.espresso.ViewInteraction;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;

/**
 * Test utilities to be used with instrumentation tests.
 */
public class TestUtils {

    // Strings
    public static String unformattedText = "hello";
    public static String formattedText = "world";
    public static String linkURLText = "https://github.com/wordpress-mobile/AztecEditor-Android";

    // Editor Views
    public static ViewInteraction aztecText = onView(withId(R.id.aztec));
    public static ViewInteraction sourceText = onView(allOf(withId(R.id.source), isDisplayed()));

    // Format Toolbar Buttons
    public static ViewInteraction boldButton = onView(withId(R.id.format_bar_button_bold));
    public static ViewInteraction headingButton = onView(withId(R.id.format_bar_button_heading));
    public static ViewInteraction italicButton = onView(withId(R.id.format_bar_button_italic));
    public static ViewInteraction linkButton = onView(withId(R.id.format_bar_button_link));
    public static ViewInteraction moreButton = onView(withId(R.id.format_bar_button_more));
    public static ViewInteraction orderedListButton = onView(withId(R.id.format_bar_button_ol));
    public static ViewInteraction pageButton = onView(withId(R.id.format_bar_button_page));
    public static ViewInteraction quoteButton = onView(withId(R.id.format_bar_button_quote));
    public static ViewInteraction strikethroughButton = onView(withId(R.id.format_bar_button_strikethrough));
    public static ViewInteraction underlineButton = onView(withId(R.id.format_bar_button_underline));
    public static ViewInteraction unorderedListButton = onView(withId(R.id.format_bar_button_ul));

    // Heading/Paragraph Format Selectors
    public static ViewInteraction headingOneSelector = onView(allOf(withId(android.R.id.title), withText("Heading 1")));
    public static ViewInteraction headingTwoSelector = onView(withText("Heading 2"));
    public static ViewInteraction headingThreeSelector = onView(withText("Heading 3"));
    public static ViewInteraction headingFourSelector = onView(withText("Heading 4"));
    public static ViewInteraction headingFiveSelector = onView(withText("Heading 5"));
    public static ViewInteraction headingSixSelector = onView(withText("Heading 6"));
    public static ViewInteraction preSelector = onView(withText("Heading 6"));

    // Link Modal
    public static ViewInteraction linkOKButton = onView(withId(android.R.id.button1));
    public static ViewInteraction linkTextField = onView(withId(R.id.linkText));
    public static ViewInteraction linkURLField = onView(withId(R.id.linkURL));

    public static void toggleHTMLView() {
        ViewInteraction htmlButton = onView(withId(R.id.format_bar_button_html));
        htmlButton.perform(click());
    }
}

@@ -69,25 +69,140 @@
 sso.
-ViewInteraction;%0A
+DataInteraction;%0Aimport android.support.test.espresso.ViewInteraction;%0A%0Aimport static android.support.test.espresso.Espresso.onData;
 %0Aimp
@@ -498,50 +498,21 @@
 tic 
-android.support.test.espresso.matcher.View
+org.hamcrest.
 Matc
@@ -516,24 +516,21 @@
 atchers.
-withText
+allOf
 ;%0Aimport
@@ -559,21 +559,27 @@
 atchers.
-allOf
+hasToString
 ;%0A%0A/**%0A 
@@ -2220,36 +2220,36 @@
   public static 
-View
+Data
 Interaction head
@@ -2271,55 +2271,24 @@
 = on
-View(allOf(withId(android.R.id.title), withText
+Data(hasToString
 (%22He
@@ -2297,17 +2297,16 @@
 ing 1%22))
-)
 ;%0A    pu
@@ -2309,36 +2309,36 @@
   public static 
-View
+Data
 Interaction head
@@ -2352,37 +2352,40 @@
 elector = on
-View(withText
+Data(hasToString
 (%22Heading 2%22
@@ -2398,36 +2398,36 @@
   public static 
-View
+Data
 Interaction head
@@ -2443,37 +2443,40 @@
 elector = on
-View(withText
+Data(hasToString
 (%22Heading 3%22
@@ -2489,36 +2489,36 @@
   public static 
-View
+Data
 Interaction head
@@ -2533,37 +2533,40 @@
 elector = on
-View(withText
+Data(hasToString
 (%22Heading 4%22
@@ -2579,36 +2579,36 @@
   public static 
-View
+Data
 Interaction head
@@ -2623,37 +2623,40 @@
 elector = on
-View(withText
+Data(hasToString
 (%22Heading 5%22
@@ -2669,36 +2669,36 @@
   public static 
-View
+Data
 Interaction head
@@ -2712,37 +2712,40 @@
 elector = on
-View(withText
+Data(hasToString
 (%22Heading 6%22
@@ -2758,36 +2758,36 @@
   public static 
-View
+Data
 Interaction preS
@@ -2802,32 +2802,35 @@
 = on
-View(withText(%22Heading 6
+Data(hasToString(%22Preformat
 %22));

Update paragraph style selectors