in app/src/androidTestMock/java/com/example/android/architecture/blueprints/todoapp/tasks/AppNavigationTest.kt [153:180]
fun statsScreen_clickOnAndroidHomeIcon_OpensNavigation() {
// start up Tasks screen
val activityScenario = ActivityScenario.launch(TasksActivity::class.java)
dataBindingIdlingResource.monitorActivity(activityScenario)
// When the user navigates to the stats screen
activityScenario.onActivity {
it.findNavController(R.id.nav_host_fragment).navigate(R.id.statistics_fragment_dest)
}
// Then check that left drawer is closed at startup
onView(withId(R.id.drawer_layout))
.check(matches(isClosed(Gravity.START))) // Left Drawer should be closed.
// When the drawer is opened
onView(
withContentDescription(
activityScenario
.getToolbarNavigationContentDescription()
)
).perform(click())
// Then check that the drawer is open
onView(withId(R.id.drawer_layout))
.check(matches(isOpen(Gravity.START))) // Left drawer is open open.
// When using ActivityScenario.launch, always call close()
activityScenario.close()
}