public static TestBrowser getBrowserActivityWhenLaunched(Runnable launchRunnable) {
        Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
        Instrumentation.ActivityMonitor monitor
                = instrumentation.addMonitor(TestBrowser.class.getName(), null, false);

        launchRunnable.run();
        TestBrowser activity =
                (TestBrowser) instrumentation.waitForMonitorWithTimeout(monitor, 3000);
        assertNotNull("TestBrowser wasn't launched", activity);

        // ActivityMonitor is triggered in onCreate and in onResume, which can lead to races when
        // launching several activity instances. So wait for onResume before returning.
        boolean resumed = activity.waitForResume(3000);
        assertTrue("TestBrowser didn't reach onResume", resumed);
        return activity;
    }
Waits until {@link TestBrowser} is launched and resumed, and returns it.

@param launchRunnable Runnable that should start the activity.
customtabs/tests/src/android/support/customtabs/testutil/TestUtil.java