This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void whenEmailIsMissing_shouldDisplay_noInfoMessage() { | |
mActivityRule.launchActivity(createIntent(true)); | |
onView(withId(R.id.user_details_image)).check(matches(isDisplayed())); | |
onView(withId(R.id.user_details_name)).check(matches(isDisplayed())); | |
onView(allOf( | |
withId(R.id.image_and_text_image), | |
hasSibling(withText("No info available."))) | |
).check(matches(isDisplayed())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TextColorMatcher { | |
private TextColorMatcher(){} | |
public static Matcher<View> withTextColor(@ColorInt final int expectedColor) { | |
return new BoundedMatcher<View, TextView>(TextView.class) { | |
int currentColor = 0; | |
@Override | |
public void describeTo(Description description) { | |
description.appendText("expected TextColor: ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void whenEmailIsMissing_shouldDisplay_noInfoMessage() { | |
mActivityRule.launchActivity(createIntent(true)); | |
onView(withId(R.id.user_details_image)).check(matches(isDisplayed())); | |
onView(withId(R.id.user_details_name)).check(matches(isDisplayed())); | |
onView(allOf( | |
withId(R.id.image_and_text_image), | |
hasSibling(withText("No info available.")))) | |
.check(matches(isDisplayed())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void whenClickOnItemList_shouldStartUserDetailsActivity_withExtra() { | |
server.enqueue(new MockResponse().setResponseCode(200).setBody(Mocks.SUCCESS)); | |
mActivityRule.launchActivity(new Intent()); | |
Intents.init(); | |
Matcher<Intent> matcher = allOf( | |
hasComponent(UserDetailsActivity.class.getName()), | |
hasExtraWithKey(UserDetailsActivity.CLICKED_USER) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void checkUserItemView_isDisplayed_noTricks() { | |
server.enqueue(new MockResponse().setResponseCode(200).setBody(Mocks.SUCCESS)); | |
mActivityRule.launchActivity(new Intent()); | |
onView(allOf(withId(R.id.user_view_image), hasSibling(withText("Eddie Dunn")))).check(matches(isDisplayed())); | |
onView(allOf(withId(R.id.user_view_name), withText("Eddie Dunn"))).check(matches(isDisplayed())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void checkUserItemView_isDisplayed() { | |
server.enqueue(new MockResponse().setResponseCode(200).setBody(Mocks.SUCCESS_SINGLE_ITEM)); | |
mActivityRule.launchActivity(new Intent()); | |
onView(withId(R.id.user_view_image)).check(matches(isDisplayed())); | |
onView(withId(R.id.user_view_name)).check(matches(isDisplayed())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void checkUserItemView_isDisplayed() { | |
server.enqueue(new MockResponse().setResponseCode(200).setBody(Mocks.SUCCESS)); | |
mActivityRule.launchActivity(new Intent()); | |
onView(withId(R.id.user_view_image)).check(matches(isDisplayed())); | |
onView(withId(R.id.user_view_name)).check(matches(isDisplayed())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void whenResultIsOk_shouldDisplayListWithUsers() { | |
server.enqueue(new MockResponse().setResponseCode(200).setBody(Mocks.SUCCESS)); | |
mActivityRule.launchActivity(new Intent()); | |
onView(withId(R.id.recycler_view)).check(matches(isDisplayed())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4.class) | |
public class MainActivityTest { | |
private MockWebServer server; | |
@Rule | |
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); | |
@Before | |
public void setUp() throws Exception { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4.class) | |
public class MainActivityTest { | |
private MockWebServer server; | |
@Rule | |
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); | |
@Before | |
public void setUp() throws Exception { |