Search in sources :

Example 1 with ViewPagerIdlingResource

use of com.karumi.rosie.sample.idlingresources.ViewPagerIdlingResource in project Rosie by Karumi.

the class MainActivityTest method shouldOpenComicSeriesDetailActivityOnRecyclerViewItemClicked.

@Test
public void shouldOpenComicSeriesDetailActivityOnRecyclerViewItemClicked() throws Exception {
    givenThereAreSomeCharacters(ANY_NUMBER_OF_CHARACTERS);
    List<ComicSeries> comicSeries = givenThereAreSomeComicSeries(ANY_NUMBER_OF_COMIC_SERIES);
    givenAnyComicSeriesDetail();
    int comicSeriesIndex = 0;
    Activity activity = startActivity();
    registerIdlingResources(new ViewPagerIdlingResource((ViewPager) activity.findViewById(R.id.vp_main)));
    onView(withId(R.id.vp_main)).perform(swipeLeft());
    onView(withId(R.id.rv_comics)).perform(RecyclerViewActions.actionOnItemAtPosition(comicSeriesIndex, click()));
    ComicSeries comicSeriesSelected = comicSeries.get(comicSeriesIndex);
    intended(hasComponent(ComicSeriesDetailsActivity.class.getCanonicalName()));
    intended(hasExtra("ComicSeriesDetailsActivity.ComicSeriesKey", comicSeriesSelected.getKey().intValue()));
}
Also used : ViewPagerIdlingResource(com.karumi.rosie.sample.idlingresources.ViewPagerIdlingResource) ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) CharacterDetailsActivity(com.karumi.rosie.sample.characters.view.activity.CharacterDetailsActivity) ComicSeriesDetailsActivity(com.karumi.rosie.sample.comics.view.activity.ComicSeriesDetailsActivity) Activity(android.app.Activity) ViewPager(android.support.v4.view.ViewPager) LargeTest(android.test.suitebuilder.annotation.LargeTest) InjectedInstrumentationTest(com.karumi.rosie.sample.InjectedInstrumentationTest) Test(org.junit.Test)

Aggregations

Activity (android.app.Activity)1 ViewPager (android.support.v4.view.ViewPager)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 InjectedInstrumentationTest (com.karumi.rosie.sample.InjectedInstrumentationTest)1 CharacterDetailsActivity (com.karumi.rosie.sample.characters.view.activity.CharacterDetailsActivity)1 ComicSeries (com.karumi.rosie.sample.comics.domain.model.ComicSeries)1 ComicSeriesDetailsActivity (com.karumi.rosie.sample.comics.view.activity.ComicSeriesDetailsActivity)1 ViewPagerIdlingResource (com.karumi.rosie.sample.idlingresources.ViewPagerIdlingResource)1 Test (org.junit.Test)1