Search in sources :

Example 21 with IntentBuilder

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

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 = Robolectric.buildActivity(SetupChooseLockPassword.class, intent).setup().get();
    SetupChooseLockPasswordFragment fragment = (SetupChooseLockPasswordFragment) activity.getFragmentManager().findFragmentById(R.id.main_content);
    fragment.onLockTypeSelected(ScreenLockType.PATTERN);
    ShadowActivity shadowActivity = shadowOf(activity);
    IntentForResult chooseLockIntent = shadowActivity.getNextStartedActivityForResult();
    assertThat(chooseLockIntent).isNotNull();
    assertThat(chooseLockIntent.requestCode).isEqualTo(SetupChooseLockPasswordFragment.REQUEST_SCREEN_LOCK_OPTIONS);
    assertThat(chooseLockIntent.intent.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) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) Test(org.junit.Test)

Example 22 with IntentBuilder

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

the class ChooseLockPasswordTest method intentBuilder_setChallenge_shouldAddExtras.

@Test
public void intentBuilder_setChallenge_shouldAddExtras() {
    Intent intent = new IntentBuilder(application).setChallenge(12345L).setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC).setPasswordLengthRange(123, 456).setUserId(123).build();
    assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false)).named("EXTRA_KEY_HAS_CHALLENGE").isTrue();
    assertThat(intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L)).named("EXTRA_KEY_CHALLENGE").isEqualTo(12345L);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0)).named("PASSWORD_MIN_KEY").isEqualTo(123);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MAX_KEY, 0)).named("PASSWORD_MAX_KEY").isEqualTo(456);
    assertThat(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, 0)).named("PASSWORD_TYPE_KEY").isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
    assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0)).named("EXTRA_USER_ID").isEqualTo(123);
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Example 23 with IntentBuilder

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

the class ChooseLockPasswordTest method intentBuilder_setChallenge_shouldAddExtras.

@Test
public void intentBuilder_setChallenge_shouldAddExtras() {
    Intent intent = new IntentBuilder(application).setChallenge(12345L).setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC).setPasswordLengthRange(123, 456).setUserId(123).build();
    assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false)).named("EXTRA_KEY_HAS_CHALLENGE").isTrue();
    assertThat(intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L)).named("EXTRA_KEY_CHALLENGE").isEqualTo(12345L);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0)).named("PASSWORD_MIN_KEY").isEqualTo(123);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MAX_KEY, 0)).named("PASSWORD_MAX_KEY").isEqualTo(456);
    assertThat(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, 0)).named("PASSWORD_TYPE_KEY").isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
    assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0)).named("EXTRA_USER_ID").isEqualTo(123);
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Example 24 with IntentBuilder

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

the class ChooseLockPasswordTest method intentBuilder_setChallenge_shouldAddExtras.

@Test
public void intentBuilder_setChallenge_shouldAddExtras() {
    Intent intent = new IntentBuilder(application).setChallenge(12345L).setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC).setPasswordLengthRange(123, 456).setUserId(123).build();
    assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false)).named("EXTRA_KEY_HAS_CHALLENGE").isTrue();
    assertThat(intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L)).named("EXTRA_KEY_CHALLENGE").isEqualTo(12345L);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0)).named("PASSWORD_MIN_KEY").isEqualTo(123);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MAX_KEY, 0)).named("PASSWORD_MAX_KEY").isEqualTo(456);
    assertThat(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, 0)).named("PASSWORD_TYPE_KEY").isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
    assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0)).named("EXTRA_USER_ID").isEqualTo(123);
}
Also used : IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) Intent(android.content.Intent) Test(org.junit.Test)

Example 25 with IntentBuilder

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

the class ChooseLockPasswordTest method intentBuilder_setPassword_shouldAddExtras.

@Test
public void intentBuilder_setPassword_shouldAddExtras() {
    Intent intent = new IntentBuilder(application).setPassword("password").setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC).setPasswordLengthRange(123, 456).setUserId(123).build();
    assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true)).named("EXTRA_KEY_HAS_CHALLENGE").isFalse();
    assertThat(intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)).named("EXTRA_KEY_PASSWORD").isEqualTo("password");
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0)).named("PASSWORD_MIN_KEY").isEqualTo(123);
    assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MAX_KEY, 0)).named("PASSWORD_MAX_KEY").isEqualTo(456);
    assertThat(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, 0)).named("PASSWORD_TYPE_KEY").isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
    assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0)).named("EXTRA_USER_ID").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