コード例 #1
0
  @Test
  public void testOnCreateWhenASKEnabledAndInactive() throws Exception {
    // mocking ASK as enable and inactive
    ShadowSettings.ShadowSecure.putString(
        RuntimeEnvironment.application.getContentResolver(),
        Settings.Secure.ENABLED_INPUT_METHODS,
        new ComponentName("net.some.one.else", "net.some.one.else.IME").flattenToString()
            + ":"
            + new ComponentName(
                    RuntimeEnvironment.application.getPackageName(),
                    RuntimeEnvironment.application.getPackageName() + ".IME")
                .flattenToString());
    ShadowSettings.ShadowSecure.putString(
        RuntimeEnvironment.application.getContentResolver(),
        Settings.Secure.DEFAULT_INPUT_METHOD,
        new ComponentName("net.some.one.else", "net.some.one.else.IME").flattenToString());

    Assert.assertNull(ShadowApplication.getInstance().getNextStartedActivity());
    ActivityController<LauncherSettingsActivity> controller =
        Robolectric.buildActivity(LauncherSettingsActivity.class).attach().create().resume();
    Intent startMainApp = ShadowApplication.getInstance().getNextStartedActivity();
    Assert.assertNotNull(startMainApp);

    Intent expectIntent = new Intent(controller.get(), MainSettingsActivity.class);

    Assert.assertEquals(expectIntent.getComponent(), startMainApp.getComponent());
  }
コード例 #2
0
  @Test
  public void testOnCreateWhenASKNotEnabled() throws Exception {
    // mocking ASK as disabled and inactive
    ShadowSettings.ShadowSecure.putString(
        RuntimeEnvironment.application.getContentResolver(),
        Settings.Secure.ENABLED_INPUT_METHODS,
        new ComponentName("net.some.one.else", "net.some.one.else.IME").flattenToString());
    ShadowSettings.ShadowSecure.putString(
        RuntimeEnvironment.application.getContentResolver(),
        Settings.Secure.DEFAULT_INPUT_METHOD,
        new ComponentName("net.some.one.else", "net.some.one.else.IME").flattenToString());

    Assert.assertNull(ShadowApplication.getInstance().getNextStartedActivity());
    ActivityController<LauncherSettingsActivity> controller =
        Robolectric.buildActivity(LauncherSettingsActivity.class).attach().create().resume();
    Intent startWizardActivityIntent = ShadowApplication.getInstance().getNextStartedActivity();
    Assert.assertNotNull(startWizardActivityIntent);

    Intent expectIntent =
        MainSettingsActivity.createStartActivityIntentForAddingFragmentToUi(
            controller.get(),
            MainSettingsActivity.class,
            new SetUpKeyboardWizardFragment(),
            TransitionExperiences.ROOT_FRAGMENT_EXPERIENCE_TRANSITION);

    Assert.assertEquals(expectIntent.getComponent(), startWizardActivityIntent.getComponent());
    Assert.assertEquals(expectIntent.getAction(), startWizardActivityIntent.getAction());
    Assert.assertEquals(
        expectIntent.getParcelableExtra("FragmentChauffeurActivity_KEY_FRAGMENT_ANIMATION"),
        startWizardActivityIntent.getParcelableExtra(
            "FragmentChauffeurActivity_KEY_FRAGMENT_ANIMATION"));
    Assert.assertEquals(
        expectIntent.getSerializableExtra("FragmentChauffeurActivity_KEY_FRAGMENT_CLASS_TO_ADD"),
        startWizardActivityIntent.getSerializableExtra(
            "FragmentChauffeurActivity_KEY_FRAGMENT_CLASS_TO_ADD"));
  }