Merge changes Id3aaa354,Ia2782c7c into tm-qpr-dev

* changes:
  Revert "Revert "[Bouncer] refine entry for bouncer user switcher.""
  [Bouncer] Have initial message id for sim pin.
This commit is contained in:
Aaron Liu
2022-12-14 16:39:53 +00:00
committed by Android (Google) Code Review
12 changed files with 215 additions and 173 deletions

View File

@@ -260,7 +260,8 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
if (reason != PROMPT_REASON_NONE) { if (reason != PROMPT_REASON_NONE) {
int promtReasonStringRes = mView.getPromptReasonStringRes(reason); int promtReasonStringRes = mView.getPromptReasonStringRes(reason);
if (promtReasonStringRes != 0) { if (promtReasonStringRes != 0) {
mMessageAreaController.setMessage(promtReasonStringRes); mMessageAreaController.setMessage(
mView.getResources().getString(promtReasonStringRes), false);
} }
} }
} }

View File

@@ -142,8 +142,11 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
} }
public void startAppearAnimation() { public void startAppearAnimation() {
if (TextUtils.isEmpty(mMessageAreaController.getMessage())) { if (TextUtils.isEmpty(mMessageAreaController.getMessage())
mMessageAreaController.setMessage(getInitialMessageResId()); && getInitialMessageResId() != 0) {
mMessageAreaController.setMessage(
mView.getResources().getString(getInitialMessageResId()),
/* animate= */ false);
} }
mView.startAppearAnimation(); mView.startAppearAnimation();
} }
@@ -163,9 +166,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
} }
/** Determines the message to show in the bouncer when it first appears. */ /** Determines the message to show in the bouncer when it first appears. */
protected int getInitialMessageResId() { protected abstract int getInitialMessageResId();
return 0;
}
/** Factory for a {@link KeyguardInputViewController}. */ /** Factory for a {@link KeyguardInputViewController}. */
public static class Factory { public static class Factory {

View File

@@ -52,6 +52,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
private int mYTransOffset; private int mYTransOffset;
private View mBouncerMessageView; private View mBouncerMessageView;
@DevicePostureInt private int mLastDevicePosture = DEVICE_POSTURE_UNKNOWN; @DevicePostureInt private int mLastDevicePosture = DEVICE_POSTURE_UNKNOWN;
public static final long ANIMATION_DURATION = 650;
public KeyguardPINView(Context context) { public KeyguardPINView(Context context) {
this(context, null); this(context, null);
@@ -181,7 +182,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
if (mAppearAnimator.isRunning()) { if (mAppearAnimator.isRunning()) {
mAppearAnimator.cancel(); mAppearAnimator.cancel();
} }
mAppearAnimator.setDuration(650); mAppearAnimator.setDuration(ANIMATION_DURATION);
mAppearAnimator.addUpdateListener(animation -> animate(animation.getAnimatedFraction())); mAppearAnimator.addUpdateListener(animation -> animate(animation.getAnimatedFraction()));
mAppearAnimator.start(); mAppearAnimator.start();
} }

View File

@@ -139,4 +139,9 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB
super.startErrorAnimation(); super.startErrorAnimation();
mView.startErrorAnimation(); mView.startErrorAnimation();
} }
@Override
protected int getInitialMessageResId() {
return R.string.keyguard_enter_your_pin;
}
} }

View File

@@ -74,9 +74,4 @@ public class KeyguardPinViewController
return mView.startDisappearAnimation( return mView.startDisappearAnimation(
mKeyguardUpdateMonitor.needsSlowUnlockTransition(), finishRunnable); mKeyguardUpdateMonitor.needsSlowUnlockTransition(), finishRunnable);
} }
@Override
protected int getInitialMessageResId() {
return R.string.keyguard_enter_your_pin;
}
} }

View File

