= launchActivity<AddContactActivity>() // WHEN // Enter contact name onView(withId(R.id.contact_name_text)).perform(typeText(contactName)) // Destroy and recreate Activity scenario.recreate() // THEN // Check contact name was preserved. onView(withId(R.id.contact_name_text)).check(matches(withText(contactName)))
events.add("after")); events.add("between"); // the 'after' task is posted, but has not been executed yet assertThat(events).containsExactly("before", "between").inOrder(); // execute all tasks posted to main looper shadowOf(getMainLooper()).idle(); assertThat(events).containsExactly("before", "between", "after").inOrder();