content: package de.aaronoe.cinematic.ui;
  
  
  import android.support.test.espresso.ViewInteraction;
  import android.support.test.rule.ActivityTestRule;
  import android.support.test.runner.AndroidJUnit4;
  import android.test.suitebuilder.annotation.LargeTest;
  
  import org.junit.Rule;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
  import de.aaronoe.cinematic.R;
  
  import static android.support.test.espresso.Espresso.onView;
  import static android.support.test.espresso.action.ViewActions.click;
  import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
  import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
  import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
  import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
  import static android.support.test.espresso.matcher.ViewMatchers.withId;
  import static android.support.test.espresso.matcher.ViewMatchers.withParent;
  import static android.support.test.espresso.matcher.ViewMatchers.withText;
  import static org.hamcrest.Matchers.allOf;
  import static org.hamcrest.Matchers.is;
  
  @LargeTest
  @RunWith(AndroidJUnit4.class)
  public class NavigateToTopRatedTvShow {
  
      @Rule
      public ActivityTestRule<NavigationActivity> mActivityTestRule = new ActivityTestRule<>(NavigationActivity.class);
  
      @Test
      public void navigateToTopRatedTvShow() {
          // Added a sleep statement to match the app's execution delay.
          // The recommended way to handle such scenarios is to use Espresso idling resources:
          // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
          try {
              Thread.sleep(60000);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          ViewInteraction appCompatImageButton = onView(
                  allOf(withContentDescription("Navigation View Closed"),
                          withParent(withId(R.id.toolbar)),
                          isDisplayed()));
          appCompatImageButton.perform(click());
  
          ViewInteraction appCompatCheckedTextView = onView(
                  allOf(withId(R.id.design_menu_item_text), withText("TV Shows"), isDisplayed()));
          appCompatCheckedTextView.perform(click());
  
          // Added a sleep statement to match the app's execution delay.
          // The recommended way to handle such scenarios is to use Espresso idling resources:
          // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
          try {
              Thread.sleep(60000);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          ViewInteraction floatingActionButton = onView(
                  allOf(withClassName(is("com.github.clans.fab.FloatingActionButton")),
                          withParent(withId(R.id.fab_menu)),
                          isDisplayed()));
          floatingActionButton.perform(click());
  
          // Added a sleep statement to match the app's execution delay.
          // The recommended way to handle such scenarios is to use Espresso idling resources:
          // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
          try {
              Thread.sleep(275);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          ViewInteraction floatingActionButton2 = onView(
                  allOf(withId(R.id.fab_action_show_top_rated),
                          withParent(withId(R.id.fab_menu)),
                          isDisplayed()));
          floatingActionButton2.perform(click());
  
          // Added a sleep statement to match the app's execution delay.
          // The recommended way to handle such scenarios is to use Espresso idling resources:
          // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
          try {
              Thread.sleep(275);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          ViewInteraction recyclerView = onView(
                  allOf(withId(R.id.rv_main_movie_list), isDisplayed()));
          recyclerView.perform(actionOnItemAtPosition(0, click()));
  
      }
  
  }
  