@@ -36,8 +36,11 @@ import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;
import static java.lang.Integer.max; import static java.lang.Integer.max;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
@@ -967,11 +970,23 @@ public class KeyguardSecurityContainer extends ConstraintLayout {
} }
mUserSwitcherViewGroup.setAlpha(0f); mUserSwitcherViewGroup.setAlpha(0f);
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mUserSwitcherViewGroup, View.ALPHA, ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
1f); int yTrans = mView.getResources().getDimensionPixelSize(R.dimen.pin_view_trans_y_entry);
alphaAnim.setInterpolator(Interpolators.ALPHA_IN); animator.setInterpolator(Interpolators.STANDARD_DECELERATE);
alphaAnim.setDuration(500); animator.setDuration(650);
alphaAnim.start(); animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mUserSwitcherViewGroup.setAlpha(1f);
mUserSwitcherViewGroup.setTranslationY(0f);
}
});
animator.addUpdateListener(animation -> {
float value = (float) animation.getAnimatedValue();
mUserSwitcherViewGroup.setAlpha(value);
mUserSwitcherViewGroup.setTranslationY(yTrans - yTrans * value);
});
animator.start();
} }
@Override @Override

View File

@@ -156,5 +156,10 @@ public class KeyguardSecurityViewFlipperController
@Override @Override
public void onStartingToHide() { public void onStartingToHide() {
} }
@Override
protected int getInitialMessageResId() {
return 0;
}
} }
} }

View File

@@ -19,6 +19,7 @@ package com.android.keyguard;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;
@@ -87,6 +88,7 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
when(mAbsKeyInputView.isAttachedToWindow()).thenReturn(true); when(mAbsKeyInputView.isAttachedToWindow()).thenReturn(true);
when(mAbsKeyInputView.requireViewById(R.id.bouncer_message_area)) when(mAbsKeyInputView.requireViewById(R.id.bouncer_message_area))
.thenReturn(mKeyguardMessageArea); .thenReturn(mKeyguardMessageArea);
when(mAbsKeyInputView.getResources()).thenReturn(getContext().getResources());
mKeyguardAbsKeyInputViewController = new KeyguardAbsKeyInputViewController(mAbsKeyInputView, mKeyguardAbsKeyInputViewController = new KeyguardAbsKeyInputViewController(mAbsKeyInputView,
mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback, mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
mKeyguardMessageAreaControllerFactory, mLatencyTracker, mFalsingCollector, mKeyguardMessageAreaControllerFactory, mLatencyTracker, mFalsingCollector,
@@ -99,6 +101,11 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
public void onResume(int reason) { public void onResume(int reason) {
super.onResume(reason); super.onResume(reason);
} }
@Override
protected int getInitialMessageResId() {
return 0;
}
}; };
mKeyguardAbsKeyInputViewController.init(); mKeyguardAbsKeyInputViewController.init();
reset(mKeyguardMessageAreaController); // Clear out implicit call to init. reset(mKeyguardMessageAreaController); // Clear out implicit call to init.
@@ -125,4 +132,22 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
verifyZeroInteractions(mKeyguardSecurityCallback); verifyZeroInteractions(mKeyguardSecurityCallback);
verifyZeroInteractions(mKeyguardMessageAreaController); verifyZeroInteractions(mKeyguardMessageAreaController);
} }
@Test
public void onPromptReasonNone_doesNotSetMessage() {
mKeyguardAbsKeyInputViewController.showPromptReason(0);
verify(mKeyguardMessageAreaController, never()).setMessage(
getContext().getResources().getString(R.string.kg_prompt_reason_restart_password),
false);
}
@Test
public void onPromptReason_setsMessage() {
when(mAbsKeyInputView.getPromptReasonStringRes(1)).thenReturn(
R.string.kg_prompt_reason_restart_password);
mKeyguardAbsKeyInputViewController.showPromptReason(1);
verify(mKeyguardMessageAreaController).setMessage(
getContext().getResources().getString(R.string.kg_prompt_reason_restart_password),
false);
}
} }

View File

