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

Commit f69d25f7 authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

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
parent 7c060b29
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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))
    }