本文整理了Java中android.app.Instrumentation.waitForMonitor()
方法的一些代码示例,展示了Instrumentation.waitForMonitor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instrumentation.waitForMonitor()
方法的具体详情如下:
包路径:android.app.Instrumentation
类名称:Instrumentation
方法名:waitForMonitor
暂无
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public Activity waitForMonitor(ActivityMonitor monitor) {
return base.waitForMonitor(monitor);
}
代码示例来源:origin: stephentuso/welcome-android
@Before
public void initActivity() {
instrumentation = InstrumentationRegistry.getInstrumentation();
Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(TestActivity.class.getName(), null, false);
instrumentation.addMonitor(monitor);
Intent intent = new Intent(instrumentation.getTargetContext(), TestActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
instrumentation.startActivitySync(intent);
activity = instrumentation.waitForMonitor(monitor);
assertNotNull(activity);
}
代码示例来源:origin: stephentuso/welcome-android
@Override
public void initActivity() {
super.initActivity();
welcomeMonitor = new Instrumentation.ActivityMonitor(DefaultWelcomeActivity.class.getName(), null, false);
instrumentation.addMonitor(welcomeMonitor);
new WelcomeHelper(activity, DefaultWelcomeActivity.class).forceShow();
welcomeActivity = (WelcomeActivity) instrumentation.waitForMonitor(welcomeMonitor);
}
代码示例来源:origin: stephentuso/welcome-android
@Test
public void testForceShow() {
ActivityMonitor monitor = new ActivityMonitor(DefaultWelcomeActivity.class.getName(), null, false);
instrumentation.addMonitor(monitor);
helper.forceShow();
Activity welcomeActivity = instrumentation.waitForMonitor(monitor);
assertNotNull(welcomeActivity);
}
代码示例来源:origin: stephentuso/welcome-android
@Test
public void testShow() {
ActivityMonitor monitor = new ActivityMonitor(DefaultWelcomeActivity.class.getName(), null, false);
instrumentation.addMonitor(monitor);
String key = WelcomeUtils.getKey(DefaultWelcomeActivity.class);
WelcomeSharedPreferencesHelper.storeWelcomeCompleted(activity, key);
assertFalse(helper.show(null));
assertFalse(helper.show(new Bundle()));
WelcomeSharedPreferencesHelper.removeWelcomeCompleted(activity, key);
assertTrue(helper.show(null));
assertFalse(helper.show(null));
Activity welcomeActivity = instrumentation.waitForMonitor(monitor);
assertNotNull(welcomeActivity);
WelcomeSharedPreferencesHelper.removeWelcomeCompleted(activity, key);
Bundle state = new Bundle();
helper.onSaveInstanceState(state);
assertFalse(helper.show(state));
}
代码示例来源:origin: bzsome/VirtualApp-x326
@Override
public Activity waitForMonitor(ActivityMonitor monitor) {
return base.waitForMonitor(monitor);
}
代码示例来源:origin: darkskygit/VirtualApp
@Override
public Activity waitForMonitor(ActivityMonitor monitor) {
return base.waitForMonitor(monitor);
}
代码示例来源:origin: takahirom/PreLollipopTransition
public void testListClick() throws InterruptedException {
Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity.class.getName(), null, false);
Spoon.screenshot(getActivity(), "init");
// listviewactivity -> subactivity
final ListView listView = (ListView) getActivity().findViewById(R.id.list);
instrumentation.waitForIdleSync();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
assertTrue(listView.performItemClick(listView.getChildAt(0), 0, 0));
}
});
Activity detailActivity = instrumentation.waitForMonitor(monitor);
// Wait for animation
Thread.sleep(2000l);
instrumentation.waitForIdleSync();
Spoon.screenshot(detailActivity, "listview_transition");
// subactivity -> listviewactivity
sendKeys(KeyEvent.KEYCODE_BACK);
// Wait for animation
Thread.sleep(2000l);
instrumentation.waitForIdleSync();
Spoon.screenshot(getActivity(), "listview_transition_backpress");
}
代码示例来源:origin: takahirom/PreLollipopTransition
public void testGoSubActivity2() throws InterruptedException {
Spoon.screenshot(getActivity(), "init");
Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity2.class.getName(), null, false);
final ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView2);
instrumentation.waitForIdleSync();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
assertTrue(imageView.performClick());
}
});
Activity activity = instrumentation.waitForMonitor(monitor);
// Verify new activity was shown.
ANDROID.assertThat(monitor).hasHits(1);
// Wait for animation
Thread.sleep(2000l);
Spoon.screenshot(activity, "sub_activity_shown");
// subactivity -> mainactivity
sendKeys(KeyEvent.KEYCODE_BACK);
// Wait for animation
Thread.sleep(2000l);
instrumentation.waitForIdleSync();
Spoon.screenshot(getActivity(), "main_activity_backed");
}
代码示例来源:origin: takahirom/PreLollipopTransition
public void testGoSubActivity() throws InterruptedException {
Spoon.screenshot(getActivity(), "init");
Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity.class.getName(), null, false);
final ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView);
instrumentation.waitForIdleSync();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
assertTrue(imageView.performClick());
}
});
Activity activity = instrumentation.waitForMonitor(monitor);
// Verify new activity was shown.
ANDROID.assertThat(monitor).hasHits(1);
// Wait for animation
Thread.sleep(2000l);
Spoon.screenshot(activity, "sub_activity_shown");
// subactivity -> mainactivity
sendKeys(KeyEvent.KEYCODE_BACK);
// Wait for animation
Thread.sleep(2000l);
instrumentation.waitForIdleSync();
Spoon.screenshot(getActivity(), "main_activity_backed");
}
代码示例来源:origin: luili16/UIMocker
@Override
@CallSuper
public Activity waitForMonitor(Instrumentation.ActivityMonitor monitor) {
if (DEBUG) {
Logger.d(TAG,"waitForMonitor");
}
return mInstrumentation.waitForMonitor(monitor);
}
代码示例来源:origin: takahirom/PreLollipopTransition
Activity activity = instrumentation.waitForMonitor(monitor);
代码示例来源:origin: stackoverflow.com
public static Activity restartActivity(Activity activity, Instrumentation instrumentation, Intent intent){
String className = activity.getClass().getName();
Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(className, null, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(instrumentation.getTargetContext(), className );
instrumentation.startActivitySync(intent);
Activity newActivity = instrumentation.waitForMonitor(monitor);
instrumentation.removeMonitor(monitor);
return newActivity;
}
内容来源于网络,如有侵权,请联系作者删除!