Search in sources :

Example 36 with IntentBuilder

use of com.android.settings.password.ChooseLockPassword.IntentBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SetupChooseLockPasswordTest method createActivity_clickDifferentOption_extrasShouldBePropagated.

@Test
public void createActivity_clickDifferentOption_extrasShouldBePropagated() {
    Bundle bundle = new Bundle();
    bundle.putString("foo", "bar");
    Intent intent = new IntentBuilder(application).build();
    intent.putExtra(ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS, bundle);
    intent = SetupChooseLockPassword.modifyIntentForSetup(application, intent);
    intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, true);
    SetupChooseLockPassword activity = ActivityController.of(new SetupChooseLockPassword(), intent).setup().get();
    SetupChooseLockPasswordFragment fragment = (SetupChooseLockPasswordFragment) activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
    fragment.onLockTypeSelected(ScreenLockType.PATTERN);
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
    assertThat(nextStartedActivity).isNotNull();
    assertThat(nextStartedActivity.getBooleanExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false)).isTrue();
    assertThat(nextStartedActivity.getStringExtra("foo")).named("Foo extra").isEqualTo("bar");
}
Also used : Bundle(android.os.Bundle) IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) SetupChooseLockPasswordFragment(com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test)

Example 37 with IntentBuilder

use of com.android.settings.password.ChooseLockPassword.IntentBuilder in project android_packages_apps_Settings by omnirom.

the class SetupChooseLockPasswordTest method createActivity_shouldNotCrash.

@Test
public void createActivity_shouldNotCrash() {
    // Basic test for activity created without crashing
    final Intent intent = SetupChooseLockPassword.modifyIntentForSetup(application, new IntentBuilder(application).build());
    ActivityController.of(new SetupChooseLockPassword(), intent).setup().get();
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Example 38 with IntentBuilder

use of com.android.settings.password.ChooseLockPassword.IntentBuilder in project android_packages_apps_Settings by omnirom.

the class ChooseLockPasswordTest method intentBuilder_setMinComplexityMedium_hasMinComplexityExtraMedium.

@Test
public void intentBuilder_setMinComplexityMedium_hasMinComplexityExtraMedium() {
    Intent intent = new IntentBuilder(application).setPasswordRequirement(PASSWORD_COMPLEXITY_MEDIUM, null).build();
    assertThat(intent.hasExtra(ChooseLockPassword.EXTRA_KEY_MIN_COMPLEXITY)).isTrue();
    assertThat(intent.getIntExtra(ChooseLockPassword.EXTRA_KEY_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE)).isEqualTo(PASSWORD_COMPLEXITY_MEDIUM);
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Example 39 with IntentBuilder

use of com.android.settings.password.ChooseLockPassword.IntentBuilder in project android_packages_apps_Settings by omnirom.

the class ChooseLockPasswordTest method intentBuilder_setMinComplexityNotCalled.

@Test
public void intentBuilder_setMinComplexityNotCalled() {
    Intent intent = new IntentBuilder(application).build();
    assertThat(intent.hasExtra(ChooseLockPassword.EXTRA_KEY_MIN_COMPLEXITY)).isFalse();
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Example 40 with IntentBuilder

use of com.android.settings.password.ChooseLockPassword.IntentBuilder in project android_packages_apps_Settings by omnirom.

the class ChooseLockPasswordTest method intentBuilder_setRequestGatekeeperPassword_shouldAddExtras.

@Test
public void intentBuilder_setRequestGatekeeperPassword_shouldAddExtras() {
    Intent intent = new IntentBuilder(application).setRequestGatekeeperPasswordHandle(true).setPasswordType(PASSWORD_QUALITY_ALPHANUMERIC).setUserId(123).build();
    assertWithMessage("EXTRA_KEY_REQUEST_GK_PW").that(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, false)).isTrue();
    assertWithMessage("PASSWORD_TYPE_KEY").that(intent.getIntExtra(PASSWORD_TYPE_KEY, 0)).isEqualTo(PASSWORD_QUALITY_ALPHANUMERIC);
    assertWithMessage("EXTRA_USER_ID").that(intent.getIntExtra(Intent.EXTRA_USER_ID, 0)).isEqualTo(123);
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

IntentBuilder (com.android.settings.password.ChooseLockPassword.IntentBuilder)43 Intent (android.content.Intent)36 Test (org.junit.Test)29 Bundle (android.os.Bundle)7 ChooseLockPasswordFragment (com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment)7 SetupChooseLockPasswordFragment (com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment)7 ShadowActivity (org.robolectric.shadows.ShadowActivity)7 IntentForResult (org.robolectric.shadows.ShadowActivity.IntentForResult)5 LockscreenCredential (com.android.internal.widget.LockscreenCredential)2