android.app.Instrumentation.waitForMonitorWithTimeout()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中android.app.Instrumentation.waitForMonitorWithTimeout()方法的一些代码示例,展示了Instrumentation.waitForMonitorWithTimeout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instrumentation.waitForMonitorWithTimeout()方法的具体详情如下:
包路径:android.app.Instrumentation
类名称:Instrumentation
方法名:waitForMonitorWithTimeout

Instrumentation.waitForMonitorWithTimeout介绍

暂无

代码示例

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public Activity waitForMonitorWithTimeout(ActivityMonitor monitor, long timeOut) {
  return base.waitForMonitorWithTimeout(monitor, timeOut);
}

代码示例来源:origin: darkskygit/VirtualApp

@Override
public Activity waitForMonitorWithTimeout(ActivityMonitor monitor, long timeOut) {
  return base.waitForMonitorWithTimeout(monitor, timeOut);
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public Activity waitForMonitorWithTimeout(ActivityMonitor monitor, long timeOut) {
  return base.waitForMonitorWithTimeout(monitor, timeOut);
}

代码示例来源:origin: stackoverflow.com

Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
Instrumentation.ActivityMonitor activityMonitor = instrumentation.addMonitor(LastActivity.class.getName(), null, false);
Activity activity = instrumentation.waitForMonitorWithTimeout(activityMonitor, 1000);

Espresso.pressBack();

if(activity != null) {
 // do something
 fail();
}

代码示例来源:origin: luili16/UIMocker

@Override
@CallSuper
public Activity waitForMonitorWithTimeout(Instrumentation.ActivityMonitor monitor, long timeOut) {
  if (DEBUG) {
    Logger.d(TAG,"waitForMonitorWithTimeout");
  }
  return mInstrumentation.waitForMonitorWithTimeout(monitor, timeOut);
}

代码示例来源:origin: stackoverflow.com

// register activity monitor for the send mail activity    
Instrumentation instrumentation = getInstrumentation();    
IntentFilter filter = new IntentFilter(Intent.ACTION_SENDTO);

//Here you just need to say to your intent filter what exactly to look for 
filter.addDataType(CommonDataKinds.Email.CONTENT_TYPE);


ActivityMonitor monitor = instrumentation.addMonitor(filter, null, true);
// click on the "Send Feedback" button (use Robotium here)
solo.clickOnButton(0);    
// wait for the send mail activity to start
Activity currentActivity = instrumentation.waitForMonitorWithTimeout(monitor, 5000);
assertNotNull(currentActivity);

代码示例来源:origin: stackoverflow.com

// register activity monitor for the send mail activity
Instrumentation instrumentation = getInstrumentation();
IntentFilter filter = new IntentFilter(Intent.ACTION_SENDTO);
ActivityMonitor monitor = new ActivityMonitor(filter, null, false);
ActivityMonitor soloMonitor = solo.getActivityMonitor();

// Remove the solo monitor, so your monitor is first on the list.
instrumentation.removeMonitor(soloMonitor);
// add your own monitor.
instrumentation.addMonitor(monitor);
// Re-add the solo monitor
instrumentation.addMonitor(soloMonitor);

// click on the "Send Feedback" button (use Robotium here)
solo.clickOnButton(0);

// wait for the send mail activity to start
Activity currentActivity = instrumentation.waitForMonitorWithTimeout(monitor, 5000);
assertNotNull(currentActivity);

代码示例来源:origin: andstatus/andstatus

public Activity waitForNextActivity(String method, long timeOut) throws InterruptedException {
  Activity nextActivity = InstrumentationRegistry.getInstrumentation().waitForMonitorWithTimeout(activityMonitor, timeOut);
  MyLog.v(this, method + "-Log after waitForMonitor: " + nextActivity);
  assertNotNull("Next activity is opened and captured", nextActivity);
  activityMonitor = null;
  return nextActivity;
}

代码示例来源:origin: appium/appium-espresso-driver

public static void startActivity(String activity, @Nullable String waitActivity,
                   @Nullable Long waitDuration) {
    logger.info(String.format("Starting activity '%s'", activity));
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    String fullyQualifiedAppActivity = getFullyQualifiedActivityName(instrumentation, activity);
    String fullyQualifiedWaitActivity = isBlank(waitActivity)
        ? fullyQualifiedAppActivity
        : getFullyQualifiedActivityName(instrumentation, waitActivity);
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName(instrumentation.getTargetContext(), fullyQualifiedAppActivity);
    Instrumentation.ActivityMonitor activityStateMonitor = instrumentation
        .addMonitor(fullyQualifiedWaitActivity, null, false);
    instrumentation.startActivitySync(intent);
    if (waitDuration == null) {
      waitDuration = ACTIVITY_STARTUP_TIMEOUT;
    }
    Activity currentActivity = instrumentation.waitForMonitorWithTimeout(activityStateMonitor, waitDuration);
    if (currentActivity == null) {
      throw new IllegalStateException(String.format("Activity '%s' was unable to start within %sms timeout",
          fullyQualifiedWaitActivity, waitDuration));
    }
    logger.info(String.format("Activity '%s' started", currentActivity.getLocalClassName()));
  }
}

代码示例来源:origin: andstatus/andstatus

public Activity waitForNextActivity(String methodExt, long timeOut) throws InterruptedException {
  Activity nextActivity = InstrumentationRegistry.getInstrumentation().waitForMonitorWithTimeout(mActivityMonitor, timeOut);
  MyLog.v(methodExt, "After waitForMonitor: " + nextActivity);
  assertNotNull("Next activity is opened and captured", nextActivity);
  TestSuite.waitForListLoaded(nextActivity, 2);
  mActivityMonitor = null;
  return nextActivity;
}

代码示例来源:origin: andstatus/andstatus

private void openingOriginList() throws InterruptedException {
    final String method = "testOpeningOriginList";
    ActivityMonitor activityMonitor = getInstrumentation().addMonitor(PersistentOriginList.class.getName(), null, false);
    Runnable clicker = new Runnable() {
      @Override
      public void run() {
        MyLog.v(this, method + "-Log before click");
        getActivity().selectOrigin(OriginType.GNUSOCIAL);
      }
     };
  
    MyLog.v(this, method + "-Log before run clicker 1");
    getActivity().runOnUiThread(clicker);
     
    Activity nextActivity = getInstrumentation().waitForMonitorWithTimeout(activityMonitor, 15000);
    MyLog.v(this, method + "-Log after waitForMonitor: " 
        + nextActivity);
    assertNotNull("Next activity is opened and captured", nextActivity);
    TestSuite.waitForListLoaded(nextActivity, 6);
    DbUtils.waitMs(method, 500);
    nextActivity.finish();
  }
}

代码示例来源:origin: andstatus/andstatus

.waitForMonitorWithTimeout(activityMonitor, 15000);
assertTrue(selectorActivity != null);
ActivityTestHelper.waitViewInvisible(method, editorView);

相关文章

Instrumentation类方法