Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fa524bc authored by Joshua Mokut's avatar Joshua Mokut Committed by Android (Google) Code Review
Browse files

Merge "Fixed Failing tests for pinInputFieldStyledFocusState Flag advance" into main

parents ff603004 3551f68e
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.keyguard
package com.android.keyguard


import android.testing.TestableLooper
import android.testing.TestableLooper
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.EditText
import android.widget.ImageView
import android.widget.ImageView
@@ -51,10 +52,14 @@ import org.mockito.MockitoAnnotations


@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@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() {
class KeyguardPasswordViewControllerTest : SysuiTestCase() {
    @Mock private lateinit var keyguardPasswordView: KeyguardPasswordView
    @Mock private lateinit var keyguardPasswordView: KeyguardPasswordView
    @Mock private lateinit var passwordEntry: EditText
    @Mock private lateinit var passwordEntry: EditText
    private var passwordEntryLayoutParams =
        ViewGroup.LayoutParams(/* width = */ 0, /* height = */ 0)
    @Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
    @Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
    @Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode
    @Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode
    @Mock lateinit var lockPatternUtils: LockPatternUtils
    @Mock lateinit var lockPatternUtils: LockPatternUtils
@@ -92,7 +97,7 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
        whenever(keyguardPasswordView.findViewById<ImageView>(R.id.switch_ime_button))
        whenever(keyguardPasswordView.findViewById<ImageView>(R.id.switch_ime_button))
            .thenReturn(mock(ImageView::class.java))
            .thenReturn(mock(ImageView::class.java))
        `when`(keyguardPasswordView.resources).thenReturn(context.resources)
        `when`(keyguardPasswordView.resources).thenReturn(context.resources)

        whenever(passwordEntry.layoutParams).thenReturn(passwordEntryLayoutParams)
        val keyguardKeyboardInteractor = KeyguardKeyboardInteractor(FakeKeyboardRepository())
        val keyguardKeyboardInteractor = KeyguardKeyboardInteractor(FakeKeyboardRepository())
        val fakeFeatureFlags = FakeFeatureFlags()
        val fakeFeatureFlags = FakeFeatureFlags()
        fakeFeatureFlags.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, false)
        fakeFeatureFlags.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, false)
+7 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;


import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;


import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
@@ -48,13 +49,17 @@ import org.mockito.MockitoAnnotations;


@SmallTest
@SmallTest
@RunWith(AndroidJUnit4.class)
@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 {
public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {


    @Mock
    @Mock
    private KeyguardPinBasedInputView mPinBasedInputView;
    private KeyguardPinBasedInputView mPinBasedInputView;
    @Mock
    @Mock
    private PasswordTextView mPasswordEntry;
    private PasswordTextView mPasswordEntry;
    private final ViewGroup.LayoutParams mPasswordEntryLayoutParams =
            new ViewGroup.LayoutParams(/* width= */ 0, /* height= */ 0);
    @Mock
    @Mock
    private BouncerKeyguardMessageArea mKeyguardMessageArea;
    private BouncerKeyguardMessageArea mKeyguardMessageArea;
    @Mock
    @Mock
@@ -103,6 +108,7 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
                .thenReturn(mOkButton);
                .thenReturn(mOkButton);


        when(mPinBasedInputView.getResources()).thenReturn(getContext().getResources());
        when(mPinBasedInputView.getResources()).thenReturn(getContext().getResources());
        when(mPasswordEntry.getLayoutParams()).thenReturn(mPasswordEntryLayoutParams);
        KeyguardKeyboardInteractor keyguardKeyboardInteractor =
        KeyguardKeyboardInteractor keyguardKeyboardInteractor =
                new KeyguardKeyboardInteractor(new FakeKeyboardRepository());
                new KeyguardKeyboardInteractor(new FakeKeyboardRepository());
        FakeFeatureFlags featureFlags = new FakeFeatureFlags();
        FakeFeatureFlags featureFlags = new FakeFeatureFlags();
+9 −5
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.keyguard


import android.testing.TestableLooper
import android.testing.TestableLooper
import android.view.View
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -59,7 +60,9 @@ import org.mockito.MockitoAnnotations


@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@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() {
class KeyguardPinViewControllerTest : SysuiTestCase() {


    private lateinit var objectKeyguardPINView: KeyguardPINView
    private lateinit var objectKeyguardPINView: KeyguardPINView
@@ -90,6 +93,8 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
    @Mock private val mEmergencyButtonController: EmergencyButtonController? = null
    @Mock private val mEmergencyButtonController: EmergencyButtonController? = null
    private val falsingCollector: FalsingCollector = FalsingCollectorFake()
    private val falsingCollector: FalsingCollector = FalsingCollectorFake()
    private val keyguardKeyboardInteractor = KeyguardKeyboardInteractor(FakeKeyboardRepository())
    private val keyguardKeyboardInteractor = KeyguardKeyboardInteractor(FakeKeyboardRepository())
    private val passwordTextViewLayoutParams =
        ViewGroup.LayoutParams(/* width= */ 0, /* height= */ 0)
    @Mock lateinit var postureController: DevicePostureController
    @Mock lateinit var postureController: DevicePostureController
    @Mock lateinit var mSelectedUserInteractor: SelectedUserInteractor
    @Mock lateinit var mSelectedUserInteractor: SelectedUserInteractor


@@ -104,11 +109,9 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
    @Before
    @Before
    fun setup() {
    fun setup() {
        MockitoAnnotations.initMocks(this)
        MockitoAnnotations.initMocks(this)
        Mockito.`when`(mockKeyguardPinView.requireViewById<View>(R.id.bouncer_message_area))
        `when`(mockKeyguardPinView.requireViewById<View>(R.id.bouncer_message_area))
            .thenReturn(keyguardMessageArea)
            .thenReturn(keyguardMessageArea)
        Mockito.`when`(
        `when`(keyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea::class.java)))
                keyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea::class.java))
            )
            .thenReturn(keyguardMessageAreaController)
            .thenReturn(keyguardMessageAreaController)
        `when`(mockKeyguardPinView.passwordTextViewId).thenReturn(R.id.pinEntry)
        `when`(mockKeyguardPinView.passwordTextViewId).thenReturn(R.id.pinEntry)
        `when`(mockKeyguardPinView.findViewById<PasswordTextView>(R.id.pinEntry))
        `when`(mockKeyguardPinView.findViewById<PasswordTextView>(R.id.pinEntry))
@@ -121,6 +124,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
        `when`(mockKeyguardPinView.buttons).thenReturn(arrayOf())
        `when`(mockKeyguardPinView.buttons).thenReturn(arrayOf())
        `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6)
        `when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6)
        `when`(featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(false)
        `when`(featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(false)
        `when`(passwordTextView.layoutParams).thenReturn(passwordTextViewLayoutParams)


        objectKeyguardPINView =
        objectKeyguardPINView =
            View.inflate(mContext, R.layout.keyguard_pin_view, null)
            View.inflate(mContext, R.layout.keyguard_pin_view, null)
+3 −1
Original line number Original line Diff line number Diff line
@@ -49,7 +49,9 @@ import org.mockito.MockitoAnnotations


@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@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() {
class KeyguardSimPinViewControllerTest : SysuiTestCase() {
    private lateinit var simPinView: KeyguardSimPinView
    private lateinit var simPinView: KeyguardSimPinView
    private lateinit var underTest: KeyguardSimPinViewController
    private lateinit var underTest: KeyguardSimPinViewController
+3 −1
Original line number Original line Diff line number Diff line
@@ -43,7 +43,9 @@ import org.mockito.MockitoAnnotations


@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@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() {
class KeyguardSimPukViewControllerTest : SysuiTestCase() {
    private lateinit var simPukView: KeyguardSimPukView
    private lateinit var simPukView: KeyguardSimPukView
    private lateinit var underTest: KeyguardSimPukViewController
    private lateinit var underTest: KeyguardSimPukViewController