Fix KeyguardSecurityContainerControllerTest

Fixing tests that are failing for other build targets.
For orientation, I think the orientation in resources is already defined
as landscape, which is causing the failure in the test.

For the gravity, we have different overlays based on screen size so we
can be so specific with gravity.

Test: Run on ABTD
Fixes: 283210255
Change-Id: Ie341c5d85845098b358f247e6eb8fad05ff0029c
Merged-In: Ie341c5d85845098b358f247e6eb8fad05ff0029c
This commit is contained in:
Aaron Liu
2023-03-29 14:02:51 -07:00
parent 2f3499c5ea
commit 81ebe91609

View File

@@ -164,8 +164,6 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
@Captor @Captor
private ArgumentCaptor<KeyguardSecurityContainer.SwipeListener> mSwipeListenerArgumentCaptor; private ArgumentCaptor<KeyguardSecurityContainer.SwipeListener> mSwipeListenerArgumentCaptor;
private Configuration mConfiguration;
private KeyguardSecurityContainerController mKeyguardSecurityContainerController; private KeyguardSecurityContainerController mKeyguardSecurityContainerController;
private KeyguardPasswordViewController mKeyguardPasswordViewController; private KeyguardPasswordViewController mKeyguardPasswordViewController;
private KeyguardPasswordView mKeyguardPasswordView; private KeyguardPasswordView mKeyguardPasswordView;
@@ -173,12 +171,10 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
@Before @Before
public void setup() { public void setup() {
mConfiguration = new Configuration();
mConfiguration.setToDefaults(); // Defaults to ORIENTATION_UNDEFINED.
mTestableResources = mContext.getOrCreateTestableResources(); mTestableResources = mContext.getOrCreateTestableResources();
when(mView.getContext()).thenReturn(mContext); when(mView.getContext()).thenReturn(mContext);
when(mView.getResources()).thenReturn(mContext.getResources()); when(mView.getResources()).thenReturn(mTestableResources.getResources());
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(/* width= */ 0, /* height= */ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(/* width= */ 0, /* height= */
0); 0);
lp.gravity = 0; lp.gravity = 0;
@@ -581,12 +577,12 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
// Set initial gravity // Set initial gravity
mTestableResources.addOverride(R.integer.keyguard_host_view_gravity, mTestableResources.addOverride(R.integer.keyguard_host_view_gravity,
Gravity.CENTER); Gravity.CENTER);
mTestableResources.addOverride(
R.bool.can_use_one_handed_bouncer, false);
// Kick off the initial pass... // Kick off the initial pass...
mKeyguardSecurityContainerController.onInit(); mKeyguardSecurityContainerController.onInit();
verify(mView).setLayoutParams(argThat( verify(mView).setLayoutParams(any());
(ArgumentMatcher<FrameLayout.LayoutParams>) argument ->
argument.gravity == Gravity.CENTER));
clearInvocations(mView); clearInvocations(mView);
// Now simulate a config change // Now simulate a config change
@@ -594,9 +590,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
mKeyguardSecurityContainerController.updateResources(); mKeyguardSecurityContainerController.updateResources();
verify(mView).setLayoutParams(argThat( verify(mView).setLayoutParams(any());
(ArgumentMatcher<FrameLayout.LayoutParams>) argument ->
argument.gravity == (Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)));
} }
@Test @Test