OnboardingFragmentImpl extends OnboardingScreenContract.View { @Override void showPages(@NonNull final List<OnboardingPage> pages, final boolean showEmptyLastPage) { setUpViewPager(pages, showEmptyLastPage); } OnboardingFragmentImpl(final OnboardingFragmentImplCallback fragment,
            final boolean showEmptyLastPage);  OnboardingFragmentImpl(final OnboardingFragmentImplCallback fragment,
            final boolean showEmptyLastPage, final ArrayList<OnboardingPage> pages); @Override void setListener(@NonNull final OnboardingFragmentListener listener); View onCreateView(final LayoutInflater inflater, final ViewGroup container,
            final Bundle savedInstanceState);  }
@Test public void should_showPages() throws Exception { final OnboardingScreenPresenter presenter = mock(OnboardingScreenPresenter.class); final AtomicReference<OnboardingFragmentImpl> onboardingFragmentImplRef = new AtomicReference<>(); final ArrayList<OnboardingPage> pages = DefaultPagesPhone.asArrayList(); final ActivityScenario<OnboardingFragmentHostActivity> scenario = launchHostActivity(presenter, onboardingFragmentImplRef, false, pages); scenario.onActivity(new ActivityScenario.ActivityAction<OnboardingFragmentHostActivity>() { @Override public void perform(final OnboardingFragmentHostActivity activity) { final OnboardingFragmentImpl onboardingFragmentImpl = onboardingFragmentImplRef.get(); onboardingFragmentImpl.showPages(pages, false); } }); onView(withText(pages.get(0).getTextResId())).check( matches(isCompletelyDisplayed())); }
@Test public void should_notifyPresenter_whenSwipedToNextPage() throws Exception { final OnboardingScreenPresenter presenter = mock(OnboardingScreenPresenter.class); final AtomicReference<OnboardingFragmentImpl> onboardingFragmentImplRef = new AtomicReference<>(); final ArrayList<OnboardingPage> pages = DefaultPagesPhone.asArrayList(); final ActivityScenario<OnboardingFragmentHostActivity> scenario = launchHostActivity(presenter, onboardingFragmentImplRef, false, pages); scenario.onActivity(new ActivityScenario.ActivityAction<OnboardingFragmentHostActivity>() { @Override public void perform(final OnboardingFragmentHostActivity activity) { final OnboardingFragmentImpl onboardingFragmentImpl = onboardingFragmentImplRef.get(); onboardingFragmentImpl.showPages(pages, false); } }); onView(withId(R.id.gv_onboarding_viewpager)).perform(ViewActions.swipeLeft()); onView(withText(pages.get(1).getTextResId())).check(matches(isCompletelyDisplayed())); verify(presenter).onScrolledToPage(1); }