当前位置: 首页>>代码示例>>Java>>正文


Java Instrumentation.ActivityMonitor方法代码示例

本文整理汇总了Java中android.app.Instrumentation.ActivityMonitor方法的典型用法代码示例。如果您正苦于以下问题:Java Instrumentation.ActivityMonitor方法的具体用法?Java Instrumentation.ActivityMonitor怎么用?Java Instrumentation.ActivityMonitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Instrumentation的用法示例。


在下文中一共展示了Instrumentation.ActivityMonitor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForOverlay

import android.app.Instrumentation; //导入方法依赖的package包/类
void waitForOverlay(long millis) {
    if (!testSystemLayer()) {
        Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(MainActivity.class.getCanonicalName(),
                null, false);
        getInstrumentation().addMonitor(monitor);
        getActivityRule().launchActivity(new Intent(getApplication(), MainActivity.class));
        try {
            monitor.waitForActivityWithTimeout(5000);
        } finally {
            getInstrumentation().removeMonitor(monitor);
        }
    }
    try {
        Thread.currentThread().sleep(millis);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:19,代码来源:DebugOverlayInstrumentedTest.java

示例2: recreateCurrentActivity

import android.app.Instrumentation; //导入方法依赖的package包/类
public void recreateCurrentActivity() {
    if( mActivity != null )
    {
        final Instrumentation.ActivityMonitor monitor =
            new Instrumentation.ActivityMonitor(mActivity.getClass().getName(), null, false);
        mInstrumentation.addMonitor(monitor);

        mInstrumentation.runOnMainSync(new Runnable()
        {
            @Override
            public void run()
            {
                mActivity.recreate();
            }
        });
        afterActivityFinished();
        mInstrumentation.waitForIdleSync();

        beforeActivityLaunched();
        //noinspection unchecked
        mActivity = checkNotNull((T) monitor.waitForActivity(), "current activity shouldn't be null!");
        afterActivityLaunched();

        mInstrumentation.removeMonitor(monitor);
    }
}
 
开发者ID:benoitletondor,项目名称:mvp-core,代码行数:27,代码来源:ActivityLifecycleTestRule.java

示例3: startSecondActivity

import android.app.Instrumentation; //导入方法依赖的package包/类
@Test
public void startSecondActivity() {
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            debugOverlay = new DebugOverlay.Builder(getApplication())
                    .allowSystemLayer(testSystemLayer())
                    .build();
            debugOverlay.install();
        }
    });

    waitForOverlay();

    Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(ScrollingActivity.class.getCanonicalName(),
            null, false);
    getInstrumentation().addMonitor(monitor);
    try {
        onView(withId(com.ms_square.debugoverlay.sample.R.id.fab)).perform(click());
        Activity nextActivity = monitor.waitForActivityWithTimeout(5000);
        assertThat(nextActivity, Matchers.is(Matchers.notNullValue()));

        takeActivityScreenShot(nextActivity);

        nextActivity.finish();
    } finally {
        getInstrumentation().removeMonitor(monitor);
    }
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:30,代码来源:DebugOverlayInstrumentedTest.java

示例4: menuClickProfileGoesToProfile

import android.app.Instrumentation; //导入方法依赖的package包/类
@Test
public void menuClickProfileGoesToProfile() throws Exception {
    Instrumentation.ActivityMonitor activityMonitor = getInstrumentation()
            .addMonitor(ProfileActivity.class.getName(), null, false);

    onView(withId(R.id.action_profile)).perform(click());
    ProfileActivity targetActivity = (ProfileActivity) activityMonitor.waitForActivity();
    assertNotNull("Target Activity is not launched", targetActivity);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:10,代码来源:MainActivityInstrumentedTest.java

示例5: menuClickFriendsGoesToFriends

import android.app.Instrumentation; //导入方法依赖的package包/类
@Test
public void menuClickFriendsGoesToFriends() throws Exception {
    Instrumentation.ActivityMonitor activityMonitor = getInstrumentation()
            .addMonitor(FriendsActivity.class.getName(), null, false);

    onView(withId(R.id.action_friends)).perform(click());
    FriendsActivity targetActivity = (FriendsActivity) activityMonitor.waitForActivity();
    assertNotNull("Target Activity is not launched", targetActivity);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:10,代码来源:MainActivityInstrumentedTest.java

示例6: openActivity

import android.app.Instrumentation; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void openActivity(){
    Instrumentation.ActivityMonitor activityMonitor = new Instrumentation.ActivityMonitor(SelectPictureActivity.class.getName(), null, false);
    instrumentation.addMonitor(activityMonitor);

    onView(withId(R.id.changePictureButton)).perform(click());

    Activity launchedActivity = instrumentation.waitForMonitor(activityMonitor);
    Assert.assertEquals(launchedActivity.getClass(), SelectPictureActivity.class);
    launchedActivity.finish();
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:12,代码来源:MainActivityTest.java


注:本文中的android.app.Instrumentation.ActivityMonitor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。