in app/src/sharedTest/java/com/example/android/architecture/blueprints/todoapp/statistics/StatisticsFragmentTest.kt [86:107]
fun tasks_showsNonEmptyMessage() {
// Given some tasks
repository.apply {
saveTaskBlocking(Task("Title1", "Description1", false))
saveTaskBlocking(Task("Title2", "Description2", true))
}
val scenario = launchFragmentInContainer<StatisticsFragment>(Bundle(), R.style.AppTheme)
dataBindingIdlingResource.monitorFragment(scenario)
val expectedActiveTaskText = getApplicationContext<Context>()
.getString(R.string.statistics_active_tasks, 50.0f)
val expectedCompletedTaskText = getApplicationContext<Context>()
.getString(R.string.statistics_completed_tasks, 50.0f)
// check that both info boxes are displayed and contain the correct info
onView(withId(R.id.stats_active_text)).check(matches(isDisplayed()))
onView(withId(R.id.stats_active_text)).check(matches(withText(expectedActiveTaskText)))
onView(withId(R.id.stats_completed_text)).check(matches(isDisplayed()))
onView(withId(R.id.stats_completed_text))
.check(matches(withText(expectedCompletedTaskText)))
}