Skip to content

Instantly share code, notes, and snippets.

@heitorcolangelo
Created July 27, 2016 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heitorcolangelo/354080abf09bdabd0e9dd0f5a268bc21 to your computer and use it in GitHub Desktop.
Save heitorcolangelo/354080abf09bdabd0e9dd0f5a268bc21 to your computer and use it in GitHub Desktop.
LoginActivityTest - intent test 2
@Test
public void whenBothFieldsAreFilled_andClickOnLoginButton_shouldOpenMainActivity() {
Intents.init();
onView(withId(R.id.login_username)).perform(typeText("defaultText"), closeSoftKeyboard());
onView(withId(R.id.login_password)).perform(typeText("defaultText"), closeSoftKeyboard());
Matcher<Intent> matcher = hasComponent(MainActivity.class.getName());
ActivityResult result = new ActivityResult(Activity.RESULT_OK, null);
intending(matcher).respondWith(result);
onView(withId(R.id.login_button)).perform(click());
intended(matcher);
Intents.release();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment