diff options
| author | 2024-02-16 10:37:01 +0000 | |
|---|---|---|
| committer | 2024-02-16 10:37:01 +0000 | |
| commit | 1fa524bcc29a496f7a8827cb2230287d9fd98c0b (patch) | |
| tree | b52dcc34a19d35686e5495ee02233662d8503e06 | |
| parent | ff603004bab5993f74c118c2c0a47909c873ce2b (diff) | |
| parent | 3551f68e8b5980dbd564b2e0c3889a6384395282 (diff) | |
Merge "Fixed Failing tests for pinInputFieldStyledFocusState Flag advance" into main
5 files changed, 29 insertions, 10 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt index c6327ffa25f1..c3857889a134 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt @@ -17,6 +17,7 @@ package com.android.keyguard import android.testing.TestableLooper +import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.ImageView @@ -51,10 +52,14 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) -@TestableLooper.RunWithLooper +// collectFlow in KeyguardPinBasedInputViewController.onViewAttached calls JavaAdapter.CollectFlow, +// which calls View.onRepeatWhenAttached, which requires being run on main thread. +@TestableLooper.RunWithLooper(setAsMainLooper = true) class KeyguardPasswordViewControllerTest : SysuiTestCase() { @Mock private lateinit var keyguardPasswordView: KeyguardPasswordView @Mock private lateinit var passwordEntry: EditText + private var passwordEntryLayoutParams = + ViewGroup.LayoutParams(/* width = */ 0, /* height = */ 0) @Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor @Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode @Mock lateinit var lockPatternUtils: LockPatternUtils @@ -92,7 +97,7 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() { whenever(keyguardPasswordView.findViewById<ImageView>(R.id.switch_ime_button)) .thenReturn(mock(ImageView::class.java)) `when`(keyguardPasswordView.resources).thenReturn(context.resources) - + whenever(passwordEntry.layoutParams).thenReturn(passwordEntryLayoutParams) val keyguardKeyboardInteractor = KeyguardKeyboardInteractor(FakeKeyboardRepository()) val fakeFeatureFlags = FakeFeatureFlags() fakeFeatureFlags.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, false) diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java index f86342c0c20e..0054d137bd2c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java @@ -24,6 +24,7 @@ import static org.mockito.Mockito.when; import android.testing.TestableLooper.RunWithLooper; import android.view.View; +import android.view.ViewGroup; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; @@ -48,13 +49,17 @@ import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidJUnit4.class) -@RunWithLooper +// collectFlow in KeyguardPinBasedInputViewController.onViewAttached calls JavaAdapter.CollectFlow, +// which calls View.onRepeatWhenAttached, which requires being run on main thread. +@RunWithLooper(setAsMainLooper = true) public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase { @Mock private KeyguardPinBasedInputView mPinBasedInputView; @Mock private PasswordTextView mPasswordEntry; + private final ViewGroup.LayoutParams mPasswordEntryLayoutParams = + new ViewGroup.LayoutParams(/* width= */ 0, /* height= */ 0); @Mock private BouncerKeyguardMessageArea mKeyguardMessageArea; @Mock @@ -103,6 +108,7 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase { .thenReturn(mOkButton); when(mPinBasedInputView.getResources()).thenReturn(getContext().getResources()); + when(mPasswordEntry.getLayoutParams()).thenReturn(mPasswordEntryLayoutParams); KeyguardKeyboardInteractor keyguardKeyboardInteractor = new KeyguardKeyboardInteractor(new FakeKeyboardRepository()); FakeFeatureFlags featureFlags = new FakeFeatureFlags(); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt index d048cbe02fa8..36d4d122ab11 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt @@ -18,6 +18,7 @@ package com.android.keyguard import android.testing.TestableLooper import android.view.View +import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -59,7 +60,9 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) -@TestableLooper.RunWithLooper +// collectFlow in KeyguardPinBasedInputViewController.onViewAttached calls JavaAdapter.CollectFlow, +// which calls View.onRepeatWhenAttached, which requires being run on main thread. +@TestableLooper.RunWithLooper(setAsMainLooper = true) class KeyguardPinViewControllerTest : SysuiTestCase() { private lateinit var objectKeyguardPINView: KeyguardPINView @@ -90,6 +93,8 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { @Mock private val mEmergencyButtonController: EmergencyButtonController? = null private val falsingCollector: FalsingCollector = FalsingCollectorFake() private val keyguardKeyboardInteractor = KeyguardKeyboardInteractor(FakeKeyboardRepository()) + private val passwordTextViewLayoutParams = + ViewGroup.LayoutParams(/* width= */ 0, /* height= */ 0) @Mock lateinit var postureController: DevicePostureController @Mock lateinit var mSelectedUserInteractor: SelectedUserInteractor @@ -104,11 +109,9 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { @Before fun setup() { MockitoAnnotations.initMocks(this) - Mockito.`when`(mockKeyguardPinView.requireViewById<View>(R.id.bouncer_message_area)) + `when`(mockKeyguardPinView.requireViewById<View>(R.id.bouncer_message_area)) .thenReturn(keyguardMessageArea) - Mockito.`when`( - keyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea::class.java)) - ) + `when`(keyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea::class.java))) .thenReturn(keyguardMessageAreaController) `when`(mockKeyguardPinView.passwordTextViewId).thenReturn(R.id.pinEntry) `when`(mockKeyguardPinView.findViewById<PasswordTextView>(R.id.pinEntry)) @@ -121,6 +124,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() { `when`(mockKeyguardPinView.buttons).thenReturn(arrayOf()) `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6) `when`(featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(false) + `when`(passwordTextView.layoutParams).thenReturn(passwordTextViewLayoutParams) objectKeyguardPINView = View.inflate(mContext, R.layout.keyguard_pin_view, null) diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt index 4a2554eb5201..9b5364ed6e6e 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt @@ -49,7 +49,9 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) -@TestableLooper.RunWithLooper +// collectFlow in KeyguardPinBasedInputViewController.onViewAttached calls JavaAdapter.CollectFlow, +// which calls View.onRepeatWhenAttached, which requires being run on main thread. +@TestableLooper.RunWithLooper(setAsMainLooper = true) class KeyguardSimPinViewControllerTest : SysuiTestCase() { private lateinit var simPinView: KeyguardSimPinView private lateinit var underTest: KeyguardSimPinViewController diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt index 4f461845d905..e71490c73aa1 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt @@ -43,7 +43,9 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) -@TestableLooper.RunWithLooper +// collectFlow in KeyguardPinBasedInputViewController.onViewAttached calls JavaAdapter.CollectFlow, +// which calls View.onRepeatWhenAttached, which requires being run on main thread. +@TestableLooper.RunWithLooper(setAsMainLooper = true) class KeyguardSimPukViewControllerTest : SysuiTestCase() { private lateinit var simPukView: KeyguardSimPukView private lateinit var underTest: KeyguardSimPukViewController |