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

Commit 2c2767ec authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add logging for communal scene changes" into main

parents d208ee5f 595846cc
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -1410,7 +1410,10 @@ fun AccessibilityContainer(viewModel: BaseCommunalViewModel, content: @Composabl
                                    R.string.accessibility_action_label_close_communal_hub
                                    R.string.accessibility_action_label_close_communal_hub
                                )
                                )
                            ) {
                            ) {
                                viewModel.changeScene(CommunalScenes.Blank)
                                viewModel.changeScene(
                                    CommunalScenes.Blank,
                                    "closed by accessibility"
                                )
                                true
                                true
                            },
                            },
                            CustomAccessibilityAction(
                            CustomAccessibilityAction(
+18 −18
Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)


                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                communalSceneInteractor.setEditModeState(EditModeState.STARTING)
                communalSceneInteractor.setEditModeState(EditModeState.STARTING)
@@ -133,7 +133,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)


                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                communalSceneInteractor.setIsLaunchingWidget(true)
                communalSceneInteractor.setIsLaunchingWidget(true)
@@ -154,7 +154,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)


                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                communalSceneInteractor.setIsLaunchingWidget(false)
                communalSceneInteractor.setIsLaunchingWidget(false)
@@ -174,7 +174,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                communalInteractor.setEditModeOpen(true)
                communalInteractor.setEditModeOpen(true)
@@ -213,7 +213,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(false)
                whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(false)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                updateDocked(true)
                updateDocked(true)
@@ -233,7 +233,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(true)
                whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(true)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                updateDocked(true)
                updateDocked(true)
@@ -270,7 +270,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                fakeKeyguardTransitionRepository.sendTransitionSteps(
                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -292,7 +292,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)


                fakeKeyguardTransitionRepository.sendTransitionSteps(
                fakeKeyguardTransitionRepository.sendTransitionSteps(
@@ -320,7 +320,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun dockingOnLockscreen_forcesCommunal() =
    fun dockingOnLockscreen_forcesCommunal() =
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                communalSceneInteractor.changeScene(CommunalScenes.Blank)
                communalSceneInteractor.changeScene(CommunalScenes.Blank, "test")
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)


                // device is docked while on the lockscreen
                // device is docked while on the lockscreen
@@ -342,7 +342,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
    fun dockingOnLockscreen_doesNotForceCommunalIfDreamStarts() =
    fun dockingOnLockscreen_doesNotForceCommunalIfDreamStarts() =
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                communalSceneInteractor.changeScene(CommunalScenes.Blank)
                communalSceneInteractor.changeScene(CommunalScenes.Blank, "test")
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)


                // device is docked while on the lockscreen
                // device is docked while on the lockscreen
@@ -374,7 +374,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                // Device is dreaming and on communal.
                // Device is dreaming and on communal.
                updateDreaming(true)
                updateDreaming(true)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
@@ -391,7 +391,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                // Device is not dreaming and on communal.
                // Device is not dreaming and on communal.
                updateDreaming(false)
                updateDreaming(false)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                // Scene stays as Communal
                // Scene stays as Communal
                advanceTimeBy(SCREEN_TIMEOUT.milliseconds)
                advanceTimeBy(SCREEN_TIMEOUT.milliseconds)
@@ -406,7 +406,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                // Device is dreaming and on communal.
                // Device is dreaming and on communal.
                updateDreaming(true)
                updateDreaming(true)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
@@ -429,7 +429,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                // Device is on communal, but not dreaming.
                // Device is on communal, but not dreaming.
                updateDreaming(false)
                updateDreaming(false)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
@@ -450,7 +450,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                // Device is on communal.
                // Device is on communal.
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                // Device stays on the hub after the timeout since we're not dreaming.
                // Device stays on the hub after the timeout since we're not dreaming.
                advanceTimeBy(SCREEN_TIMEOUT.milliseconds * 2)
                advanceTimeBy(SCREEN_TIMEOUT.milliseconds * 2)
