diff options
| author | 2021-06-16 13:40:55 -0700 | |
|---|---|---|
| committer | 2021-07-26 23:32:30 +0000 | |
| commit | f69d25f7f25d1e879c91c6d7f90db92603e55eff (patch) | |
| tree | 2d9f84a4a52232d263accc704236b819aea514de | |
| parent | 7c060b29511367f80b20edaf3b569c10aeafa2c9 (diff) | |
Fix crash when running UserSwitcherControllerTest
Previously, test would fail on wembley with the following errors:
- No service published for: fingerprint
- No service published for: face
- java.lang.AssertionError: expected:<1> but was:<0>
Fixes: 191280089
Bug: 194441567
Test: atest SystemUITests:com.android.systemui.statusbar.policy.UserSwitcherControllerTest
Change-Id: I34539a5e9678b308b4d3a03e4593fb9385e7831f
Merged-In: I34539a5e9678b308b4d3a03e4593fb9385e7831f
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt index c345f71fa851..ace2c71d9c63 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt @@ -17,10 +17,13 @@ package com.android.systemui.statusbar.policy import android.app.IActivityTaskManager +import android.content.Context import android.content.DialogInterface import android.content.Intent import android.content.pm.UserInfo import android.graphics.Bitmap +import android.hardware.face.FaceManager +import android.hardware.fingerprint.FingerprintManager import android.os.Handler import android.os.UserHandle import android.os.UserManager @@ -51,6 +54,7 @@ import org.mockito.ArgumentMatchers.eq import org.mockito.Mock import org.mockito.Mockito.any import org.mockito.Mockito.anyString +import org.mockito.Mockito.mock import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @@ -93,6 +97,10 @@ class UserSwitcherControllerTest : SysuiTestCase() { context.orCreateTestableResources.addOverride( com.android.internal.R.bool.config_guestUserAutoCreated, false) + context.addMockSystemService(Context.FACE_SERVICE, mock(FaceManager::class.java)) + context.addMockSystemService(Context.FINGERPRINT_SERVICE, + mock(FingerprintManager::class.java)) + `when`(userManager.canAddMoreUsers()).thenReturn(true) userSwitcherController = UserSwitcherController(context, @@ -130,6 +138,7 @@ class UserSwitcherControllerTest : SysuiTestCase() { `when`(userManager.createGuest(any(), anyString())).thenReturn(guestInfo) userSwitcherController.onUserListItemClicked(emptyGuestUserRecord) + testableLooper.processAllMessages() assertEquals(1, uiEventLogger.numLogs()) assertEquals(QSUserSwitcherEvent.QS_USER_GUEST_ADD.id, uiEventLogger.eventId(0)) } |