@@ -30,45 +30,33 @@ import com.android.systemui.util.concurrency.DelayableExecutor
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito import org.mockito.Mockito
import org.mockito.Mockito.`when`
import org.mockito.Mockito.never import org.mockito.Mockito.never
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner::class) @RunWith(AndroidTestingRunner::class)
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
class KeyguardPasswordViewControllerTest : SysuiTestCase() { class KeyguardPasswordViewControllerTest : SysuiTestCase() {
@Mock @Mock private lateinit var keyguardPasswordView: KeyguardPasswordView
private lateinit var keyguardPasswordView: KeyguardPasswordView @Mock private lateinit var passwordEntry: EditText
@Mock @Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
private lateinit var passwordEntry: EditText @Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode
@Mock @Mock lateinit var lockPatternUtils: LockPatternUtils
lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor @Mock lateinit var keyguardSecurityCallback: KeyguardSecurityCallback
@Mock @Mock lateinit var messageAreaControllerFactory: KeyguardMessageAreaController.Factory
lateinit var securityMode: KeyguardSecurityModel.SecurityMode @Mock lateinit var latencyTracker: LatencyTracker
@Mock @Mock lateinit var inputMethodManager: InputMethodManager
lateinit var lockPatternUtils: LockPatternUtils @Mock lateinit var emergencyButtonController: EmergencyButtonController
@Mock @Mock lateinit var mainExecutor: DelayableExecutor
lateinit var keyguardSecurityCallback: KeyguardSecurityCallback @Mock lateinit var falsingCollector: FalsingCollector
@Mock @Mock lateinit var keyguardViewController: KeyguardViewController
lateinit var messageAreaControllerFactory: KeyguardMessageAreaController.Factory @Mock private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
@Mock
lateinit var latencyTracker: LatencyTracker
@Mock
lateinit var inputMethodManager: InputMethodManager
@Mock
lateinit var emergencyButtonController: EmergencyButtonController
@Mock
lateinit var mainExecutor: DelayableExecutor
@Mock
lateinit var falsingCollector: FalsingCollector
@Mock
lateinit var keyguardViewController: KeyguardViewController
@Mock
private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
@Mock @Mock
private lateinit var mKeyguardMessageAreaController: private lateinit var mKeyguardMessageAreaController:
KeyguardMessageAreaController<BouncerKeyguardMessageArea> KeyguardMessageAreaController<BouncerKeyguardMessageArea>
@@ -79,15 +67,17 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
fun setup() { fun setup() {
MockitoAnnotations.initMocks(this) MockitoAnnotations.initMocks(this)
Mockito.`when`( Mockito.`when`(
keyguardPasswordView keyguardPasswordView.requireViewById<BouncerKeyguardMessageArea>(
.requireViewById<BouncerKeyguardMessageArea>(R.id.bouncer_message_area) R.id.bouncer_message_area))
).thenReturn(mKeyguardMessageArea) .thenReturn(mKeyguardMessageArea)
Mockito.`when`(messageAreaControllerFactory.create(mKeyguardMessageArea)) Mockito.`when`(messageAreaControllerFactory.create(mKeyguardMessageArea))
.thenReturn(mKeyguardMessageAreaController) .thenReturn(mKeyguardMessageAreaController)
Mockito.`when`(keyguardPasswordView.passwordTextViewId).thenReturn(R.id.passwordEntry) Mockito.`when`(keyguardPasswordView.passwordTextViewId).thenReturn(R.id.passwordEntry)
Mockito.`when`(keyguardPasswordView.findViewById<EditText>(R.id.passwordEntry) Mockito.`when`(keyguardPasswordView.findViewById<EditText>(R.id.passwordEntry))
).thenReturn(passwordEntry) .thenReturn(passwordEntry)
keyguardPasswordViewController = KeyguardPasswordViewController( `when`(keyguardPasswordView.resources).thenReturn(context.resources)
keyguardPasswordViewController =
KeyguardPasswordViewController(
keyguardPasswordView, keyguardPasswordView,
keyguardUpdateMonitor, keyguardUpdateMonitor,
securityMode, securityMode,
@@ -100,8 +90,7 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
mainExecutor, mainExecutor,
mContext.resources, mContext.resources,
falsingCollector, falsingCollector,
keyguardViewController keyguardViewController)
)
} }
@Test @Test
@@ -135,16 +124,14 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
@Test @Test
fun startAppearAnimation() { fun startAppearAnimation() {
keyguardPasswordViewController.startAppearAnimation() keyguardPasswordViewController.startAppearAnimation()
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_password) verify(mKeyguardMessageAreaController)
.setMessage(context.resources.getString(R.string.keyguard_enter_your_password), false)
} }
@Test @Test
fun startAppearAnimation_withExistingMessage() { fun startAppearAnimation_withExistingMessage() {
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.") `when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
keyguardPasswordViewController.startAppearAnimation() keyguardPasswordViewController.startAppearAnimation()
verify( verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
mKeyguardMessageAreaController,
never()
).setMessage(R.string.keyguard_enter_your_password)
} }
} }

View File

@@ -30,54 +30,45 @@ import com.android.systemui.statusbar.policy.DevicePostureController
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.never
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.mockito.Mockito.never
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner::class) @RunWith(AndroidTestingRunner::class)
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
class KeyguardPatternViewControllerTest : SysuiTestCase() { class KeyguardPatternViewControllerTest : SysuiTestCase() {
@Mock @Mock private lateinit var mKeyguardPatternView: KeyguardPatternView
private lateinit var mKeyguardPatternView: KeyguardPatternView
@Mock @Mock private lateinit var mKeyguardUpdateMonitor: KeyguardUpdateMonitor
private lateinit var mKeyguardUpdateMonitor: KeyguardUpdateMonitor
@Mock @Mock private lateinit var mSecurityMode: KeyguardSecurityModel.SecurityMode
private lateinit var mSecurityMode: KeyguardSecurityModel.SecurityMode
@Mock @Mock private lateinit var mLockPatternUtils: LockPatternUtils
private lateinit var mLockPatternUtils: LockPatternUtils
@Mock @Mock private lateinit var mKeyguardSecurityCallback: KeyguardSecurityCallback
private lateinit var mKeyguardSecurityCallback: KeyguardSecurityCallback
@Mock @Mock private lateinit var mLatencyTracker: LatencyTracker
private lateinit var mLatencyTracker: LatencyTracker
private var mFalsingCollector: FalsingCollector = FalsingCollectorFake() private var mFalsingCollector: FalsingCollector = FalsingCollectorFake()
@Mock @Mock private lateinit var mEmergencyButtonController: EmergencyButtonController
private lateinit var mEmergencyButtonController: EmergencyButtonController
@Mock @Mock
private lateinit private lateinit var mKeyguardMessageAreaControllerFactory: KeyguardMessageAreaController.Factory
var mKeyguardMessageAreaControllerFactory: KeyguardMessageAreaController.Factory
@Mock @Mock private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
@Mock @Mock
private lateinit var mKeyguardMessageAreaController: private lateinit var mKeyguardMessageAreaController:
KeyguardMessageAreaController<BouncerKeyguardMessageArea> KeyguardMessageAreaController<BouncerKeyguardMessageArea>
@Mock @Mock private lateinit var mLockPatternView: LockPatternView
private lateinit var mLockPatternView: LockPatternView
@Mock @Mock private lateinit var mPostureController: DevicePostureController
private lateinit var mPostureController: DevicePostureController
private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController
@@ -85,19 +76,27 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
fun setup() { fun setup() {
MockitoAnnotations.initMocks(this) MockitoAnnotations.initMocks(this)
`when`(mKeyguardPatternView.isAttachedToWindow).thenReturn(true) `when`(mKeyguardPatternView.isAttachedToWindow).thenReturn(true)
`when`(mKeyguardPatternView `when`(
.requireViewById<BouncerKeyguardMessageArea>(R.id.bouncer_message_area)) mKeyguardPatternView.requireViewById<BouncerKeyguardMessageArea>(
R.id.bouncer_message_area))
.thenReturn(mKeyguardMessageArea) .thenReturn(mKeyguardMessageArea)
`when`(mKeyguardPatternView.findViewById<LockPatternView>(R.id.lockPatternView)) `when`(mKeyguardPatternView.findViewById<LockPatternView>(R.id.lockPatternView))
.thenReturn(mLockPatternView) .thenReturn(mLockPatternView)
`when`(mKeyguardMessageAreaControllerFactory.create(mKeyguardMessageArea)) `when`(mKeyguardMessageAreaControllerFactory.create(mKeyguardMessageArea))
.thenReturn(mKeyguardMessageAreaController) .thenReturn(mKeyguardMessageAreaController)
mKeyguardPatternViewController = KeyguardPatternViewController( `when`(mKeyguardPatternView.resources).thenReturn(context.resources)
mKeyguardPatternViewController =
KeyguardPatternViewController(
mKeyguardPatternView, mKeyguardPatternView,
mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback, mKeyguardUpdateMonitor,
mLatencyTracker, mFalsingCollector, mEmergencyButtonController, mSecurityMode,
mKeyguardMessageAreaControllerFactory, mPostureController mLockPatternUtils,
) mKeyguardSecurityCallback,
mLatencyTracker,
mFalsingCollector,
mEmergencyButtonController,
mKeyguardMessageAreaControllerFactory,
mPostureController)
} }
@Test @Test
@@ -107,20 +106,17 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern) verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
} }
@Test @Test
fun startAppearAnimation() { fun startAppearAnimation() {
mKeyguardPatternViewController.startAppearAnimation() mKeyguardPatternViewController.startAppearAnimation()
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern) verify(mKeyguardMessageAreaController)
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pattern), false)
} }
@Test @Test
fun startAppearAnimation_withExistingMessage() { fun startAppearAnimation_withExistingMessage() {
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.") `when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
mKeyguardPatternViewController.startAppearAnimation() mKeyguardPatternViewController.startAppearAnimation()
verify( verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
mKeyguardMessageAreaController,
never()
).setMessage(R.string.keyguard_enter_your_password)
} }
} }

