當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。