Search in sources :

Example 6 with SetupChooseLockPasswordFragment

use of com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment 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 7 with SetupChooseLockPasswordFragment

use of com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment in project android_packages_apps_Settings by crdroidandroid.

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 8 with SetupChooseLockPasswordFragment

use of com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment 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 9 with SetupChooseLockPasswordFragment

use of com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment in project android_packages_apps_Settings by omnirom.

the class SetupChooseLockPasswordTest method createActivity_inputPasswordInConfirmStage_clearButtonShouldBeShown.

@Test
public void createActivity_inputPasswordInConfirmStage_clearButtonShouldBeShown() {
    SetupChooseLockPassword activity = createSetupChooseLockPassword();
    SetupChooseLockPasswordFragment fragment = (SetupChooseLockPasswordFragment) activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
    ScrollToParentEditText passwordEntry = activity.findViewById(R.id.password_entry);
    passwordEntry.setText("");
    fragment.updateStage(Stage.NeedToConfirm);
    final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
    final Button skipOrClearButton = layout.getMixin(FooterBarMixin.class).getSecondaryButtonView();
    assertThat(skipOrClearButton.isEnabled()).isTrue();
    assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.GONE);
    passwordEntry.setText("1234");
    fragment.updateUi();
    assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
    assertThat(skipOrClearButton.getText()).isEqualTo(application.getString(R.string.lockpassword_clear_label));
}
Also used : PartnerCustomizationLayout(com.google.android.setupcompat.PartnerCustomizationLayout) ScrollToParentEditText(com.android.settings.widget.ScrollToParentEditText) Button(android.widget.Button) SetupChooseLockPasswordFragment(com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) Test(org.junit.Test)

Aggregations

SetupChooseLockPasswordFragment (com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment)9 Test (org.junit.Test)9 Intent (android.content.Intent)7 Bundle (android.os.Bundle)7 IntentBuilder (com.android.settings.password.ChooseLockPassword.IntentBuilder)7 ShadowActivity (org.robolectric.shadows.ShadowActivity)7 IntentForResult (org.robolectric.shadows.ShadowActivity.IntentForResult)5 Button (android.widget.Button)2 ScrollToParentEditText (com.android.settings.widget.ScrollToParentEditText)2 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)2 FooterBarMixin (com.google.android.setupcompat.template.FooterBarMixin)2