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

Commit c8587890 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

Fix NotificationSettingsControllerTest

Test is dependent on ActivityManager.getCurrentUser. However, there is a mock object that returns userId which is not inline with getCurrentUser.
ActivitiyManager.getCurrentUser has been started to return a value different from 0, which is a default value for int and so mock userId. This CL fixes this issue by improving the mock

Fix: 411119789
Test: NotificationSettingsControllerTest
Flag: EXEMPT trivial test set up change
Change-Id: I291da83fdc14e20fae65f257b44e06eb000b8d43
parent 7e8e08a4
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -81,13 +81,15 @@ class NotificationSettingsControllerTest : SysuiTestCase() {
        mainHandler = Handler(testableLooper.looper)
        backgroundHandler = Handler(testableLooper.looper)
        allowTestableLooperAsMainThread()
        whenever(userTracker.userId).thenReturn(ActivityManager.getCurrentUser())

        controller =
            NotificationSettingsController(
                userTracker,
                mainHandler,
                backgroundHandler,
                secureSettings,
                dumpManager
                dumpManager,
            )
    }

@@ -145,7 +147,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() {
                eq(settingUri1),
                eq(false),
                any(),
                eq(ActivityManager.getCurrentUser())
                eq(ActivityManager.getCurrentUser()),
            )

        controller.addCallback(settingUri1, Mockito.mock(Listener::class.java))
@@ -163,7 +165,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() {
                eq(settingUri1),
                eq(false),
                any(),
                eq(ActivityManager.getCurrentUser())
                eq(ActivityManager.getCurrentUser()),
            )
        clearInvocations(secureSettings)

@@ -175,7 +177,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() {
                eq(settingUri2),
                eq(false),
                any(),
                eq(ActivityManager.getCurrentUser())
                eq(ActivityManager.getCurrentUser()),
            )
    }

@@ -191,7 +193,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() {
                eq(settingUri1),
                eq(false),
                any(),
                eq(ActivityManager.getCurrentUser())
                eq(ActivityManager.getCurrentUser()),
            )
        clearInvocations(secureSettings)

@@ -258,7 +260,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() {
                any(Uri::class.java),
                anyBoolean(),
                capture(settingsObserverCaptor),
                anyInt()
                anyInt(),
            )
        verify(listenerSetting1a)
            .onSettingChanged(settingUri1, ActivityManager.getCurrentUser(), "9")