Search in sources :

Example 6 with ActivityMonitor

use of android.app.Instrumentation.ActivityMonitor in project welcome-android by stephentuso.

the class WelcomeScreenHelperAndroidTest method testShow.

@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));
}
Also used : ActivityMonitor(android.app.Instrumentation.ActivityMonitor) Bundle(android.os.Bundle) DefaultWelcomeActivity(com.stephentuso.welcomeexample.DefaultWelcomeActivity) DefaultWelcomeActivity(com.stephentuso.welcomeexample.DefaultWelcomeActivity) Activity(android.app.Activity) Test(org.junit.Test)

Example 7 with ActivityMonitor

use of android.app.Instrumentation.ActivityMonitor in project appium-espresso-driver by appium.

the class CreateSession method startActivity.

private void startActivity(String appActivity) {
    System.out.println("Starting activity '" + appActivity + "'");
    Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
    ActivityMonitor mSessionMonitor = mInstrumentation.addMonitor(appActivity, null, false);
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName(mInstrumentation.getTargetContext(), appActivity);
    mInstrumentation.startActivitySync(intent);
    Activity mCurrentActivity = mInstrumentation.waitForMonitor(mSessionMonitor);
    System.out.println("Activity '" + mCurrentActivity.getLocalClassName() + "' started");
}
Also used : ActivityMonitor(android.app.Instrumentation.ActivityMonitor) Instrumentation(android.app.Instrumentation) Activity(android.app.Activity) Intent(android.content.Intent)

Example 8 with ActivityMonitor

use of android.app.Instrumentation.ActivityMonitor in project welcome-android by stephentuso.

the class WelcomeScreenHelperAndroidTest method testForceShow.

@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);
}
Also used : ActivityMonitor(android.app.Instrumentation.ActivityMonitor) DefaultWelcomeActivity(com.stephentuso.welcomeexample.DefaultWelcomeActivity) DefaultWelcomeActivity(com.stephentuso.welcomeexample.DefaultWelcomeActivity) Activity(android.app.Activity) Test(org.junit.Test)

Aggregations

ActivityMonitor (android.app.Instrumentation.ActivityMonitor)8 Activity (android.app.Activity)6 FragmentActivity (android.support.v4.app.FragmentActivity)2 DefaultWelcomeActivity (com.stephentuso.welcomeexample.DefaultWelcomeActivity)2 Test (org.junit.Test)2 Instrumentation (android.app.Instrumentation)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 MainActivity (jp.mixi.sample.test.MainActivity)1 SubActivity (jp.mixi.sample.test.SubActivity)1