Skip to content

Instantly share code, notes, and snippets.

@creativepsyco
Created July 25, 2015 18:53
Show Gist options
  • Select an option

  • Save creativepsyco/bd7ce1a75b933941c68e to your computer and use it in GitHub Desktop.

Select an option

Save creativepsyco/bd7ce1a75b933941c68e to your computer and use it in GitHub Desktop.

Revisions

  1. creativepsyco created this gist Jul 25, 2015.
    71 changes: 71 additions & 0 deletions SimpleTest.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    import static android.support.test.espresso.Espresso.onView;
    import static android.support.test.espresso.action.ViewActions.click;
    import static android.support.test.espresso.action.ViewActions.typeText;
    import static android.support.test.espresso.assertion.ViewAssertions.matches;
    import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
    import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
    import static android.support.test.espresso.matcher.ViewMatchers.withId;
    import static android.support.test.espresso.matcher.ViewMatchers.withText;
    import static org.hamcrest.Matchers.not;

    @LargeTest
    public class BasicTest extends ActivityInstrumentationTestCase2<LoginActivity> {

    public BasicTest() {
    super(LoginActivity.class);
    }

    @Override
    public void setUp() throws Exception {
    super.setUp();
    }

    public void testWalkthroughFlow() throws InterruptedException {
    /**
    * This function tests the entire workflow for boarding.
    * If this test passes then it means the flow was a success.
    */
    onView(withId(R.id.txt_email))
    .check(matches(isDisplayed()));
    onView(withId(R.id.btn_sign_in))
    .check(matches(not(isEnabled())));
    onView(withId(R.id.txt_email))
    .perform(typeText("*****"));
    onView(withId(R.id.btn_sign_in))
    .check(matches(isEnabled()));
    onView(withId(R.id.btn_sign_in))
    .perform(click());
    onView(withId(R.id.txt_verify_code))
    .check(matches(isDisplayed()));
    onView(withId(R.id.btn_verify))
    .check(matches(not(isEnabled())));
    onView(withId(R.id.txt_verify_code))
    .perform(typeText("*****"));
    onView(withId(R.id.btn_verify))
    .check(matches(isEnabled()));
    onView(withId(R.id.btn_verify))
    .perform(click());
    onView(withId(R.id.btn_sub))
    .check(matches(isDisplayed()));
    onView(withId(R.id.btn_sub))
    .perform(click());
    onView(withText(R.string.ui_im_sure))
    .check(matches(isDisplayed()));
    onView(withText(R.string.ui_im_sure))
    .perform(click());
    onView(withText(R.string.ui_enable_notifications))
    .check(matches(isDisplayed()));
    onView(withText(R.string.ui_enable_notifications))
    .perform(click());
    onView(withText(R.string.welcome_ui))
    .check(matches(isDisplayed()));
    onView(withText(R.string.ui_done))
    .check(matches(isDisplayed()));
    /*onView(withText(R.string.ui_done))
    .perform(click());*/
    }

    public void testIfEditTextShows() throws InterruptedException {
    onView(withText("Sign in")).check(matches(isDisplayed()));
    }
    }