@Override
            public void perform(MainActivity activity) {
                mIdlingResource = activity.getIdlingResource();
                // To prove that the test fails, omit this call:
                IdlingRegistry.getInstance().register(mIdlingResource);
            }
Use {@link ActivityScenario to launch and get access to the activity.
{@link ActivityScenario#onActivity(ActivityScenario.ActivityAction)} provides a thread-safe
mechanism to access the activity.
ui/espresso/IdlingResourceSample/app/src/androidTest/java/com/example/android/testing/espresso/IdlingResourceSample/ChangeTextBehaviorTest.java