@@ -471,7 +471,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            testScope.runTest {
            testScope.runTest {
                // Device is dreaming and on communal.
                // Device is dreaming and on communal.
                updateDreaming(true)
                updateDreaming(true)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
@@ -500,7 +500,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {


                // Device is dreaming and on communal.
                // Device is dreaming and on communal.
                updateDreaming(true)
                updateDreaming(true)
                communalSceneInteractor.changeScene(CommunalScenes.Communal)
                communalSceneInteractor.changeScene(CommunalScenes.Communal, "test")


                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
                assertThat(scene).isEqualTo(CommunalScenes.Communal)
@@ -520,7 +520,7 @@ class CommunalSceneStartableTest : SysuiTestCase() {
        with(kosmos) {
        with(kosmos) {
            testScope.runTest {
            testScope.runTest {
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                val scene by collectLastValue(communalSceneInteractor.currentScene)
                communalSceneInteractor.changeScene(CommunalScenes.Blank)
                communalSceneInteractor.changeScene(CommunalScenes.Blank, "test")
                assertThat(scene).isEqualTo(CommunalScenes.Blank)
                assertThat(scene).isEqualTo(CommunalScenes.Blank)


                fakeKeyguardTransitionRepository.sendTransitionSteps(
                fakeKeyguardTransitionRepository.sendTransitionSteps(
+5 −5
Original line number Original line Diff line number Diff line
@@ -482,7 +482,7 @@ class CommunalInteractorTest : SysuiTestCase() {
        testScope.runTest {
        testScope.runTest {
            val targetScene = CommunalScenes.Communal
            val targetScene = CommunalScenes.Communal


            underTest.changeScene(targetScene)
            underTest.changeScene(targetScene, "test")


            val desiredScene = collectLastValue(communalRepository.currentScene)
            val desiredScene = collectLastValue(communalRepository.currentScene)
            runCurrent()
            runCurrent()
@@ -635,7 +635,7 @@ class CommunalInteractorTest : SysuiTestCase() {
            runCurrent()
            runCurrent()
            assertThat(isCommunalShowing()).isEqualTo(false)
            assertThat(isCommunalShowing()).isEqualTo(false)


            underTest.changeScene(CommunalScenes.Communal)
            underTest.changeScene(CommunalScenes.Communal, "test")


            isCommunalShowing = collectLastValue(underTest.isCommunalShowing)
            isCommunalShowing = collectLastValue(underTest.isCommunalShowing)
            runCurrent()
            runCurrent()
@@ -659,12 +659,12 @@ class CommunalInteractorTest : SysuiTestCase() {
            assertThat(isCommunalShowing).isFalse()
            assertThat(isCommunalShowing).isFalse()


            // Verify scene changes (without the flag) to communal sets the value to true
            // Verify scene changes (without the flag) to communal sets the value to true
            underTest.changeScene(CommunalScenes.Communal)
            underTest.changeScene(CommunalScenes.Communal, "test")
            runCurrent()
            runCurrent()
            assertThat(isCommunalShowing).isTrue()
            assertThat(isCommunalShowing).isTrue()


            // Verify scene changes (without the flag) to blank sets the value back to false
            // Verify scene changes (without the flag) to blank sets the value back to false
            underTest.changeScene(CommunalScenes.Blank)
            underTest.changeScene(CommunalScenes.Blank, "test")
            runCurrent()
            runCurrent()
            assertThat(isCommunalShowing).isFalse()
            assertThat(isCommunalShowing).isFalse()
        }
        }
@@ -679,7 +679,7 @@ class CommunalInteractorTest : SysuiTestCase() {
            assertThat(isCommunalShowing).isFalse()
            assertThat(isCommunalShowing).isFalse()


            // Verify scene changes without the flag doesn't have any impact
            // Verify scene changes without the flag doesn't have any impact
            underTest.changeScene(CommunalScenes.Communal)
            underTest.changeScene(CommunalScenes.Communal, "test")
            runCurrent()
            runCurrent()
            assertThat(isCommunalShowing).isFalse()
            assertThat(isCommunalShowing).isFalse()


+5 −4
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ class CommunalSceneInteractorTest : SysuiTestCase() {
            val currentScene by collectLastValue(underTest.currentScene)
            val currentScene by collectLastValue(underTest.currentScene)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)


            underTest.changeScene(CommunalScenes.Communal)
            underTest.changeScene(CommunalScenes.Communal, "test")
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)
        }
        }


@@ -63,7 +63,7 @@ class CommunalSceneInteractorTest : SysuiTestCase() {
            val currentScene by collectLastValue(underTest.currentScene)
            val currentScene by collectLastValue(underTest.currentScene)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)


            underTest.snapToScene(CommunalScenes.Communal)
            underTest.snapToScene(CommunalScenes.Communal, "test")
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)
        }
        }


@@ -75,6 +75,7 @@ class CommunalSceneInteractorTest : SysuiTestCase() {
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            underTest.snapToScene(
            underTest.snapToScene(
                CommunalScenes.Communal,
                CommunalScenes.Communal,
                "test",
                ActivityTransitionAnimator.TIMINGS.totalDuration
                ActivityTransitionAnimator.TIMINGS.totalDuration
            )
            )
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
@@ -86,7 +87,7 @@ class CommunalSceneInteractorTest : SysuiTestCase() {
    fun changeSceneForActivityStartOnDismissKeyguard() =
    fun changeSceneForActivityStartOnDismissKeyguard() =
        testScope.runTest {
        testScope.runTest {
            val currentScene by collectLastValue(underTest.currentScene)
            val currentScene by collectLastValue(underTest.currentScene)
            underTest.snapToScene(CommunalScenes.Communal)
            underTest.snapToScene(CommunalScenes.Communal, "test")
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)


            underTest.changeSceneForActivityStartOnDismissKeyguard()
            underTest.changeSceneForActivityStartOnDismissKeyguard()
@@ -97,7 +98,7 @@ class CommunalSceneInteractorTest : SysuiTestCase() {
    fun changeSceneForActivityStartOnDismissKeyguard_willNotChangeScene_forEditModeActivity() =
    fun changeSceneForActivityStartOnDismissKeyguard_willNotChangeScene_forEditModeActivity() =
        testScope.runTest {
        testScope.runTest {
            val currentScene by collectLastValue(underTest.currentScene)
            val currentScene by collectLastValue(underTest.currentScene)
            underTest.snapToScene(CommunalScenes.Communal)
            underTest.snapToScene(CommunalScenes.Communal, "test")
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)


            underTest.setEditModeState(EditModeState.STARTING)
            underTest.setEditModeState(EditModeState.STARTING)
+4 −4
Original line number Original line Diff line number Diff line
@@ -158,7 +158,7 @@ class CommunalTutorialInteractorTest : SysuiTestCase() {
            kosmos.setCommunalAvailable(true)
            kosmos.setCommunalAvailable(true)
            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_NOT_STARTED)
            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_NOT_STARTED)


            communalInteractor.changeScene(CommunalScenes.Blank)
            communalInteractor.changeScene(CommunalScenes.Blank, "test")


            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_NOT_STARTED)
            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_NOT_STARTED)
        }
        }
@@ -171,7 +171,7 @@ class CommunalTutorialInteractorTest : SysuiTestCase() {
            goToCommunal()
            goToCommunal()
            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_STARTED)
            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_STARTED)


            communalInteractor.changeScene(CommunalScenes.Blank)
            communalInteractor.changeScene(CommunalScenes.Blank, "test")


            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_COMPLETED)
            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_COMPLETED)
        }
        }
@@ -184,13 +184,13 @@ class CommunalTutorialInteractorTest : SysuiTestCase() {
            goToCommunal()
            goToCommunal()
            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED)
            communalTutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED)


            communalInteractor.changeScene(CommunalScenes.Blank)
            communalInteractor.changeScene(CommunalScenes.Blank, "test")


            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_COMPLETED)
            assertThat(tutorialSettingState).isEqualTo(HUB_MODE_TUTORIAL_COMPLETED)
        }
        }


    private suspend fun goToCommunal() {
    private suspend fun goToCommunal() {
        kosmos.setCommunalAvailable(true)
        kosmos.setCommunalAvailable(true)
        communalInteractor.changeScene(CommunalScenes.Communal)
        communalInteractor.changeScene(CommunalScenes.Communal, "test")
    }
    }
}
}
Loading