@Override
 public void setUp() throws Exception {
   super.setUp();
   mUiTestAutomationBridge = new UiTestAutomationBridge();
   mUiTestAutomationBridge.connect();
   mUiTestAutomationBridge.waitForIdle(
       IDLE_EVENT_TIME_DELTA_MILLIS, GLOBAL_IDLE_DETECTION_TIMEOUT_MILLIS);
   mUiTestAutomationBridge.executeCommandAndWaitForAccessibilityEvent(
       new Runnable() {
         // wait for the first accessibility event
         @Override
         public void run() {
           // bring up the activity
           getActivity();
         }
       },
       new Predicate<AccessibilityEvent>() {
         @Override
         public boolean apply(AccessibilityEvent event) {
           return (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
               && event.getPackageName().equals(getActivity().getPackageName()));
         }
       },
       TIMEOUT_PROPAGATE_ACCESSIBILITY_EVENT_MILLIS);
 }