Created
October 13, 2017 17:38
-
-
Save Pavneet-Sing/d9745326605fa9068e081436cff9b45f to your computer and use it in GitHub Desktop.
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 AppNavigationTest { | |
@Rule | |
public ActivityTestRule<NewsActivity> activityTestRule = | |
new ActivityTestRule<>(NewsActivity.class); | |
@Before | |
public void registerIdlingResource() { | |
// let espresso know to synchronize with background tasks | |
IdlingRegistry.getInstance().register(EspressoTestingIdlingResource.getIdlingResource()); | |
} | |
@After | |
public void unregisterIdlingResource() { | |
IdlingRegistry.getInstance().unregister(EspressoTestingIdlingResource.getIdlingResource()); | |
} | |
@Test | |
public void verifyDetailsIntent() { | |
// check views are displayed or not | |
onView(withId(R.id.swipe_msg_tv)).check(matches(isDisplayed())); | |
// perform swipe down gesture to initiate network request | |
onView(withId(R.id.swipe_container)).perform(swipeDown()); | |
// make sure the empty message is not displayed anymore | |
onView(withId(R.id.swipe_msg_tv)).check(matches(not(isDisplayed()))); | |
// make sure list is visible | |
onView(withId(R.id.news_frag_recycler_list)).check(matches(isDisplayed())); | |
// perform click on third item in the list | |
onView(withId(R.id.news_frag_recycler_list)) | |
.perform(RecyclerViewActions.actionOnItemAtPosition(3, click())); | |
// setup code to imitate the action of opening browser | |
Intents.init(); | |
Matcher<Intent> expectedIntent = hasAction(Intent.ACTION_VIEW); | |
intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null)); | |
onView(withText(R.string.details_story_link)).perform(click()); | |
intended(expectedIntent); | |
Intents.release(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment