Merge "Revert "[Bouncer] refine entry for bouncer user switcher."" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e8fdf35124
@@ -260,8 +260,7 @@ 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(
|
mMessageAreaController.setMessage(promtReasonStringRes);
|
||||||
mView.getResources().getString(promtReasonStringRes), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,9 +143,7 @@ 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(
|
mMessageAreaController.setMessage(getInitialMessageResId());
|
||||||
mView.getResources().getString(getInitialMessageResId()),
|
|
||||||
/* animate= */ false);
|
|
||||||
}
|
}
|
||||||
mView.startAppearAnimation();
|
mView.startAppearAnimation();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ 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);
|
||||||
@@ -182,7 +181,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
|||||||
if (mAppearAnimator.isRunning()) {
|
if (mAppearAnimator.isRunning()) {
|
||||||
mAppearAnimator.cancel();
|
mAppearAnimator.cancel();
|
||||||
}
|
}
|
||||||
mAppearAnimator.setDuration(ANIMATION_DURATION);
|
mAppearAnimator.setDuration(650);
|
||||||
mAppearAnimator.addUpdateListener(animation -> animate(animation.getAnimatedFraction()));
|
mAppearAnimator.addUpdateListener(animation -> animate(animation.getAnimatedFraction()));
|
||||||
mAppearAnimator.start();
|
mAppearAnimator.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,8 @@ 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;
|
||||||
@@ -970,23 +967,11 @@ public class KeyguardSecurityContainer extends ConstraintLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mUserSwitcherViewGroup.setAlpha(0f);
|
mUserSwitcherViewGroup.setAlpha(0f);
|
||||||
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
|
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mUserSwitcherViewGroup, View.ALPHA,
|
||||||
int yTrans = mView.getResources().getDimensionPixelSize(R.dimen.pin_view_trans_y_entry);
|
1f);
|
||||||
animator.setInterpolator(Interpolators.STANDARD_DECELERATE);
|
alphaAnim.setInterpolator(Interpolators.ALPHA_IN);
|
||||||
animator.setDuration(650);
|
alphaAnim.setDuration(500);
|
||||||
animator.addListener(new AnimatorListenerAdapter() {
|
alphaAnim.start();
|
||||||
@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
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ 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;
|
||||||
@@ -88,7 +87,6 @@ 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,
|
||||||
@@ -127,22 +125,4 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,54 +30,64 @@ 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 private lateinit var keyguardPasswordView: KeyguardPasswordView
|
@Mock
|
||||||
@Mock private lateinit var passwordEntry: EditText
|
private lateinit var keyguardPasswordView: KeyguardPasswordView
|
||||||
@Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
@Mock
|
||||||
@Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode
|
private lateinit var passwordEntry: EditText
|
||||||
@Mock lateinit var lockPatternUtils: LockPatternUtils
|
@Mock
|
||||||
@Mock lateinit var keyguardSecurityCallback: KeyguardSecurityCallback
|
lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||||
@Mock lateinit var messageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
@Mock
|
||||||
@Mock lateinit var latencyTracker: LatencyTracker
|
lateinit var securityMode: KeyguardSecurityModel.SecurityMode
|
||||||
@Mock lateinit var inputMethodManager: InputMethodManager
|
@Mock
|
||||||
@Mock lateinit var emergencyButtonController: EmergencyButtonController
|
lateinit var lockPatternUtils: LockPatternUtils
|
||||||
@Mock lateinit var mainExecutor: DelayableExecutor
|
@Mock
|
||||||
@Mock lateinit var falsingCollector: FalsingCollector
|
lateinit var keyguardSecurityCallback: KeyguardSecurityCallback
|
||||||
@Mock lateinit var keyguardViewController: KeyguardViewController
|
@Mock
|
||||||
@Mock private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
|
lateinit var messageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mKeyguardMessageAreaController:
|
lateinit var latencyTracker: LatencyTracker
|
||||||
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
@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
|
||||||
|
private lateinit var mKeyguardMessageAreaController:
|
||||||
|
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
||||||
|
|
||||||
private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController
|
private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
Mockito.`when`(
|
Mockito.`when`(
|
||||||
keyguardPasswordView.requireViewById<BouncerKeyguardMessageArea>(
|
keyguardPasswordView
|
||||||
R.id.bouncer_message_area))
|
.requireViewById<BouncerKeyguardMessageArea>(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)
|
||||||
`when`(keyguardPasswordView.resources).thenReturn(context.resources)
|
keyguardPasswordViewController = KeyguardPasswordViewController(
|
||||||
keyguardPasswordViewController =
|
|
||||||
KeyguardPasswordViewController(
|
|
||||||
keyguardPasswordView,
|
keyguardPasswordView,
|
||||||
keyguardUpdateMonitor,
|
keyguardUpdateMonitor,
|
||||||
securityMode,
|
securityMode,
|
||||||
@@ -90,48 +100,51 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
|
|||||||
mainExecutor,
|
mainExecutor,
|
||||||
mContext.resources,
|
mContext.resources,
|
||||||
falsingCollector,
|
falsingCollector,
|
||||||
keyguardViewController)
|
keyguardViewController
|
||||||
}
|
)
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testFocusWhenBouncerIsShown() {
|
|
||||||
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(true)
|
|
||||||
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
|
||||||
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
|
||||||
keyguardPasswordView.post {
|
|
||||||
verify(keyguardPasswordView).requestFocus()
|
|
||||||
verify(keyguardPasswordView).showKeyboard()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDoNotFocusWhenBouncerIsHidden() {
|
fun testFocusWhenBouncerIsShown() {
|
||||||
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(false)
|
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(true)
|
||||||
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
||||||
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||||
verify(keyguardPasswordView, never()).requestFocus()
|
keyguardPasswordView.post {
|
||||||
}
|
verify(keyguardPasswordView).requestFocus()
|
||||||
|
verify(keyguardPasswordView).showKeyboard()
|
||||||
@Test
|
}
|
||||||
fun testHideKeyboardWhenOnPause() {
|
|
||||||
keyguardPasswordViewController.onPause()
|
|
||||||
keyguardPasswordView.post {
|
|
||||||
verify(keyguardPasswordView).clearFocus()
|
|
||||||
verify(keyguardPasswordView).hideKeyboard()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun startAppearAnimation() {
|
fun testDoNotFocusWhenBouncerIsHidden() {
|
||||||
keyguardPasswordViewController.startAppearAnimation()
|
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(false)
|
||||||
verify(mKeyguardMessageAreaController)
|
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
||||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_password), false)
|
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||||
}
|
verify(keyguardPasswordView, never()).requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun startAppearAnimation_withExistingMessage() {
|
fun testHideKeyboardWhenOnPause() {
|
||||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
keyguardPasswordViewController.onPause()
|
||||||
keyguardPasswordViewController.startAppearAnimation()
|
keyguardPasswordView.post {
|
||||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
verify(keyguardPasswordView).clearFocus()
|
||||||
}
|
verify(keyguardPasswordView).hideKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun startAppearAnimation() {
|
||||||
|
keyguardPasswordViewController.startAppearAnimation()
|
||||||
|
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_password)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun startAppearAnimation_withExistingMessage() {
|
||||||
|
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||||
|
keyguardPasswordViewController.startAppearAnimation()
|
||||||
|
verify(
|
||||||
|
mKeyguardMessageAreaController,
|
||||||
|
never()
|
||||||
|
).setMessage(R.string.keyguard_enter_your_password)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,93 +30,97 @@ 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 private lateinit var mKeyguardPatternView: KeyguardPatternView
|
@Mock
|
||||||
|
private lateinit var mKeyguardPatternView: KeyguardPatternView
|
||||||
|
|
||||||
@Mock private lateinit var mKeyguardUpdateMonitor: KeyguardUpdateMonitor
|
@Mock
|
||||||
|
private lateinit var mKeyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||||
|
|
||||||
@Mock private lateinit var mSecurityMode: KeyguardSecurityModel.SecurityMode
|
@Mock
|
||||||
|
private lateinit var mSecurityMode: KeyguardSecurityModel.SecurityMode
|
||||||
|
|
||||||
@Mock private lateinit var mLockPatternUtils: LockPatternUtils
|
@Mock
|
||||||
|
private lateinit var mLockPatternUtils: LockPatternUtils
|
||||||
|
|
||||||
@Mock private lateinit var mKeyguardSecurityCallback: KeyguardSecurityCallback
|
@Mock
|
||||||
|
private lateinit var mKeyguardSecurityCallback: KeyguardSecurityCallback
|
||||||
|
|
||||||
@Mock private lateinit var mLatencyTracker: LatencyTracker
|
@Mock
|
||||||
private var mFalsingCollector: FalsingCollector = FalsingCollectorFake()
|
private lateinit var mLatencyTracker: LatencyTracker
|
||||||
|
private var mFalsingCollector: FalsingCollector = FalsingCollectorFake()
|
||||||
|
|
||||||
@Mock private lateinit var mEmergencyButtonController: EmergencyButtonController
|
@Mock
|
||||||
|
private lateinit var mEmergencyButtonController: EmergencyButtonController
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mKeyguardMessageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
private lateinit
|
||||||
|
var mKeyguardMessageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
||||||
|
|
||||||
@Mock private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
|
@Mock
|
||||||
|
private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mKeyguardMessageAreaController:
|
private lateinit var mKeyguardMessageAreaController:
|
||||||
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
||||||
|
|
||||||
@Mock private lateinit var mLockPatternView: LockPatternView
|
@Mock
|
||||||
|
private lateinit var mLockPatternView: LockPatternView
|
||||||
|
|
||||||
@Mock private lateinit var mPostureController: DevicePostureController
|
@Mock
|
||||||
|
private lateinit var mPostureController: DevicePostureController
|
||||||
|
|
||||||
private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController
|
private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
`when`(mKeyguardPatternView.isAttachedToWindow).thenReturn(true)
|
`when`(mKeyguardPatternView.isAttachedToWindow).thenReturn(true)
|
||||||
`when`(
|
`when`(mKeyguardPatternView
|
||||||
mKeyguardPatternView.requireViewById<BouncerKeyguardMessageArea>(
|
.requireViewById<BouncerKeyguardMessageArea>(R.id.bouncer_message_area))
|
||||||
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,
|
mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
|
||||||
mSecurityMode,
|
mLatencyTracker, mFalsingCollector, mEmergencyButtonController,
|
||||||
mLockPatternUtils,
|
mKeyguardMessageAreaControllerFactory, mPostureController
|
||||||
mKeyguardSecurityCallback,
|
)
|
||||||
mLatencyTracker,
|
}
|
||||||
mFalsingCollector,
|
|
||||||
mEmergencyButtonController,
|
|
||||||
mKeyguardMessageAreaControllerFactory,
|
|
||||||
mPostureController)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onPause_resetsText() {
|
fun onPause_resetsText() {
|
||||||
mKeyguardPatternViewController.init()
|
mKeyguardPatternViewController.init()
|
||||||
mKeyguardPatternViewController.onPause()
|
mKeyguardPatternViewController.onPause()
|
||||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun startAppearAnimation() {
|
|
||||||
mKeyguardPatternViewController.startAppearAnimation()
|
|
||||||
verify(mKeyguardMessageAreaController)
|
|
||||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pattern), false)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun startAppearAnimation_withExistingMessage() {
|
fun startAppearAnimation() {
|
||||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
mKeyguardPatternViewController.startAppearAnimation()
|
||||||
mKeyguardPatternViewController.startAppearAnimation()
|
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
||||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
fun startAppearAnimation_withExistingMessage() {
|
||||||
|
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||||
|
mKeyguardPatternViewController.startAppearAnimation()
|
||||||
|
verify(
|
||||||
|
mKeyguardMessageAreaController,
|
||||||
|
never()
|
||||||
|
).setMessage(R.string.keyguard_enter_your_password)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,10 @@ 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
|
||||||
@@ -82,7 +79,6 @@ 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,
|
||||||
@@ -102,14 +98,14 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun startAppearAnimation() {
|
fun startAppearAnimation() {
|
||||||
pinViewController.startAppearAnimation()
|
pinViewController.startAppearAnimation()
|
||||||
verify(keyguardMessageAreaController)
|
verify(keyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pin)
|
||||||
.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()).setMessage(anyString(), anyBoolean())
|
verify(keyguardMessageAreaController, Mockito.never())
|
||||||
|
.setMessage(R.string.keyguard_enter_your_password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user