@Test
 public void checkShotsOpen() {
   for (int i = 0; i < Config.SHOTS_PER_PAGE + 1; i++) {
     onView(allOf(withId(R.id.rvShots), isDisplayed()))
         .perform(
             RecyclerViewActions.scrollToPosition(i),
             RecyclerViewActions.actionOnItemAtPosition(i, click()));
     sleep(2000);
     pressBack();
     sleep(2000);
   }
 }
 @Test
 public void goUserPageFromComment() {
   setupMockServer(null);
   activityRule.launchActivity(intent);
   TimingIdlingResource idlingResource =
       new TimingIdlingResource(3000); // wait dummy network operation
   Espresso.registerIdlingResources(idlingResource);
   onView(withId(R.id.comment_parent)).perform(clickComment());
   Espresso.unregisterIdlingResources(idlingResource);
   Instrumentation.ActivityMonitor receiverActivityMonitor =
       InstrumentationRegistry.getInstrumentation()
           .addMonitor(UserActivity.class.getName(), null, false);
   Activity activity = receiverActivityMonitor.waitForActivityWithTimeout(1000);
   assertEquals("Launched Activity is not UserActivity", UserActivity.class, activity.getClass());
   onView(withText("¡! Nature B■x !¡")).check(matches(isDisplayed()));
   pressBack();
   SystemClock.sleep(2000);
 }
  @Test
  public void
      test_should_call_onViewReady_in_tab_fragments_when_comes_back_from_another_activity_after_being_killed()
          throws Throwable {
    if (!isDontKeepActivities()) {
      Log.i(
          getClass().getSimpleName(),
          "TestFragmentsInViewPager not tested as Don't Keep Activities setting is disabled");
      return;
    }

    // =============================> At Home
    lifeCycleValidator.expect(
        LifeCycle.onCreateNull,
        LifeCycle.onCreateViewNull,
        LifeCycle.onViewCreatedNull,
        LifeCycle.onViewReadyNewInstance,
        LifeCycle.onViewReadyFirstTime);

    lifeCycleValidatorA.expect(
        LifeCycle.onCreateNull,
        LifeCycle.onCreateViewNull,
        LifeCycle.onViewCreatedNull,
        LifeCycle.onViewReadyNewInstance,
        LifeCycle.onViewReadyFirstTime);

    lifeCycleValidatorB.expect(
        LifeCycle.onCreateNull,
        LifeCycle.onCreateViewNull,
        LifeCycle.onViewCreatedNull,
        LifeCycle.onViewReadyNewInstance,
        LifeCycle.onViewReadyFirstTime);

    lifeCycleValidatorC.expect();

    onView(withText("Tab A")).check(matches(isDisplayed()));

    onView(withId(R.id.viewpager)).perform(swipeLeft());
    onView(withText("Tab A")).check(matches(not(isDisplayed())));
    onView(withText("Tab B")).check(matches(isDisplayed()));

    // =============================> At Sub Fragment
    getActivity().launchAnotherActivity();
    waitTest(1200);
    pressBack();
    waitTest(1200);
    lifeCycleValidatorA.expect(
        LifeCycle.onDestroyView,
        LifeCycle.onDestroy,
        LifeCycle.onCreateNotNull,
        LifeCycle.onCreateViewNotNull,
        LifeCycle.onViewCreatedNotNull,
        LifeCycle.onViewReadyNewInstance,
        LifeCycle.onViewReadyRestore);

    onView(withId(R.id.viewpager)).perform(swipeLeft());
    onView(withText("Tab B")).check(matches(not(isDisplayed())));
    onView(withText("Tab C")).check(matches(isDisplayed()));
    waitTest(1000);
    lifeCycleValidatorA.expect(LifeCycle.onDestroyView);

    onView(withId(R.id.viewpager)).perform(swipeRight());
    onView(withText("Tab C")).check(matches(not(isDisplayed())));
    onView(withText("Tab B")).check(matches(isDisplayed()));

    onView(withId(R.id.viewpager)).perform(swipeRight());
    onView(withText("Tab B")).check(matches(not(isDisplayed())));
    onView(withText("Tab A")).check(matches(isDisplayed()));

    lifeCycleValidatorA.expect(
        LifeCycle.onCreateViewNull, LifeCycle.onViewCreatedNull, LifeCycle.onViewReadyFirstTime);
  }