Merge "Show customized message for private space lock setup screen" into main

This commit is contained in:
Joseph Vincent
2023-12-06 23:21:36 +00:00
committed by Android (Google) Code Review
6 changed files with 104 additions and 12 deletions

View File

@@ -28,6 +28,8 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;
import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.KEY_LOCK_SETTINGS_FOOTER;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE;
@@ -52,6 +54,7 @@ import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.provider.Settings.Global;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
@@ -379,6 +382,47 @@ public class ChooseLockGenericTest {
.isEqualTo("app name");
}
@Test
public void onSetNewPassword_withTitleAndDescription_displaysPassedTitleAndDescription() {
Intent intent =
new Intent(ACTION_SET_NEW_PASSWORD)
.putExtra(
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE,
R.string.private_space_lock_setup_title)
.putExtra(
EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION,
R.string.private_space_lock_setup_description);
initActivity(intent);
CharSequence expectedTitle = mActivity.getString(R.string.private_space_lock_setup_title);
CharSequence expectedDescription =
mActivity.getString(R.string.private_space_lock_setup_description);
assertThat(mActivity.getTitle().toString().contentEquals(expectedTitle)).isTrue();
TextView textView =
mFragment.getHeaderView().findViewById(R.id.biometric_header_description);
assertThat(textView.getText().toString().contentEquals(expectedDescription)).isTrue();
}
@Test
public void onSetNewPassword_withLockScreenTitle_titlePassedOntoNextActivity() {
Intent intent =
new Intent(ACTION_SET_NEW_PASSWORD)
.putExtra(
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE,
R.string.private_space_lock_setup_title);
initActivity(intent);
Preference facePref = new Preference(application);
facePref.setKey("unlock_skip_biometrics");
boolean result = mFragment.onPreferenceTreeClick(facePref);
assertThat(result).isTrue();
Intent actualIntent = shadowOf(mActivity).getNextStartedActivityForResult().intent;
assertThat(actualIntent.hasExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE)).isTrue();
assertThat(actualIntent.getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, -1))
.isEqualTo(R.string.private_space_lock_setup_title);
}
@Test
public void testUnifyProfile_IntentPassedToChooseLockPassword() {
final Bundle arguments = new Bundle();