// Path: patternedtextwatcher/src/androidTest/java/com/szagurskii/patternedtextwatcher/utils/Utils.java
// public class Utils {
//   /**
//    * Type inserted strings by character, like in real life.
//    *
//    * @param input          input string which needs to be typed.
//    * @param expectedOutput expected output from this input which will be checked.
//    */
//   public static void typeTextAndAssert(String input, String expectedOutput) {
//     // Type text.
//     onView(withId(android.R.id.primary))
//         .perform(typeText(input), closeSoftKeyboard());
// 
//     // Check that the text was changed.
//     assertExpectedOutput(expectedOutput);
//   }
// 
//   /**
//    * Insert a text into a view.
//    *
//    * @param input          input string which needs to be typed.
//    * @param expectedOutput expected output from this input which will be checked.
//    */
//   public static void insertTextAtOnceAndAssert(String input, String expectedOutput) {
//     // Type input.
//     onView(withId(android.R.id.primary))
//         .perform(ViewActions.replaceText(input));
//     assertExpectedOutput(expectedOutput);
// 
//   }
// 
//   /**
//    * Assert expected output.
//    *
//    * @param expectedOutput the string to assert.
//    */
//   public static void assertExpectedOutput(String expectedOutput) {
//     // Check that the input was changed.
//     onView(withId(android.R.id.primary))
//         .check(matches(withText(expectedOutput)));
//   }
// 
//   /**
//    * Delete one character from the edit text.
//    */
//   public static void deleteOneCharacter() {
//     onView(withId(android.R.id.primary)).perform(ViewActions.pressKey(KeyEvent.KEYCODE_DEL));
//   }
// }


import android.support.test.runner.AndroidJUnit4;
import com.szagurskii.patternedtextwatcher.utils.Utils;
import org.junit.Test;
import org.junit.runner.RunWith;
    Utils.insertTextAtOnceAndAssert("Espresso", "(Esp)");
  }

  @Test
  public void basicTest2() {
    addTextChangedListener("(### ###)");
    Utils.insertTextAtOnceAndAssert("Espresso", "(Esp res)");
  }

  @Test
  public void basicTestWithMobilePhone() {
    addTextChangedListener("+# (###) ###-##-##");
    Utils.insertTextAtOnceAndAssert("71234567890", "+7 (123) 456-78-90");
  }

  @Test
  public void basicTest3() {
    addTextChangedListener("########");
    Utils.insertTextAtOnceAndAssert("Espresso", "Espresso");
  }

  @Test
  public void basicTest4() {
    addTextChangedListener("(### ### ##)");
    Utils.insertTextAtOnceAndAssert("Espresso", "(Esp res so)");
  }

  @Test
  public void basicTest5() {
    addTextChangedListener("### ### ##)");
// Path: patternedtextwatcher/src/androidTest/java/com/szagurskii/patternedtextwatcher/utils/Utils.java
// public class Utils {
//   /**
//    * Type inserted strings by character, like in real life.
//    *
//    * @param input          input string which needs to be typed.
//    * @param expectedOutput expected output from this input which will be checked.
//    */
//   public static void typeTextAndAssert(String input, String expectedOutput) {
//     // Type text.
//     onView(withId(android.R.id.primary))
//         .perform(typeText(input), closeSoftKeyboard());
// 
//     // Check that the text was changed.
//     assertExpectedOutput(expectedOutput);
//   }
// 
//   /**
//    * Insert a text into a view.
//    *
//    * @param input          input string which needs to be typed.
//    * @param expectedOutput expected output from this input which will be checked.
//    */
//   public static void insertTextAtOnceAndAssert(String input, String expectedOutput) {
//     // Type input.
//     onView(withId(android.R.id.primary))
//         .perform(ViewActions.replaceText(input));
//     assertExpectedOutput(expectedOutput);
// 
//   }
// 
//   /**
//    * Assert expected output.
//    *
//    * @param expectedOutput the string to assert.
//    */
//   public static void assertExpectedOutput(String expectedOutput) {
//     // Check that the input was changed.
//     onView(withId(android.R.id.primary))
//         .check(matches(withText(expectedOutput)));
//   }
// 
//   /**
//    * Delete one character from the edit text.
//    */
//   public static void deleteOneCharacter() {
//     onView(withId(android.R.id.primary)).perform(ViewActions.pressKey(KeyEvent.KEYCODE_DEL));
//   }
// }


// Path: patternedtextwatcher/src/androidTest/java/com/szagurskii/patternedtextwatcher/TextInsertionPatternTests.java
import android.support.test.runner.AndroidJUnit4;
import com.szagurskii.patternedtextwatcher.utils.Utils;
import org.junit.Test;
import org.junit.runner.RunWith;

    Utils.insertTextAtOnceAndAssert("Espresso", "(Esp)");
  }

  @Test
  public void basicTest2() {
    addTextChangedListener("(### ###)");
    Utils.insertTextAtOnceAndAssert("Espresso", "(Esp res)");
  }

  @Test
  public void basicTestWithMobilePhone() {
    addTextChangedListener("+# (###) ###-##-##");
    Utils.insertTextAtOnceAndAssert("71234567890", "+7 (123) 456-78-90");
  }

  @Test
  public void basicTest3() {
    addTextChangedListener("########");
    Utils.insertTextAtOnceAndAssert("Espresso", "Espresso");
  }

  @Test
  public void basicTest4() {
    addTextChangedListener("(### ### ##)");
    Utils.insertTextAtOnceAndAssert("Espresso", "(Esp res so)");
  }

  @Test
  public void basicTest5() {
    addTextChangedListener("### ### ##)");
    Utils.insertTextAtOnceAndAssert("Espresso", "Esp res so)");