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

Commit 6ee96f4e authored by Jiaming Cheng's avatar Jiaming Cheng
Browse files

[Flexiglass] Fix NotificationLockscreenUserManagerTest

This cl updates the test's setUp() method to correctly mock the
DeviceUnlockedInteractor dependencies (mDeviceUnlockedInteractorLazy and
mDeviceUnlockStatusStateFlow) when SceneContainerFlag is enabled.
Specifically, it ensures that:
- mDeviceUnlockedInteractorLazy.get() returns the intended
mDeviceUnlockedInteractor mock.
- mDeviceUnlockStatusStateFlow.getValue() returns a default
DeviceUnlockStatus object.

Bug: 416716455
Flag: com.android.systemui.scene_container
Test: com.android.systemui.statusbar.NotificationLockscreenUserManagerTest
     Locally run this test and verity all the tests are passed with the
     `@EnableSceneContainer` anotation.
Change-Id: I8fccac6f60e701b5cff12d9f1c2db70de3ef7bf9
parent 0c53eace
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -289,12 +289,19 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
                .thenReturn(mock(StateFlow.class));
        when(mWifiRepositoryLazy.get()).thenReturn(mWifiRepository);
        when(mWifiRepository.getWifiNetwork()).thenReturn(mock(StateFlow.class));

        // Add the following for SceneContainer enabled
        when(mDeviceUnlockedInteractorLazy.get()).thenReturn(mDeviceUnlockedInteractor);
        when(mDeviceUnlockedInteractor.getDeviceUnlockStatus()).thenReturn(
                mDeviceUnlockStatusStateFlow);
        when(mDeviceUnlockStatusStateFlow.getValue()).thenReturn(new DeviceUnlockStatus(
                /* isUnlocked = */ true,
                /* deviceUnlockSource = */ null
        ));

        mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext);
        mLockscreenUserManager.setUpWithPresenter(mPresenter);

        when(mDeviceUnlockedInteractor.getDeviceUnlockStatus())
                .thenReturn(mDeviceUnlockStatusStateFlow);

        mBackgroundExecutor.runAllReady();
    }