run connectedAndroidTest task.
$ gradle connectedAndroidTest
NavigationViewActions.navigateTo(menu_id)
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void test_navigation_view() throws InterruptedException {
Thread.sleep(2000);
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_slideshow));
Thread.sleep(1000);
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_send));
Thread.sleep(1000);
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_gallery));
Thread.sleep(1000);
}
}