Search in sources :

Example 1 with ActivityLifecycleMonitor

use of com.google.android.apps.common.testing.testrunner.ActivityLifecycleMonitor in project double-espresso by JakeWharton.

the class RootMatchers method getResumedActivityTokens.

private static List<IBinder> getResumedActivityTokens() {
    ActivityLifecycleMonitor activityLifecycleMonitor = ActivityLifecycleMonitorRegistry.getInstance();
    Collection<Activity> resumedActivities = activityLifecycleMonitor.getActivitiesInStage(Stage.RESUMED);
    if (resumedActivities.isEmpty()) {
        throw new NoActivityResumedException("At least one activity should be in RESUMED stage.");
    }
    List<IBinder> tokens = Lists.newArrayList();
    for (Activity activity : resumedActivities) {
        tokens.add(activity.getWindow().getDecorView().getApplicationWindowToken());
    }
    return tokens;
}
Also used : IBinder(android.os.IBinder) NoActivityResumedException(com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException) Activity(android.app.Activity) ActivityLifecycleMonitor(com.google.android.apps.common.testing.testrunner.ActivityLifecycleMonitor)

Aggregations

Activity (android.app.Activity)1 IBinder (android.os.IBinder)1 ActivityLifecycleMonitor (com.google.android.apps.common.testing.testrunner.ActivityLifecycleMonitor)1 NoActivityResumedException (com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException)1