View File

@@ -16,6 +16,8 @@
package com.android.keyguard; package com.android.keyguard;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -113,4 +115,9 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
mKeyguardPinViewController.onResume(KeyguardSecurityView.SCREEN_ON); mKeyguardPinViewController.onResume(KeyguardSecurityView.SCREEN_ON);
verify(mPasswordEntry).requestFocus(); verify(mPasswordEntry).requestFocus();
} }
@Test
public void testGetInitialMessageResId() {
assertThat(mKeyguardPinViewController.getInitialMessageResId()).isNotEqualTo(0);
}
} }

View File

@@ -31,10 +31,13 @@ import com.android.systemui.statusbar.policy.DevicePostureController
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito import org.mockito.Mockito
import org.mockito.Mockito.any import org.mockito.Mockito.any
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
@SmallTest @SmallTest
@@ -79,6 +82,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
keyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea::class.java)) keyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea::class.java))
) )
.thenReturn(keyguardMessageAreaController) .thenReturn(keyguardMessageAreaController)
`when`(keyguardPinView.resources).thenReturn(context.resources)
pinViewController = pinViewController =
KeyguardPinViewController( KeyguardPinViewController(
keyguardPinView, keyguardPinView,
@@ -98,14 +102,14 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
@Test @Test
fun startAppearAnimation() { fun startAppearAnimation() {
pinViewController.startAppearAnimation() pinViewController.startAppearAnimation()
verify(keyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pin) verify(keyguardMessageAreaController)
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pin), false)
} }
@Test @Test
fun startAppearAnimation_withExistingMessage() { fun startAppearAnimation_withExistingMessage() {
Mockito.`when`(keyguardMessageAreaController.message).thenReturn("Unlock to continue.") Mockito.`when`(keyguardMessageAreaController.message).thenReturn("Unlock to continue.")
pinViewController.startAppearAnimation() pinViewController.startAppearAnimation()
verify(keyguardMessageAreaController, Mockito.never()) verify(keyguardMessageAreaController, Mockito.never()).setMessage(anyString(), anyBoolean())
.setMessage(R.string.keyguard_enter_your_password)
} }
} }