in app/src/androidTestMock/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksActivityTest.kt [243:271]
fun markTaskAsCompleteAndActiveOnDetailScreen_taskIsActiveInList() {
// Add 1 active task
val taskTitle = "ACT-COMP"
repository.saveTaskBlocking(Task(taskTitle, "DESCRIPTION"))
// start up Tasks screen
val activityScenario = ActivityScenario.launch(TasksActivity::class.java)
dataBindingIdlingResource.monitorActivity(activityScenario)
// Click on the task on the list
onView(withText(taskTitle)).perform(click())
// Click on the checkbox in task details screen
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
// Click again to restore it to original state
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
// Click on the navigation up button to go back to the list
onView(
withContentDescription(
activityScenario.getToolbarNavigationContentDescription()
)
).perform(click())
// Check that the task is marked as active
onView(allOf(withId(R.id.complete_checkbox), hasSibling(withText(taskTitle))))
.check(matches(not(isChecked())))
// Make sure the activity is closed before resetting the db:
activityScenario.close()
}