Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationLoggerViewModelTest.kt +76 −4 Original line number Diff line number Diff line Loading @@ -16,16 +16,22 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.scene.data.repository.Idle import com.android.systemui.scene.data.repository.setSceneTransition import com.android.systemui.scene.data.repository.windowRootViewVisibilityRepository import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs import com.android.systemui.testKosmos Loading @@ -33,10 +39,12 @@ import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(AndroidJUnit4::class) class NotificationLoggerViewModelTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class NotificationLoggerViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() Loading @@ -46,9 +54,22 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { private val powerInteractor = kosmos.powerInteractor private val windowRootViewVisibilityRepository = kosmos.windowRootViewVisibilityRepository private val underTest = kosmos.notificationListLoggerViewModel private val underTest by lazy { kosmos.notificationListLoggerViewModel } companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf().andSceneContainer() } } init { mSetFlagsRule.setFlagsParameterization(flags) } @Test @DisableSceneContainer fun isLockscreenOrShadeInteractive_deviceActiveAndShadeIsInteractive_true() = testScope.runTest { powerInteractor.setAwakeForTest() Loading @@ -60,6 +81,7 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { } @Test @DisableSceneContainer fun isLockscreenOrShadeInteractive_deviceIsAsleepAndShadeIsInteractive_false() = testScope.runTest { powerInteractor.setAsleepForTest() Loading @@ -71,6 +93,7 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { } @Test @DisableSceneContainer fun isLockscreenOrShadeInteractive_deviceActiveAndShadeIsNotInteractive_false() = testScope.runTest { powerInteractor.setAwakeForTest() Loading @@ -81,6 +104,54 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { assertThat(actual).isFalse() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceAwakeAndShadeIsDisplayed_true() = testScope.runTest { powerInteractor.setAwakeForTest() kosmos.setSceneTransition(Idle(Scenes.Shade)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isTrue() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceAwakeAndLockScreenIsDisplayed_true() = testScope.runTest { powerInteractor.setAwakeForTest() kosmos.setSceneTransition(Idle(Scenes.Lockscreen)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isTrue() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceIsAsleepOnLockscreen_false() = testScope.runTest { powerInteractor.setAsleepForTest() kosmos.setSceneTransition(Idle(Scenes.Lockscreen)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isFalse() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceActiveAndShadeIsClosed() = testScope.runTest { powerInteractor.setAwakeForTest() kosmos.setSceneTransition(Idle(Scenes.Gone)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isFalse() } @Test fun activeNotifications_hasNotifications() = testScope.runTest { Loading Loading @@ -135,6 +206,7 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { assertThat(isOnLockScreen).isTrue() } @Test fun isOnLockScreen_false() = testScope.runTest { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationLoggerViewModelTest.kt +76 −4 Original line number Diff line number Diff line Loading @@ -16,16 +16,22 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.scene.data.repository.Idle import com.android.systemui.scene.data.repository.setSceneTransition import com.android.systemui.scene.data.repository.windowRootViewVisibilityRepository import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs import com.android.systemui.testKosmos Loading @@ -33,10 +39,12 @@ import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(AndroidJUnit4::class) class NotificationLoggerViewModelTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class NotificationLoggerViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() Loading @@ -46,9 +54,22 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { private val powerInteractor = kosmos.powerInteractor private val windowRootViewVisibilityRepository = kosmos.windowRootViewVisibilityRepository private val underTest = kosmos.notificationListLoggerViewModel private val underTest by lazy { kosmos.notificationListLoggerViewModel } companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf().andSceneContainer() } } init { mSetFlagsRule.setFlagsParameterization(flags) } @Test @DisableSceneContainer fun isLockscreenOrShadeInteractive_deviceActiveAndShadeIsInteractive_true() = testScope.runTest { powerInteractor.setAwakeForTest() Loading @@ -60,6 +81,7 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { } @Test @DisableSceneContainer fun isLockscreenOrShadeInteractive_deviceIsAsleepAndShadeIsInteractive_false() = testScope.runTest { powerInteractor.setAsleepForTest() Loading @@ -71,6 +93,7 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { } @Test @DisableSceneContainer fun isLockscreenOrShadeInteractive_deviceActiveAndShadeIsNotInteractive_false() = testScope.runTest { powerInteractor.setAwakeForTest() Loading @@ -81,6 +104,54 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { assertThat(actual).isFalse() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceAwakeAndShadeIsDisplayed_true() = testScope.runTest { powerInteractor.setAwakeForTest() kosmos.setSceneTransition(Idle(Scenes.Shade)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isTrue() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceAwakeAndLockScreenIsDisplayed_true() = testScope.runTest { powerInteractor.setAwakeForTest() kosmos.setSceneTransition(Idle(Scenes.Lockscreen)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isTrue() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceIsAsleepOnLockscreen_false() = testScope.runTest { powerInteractor.setAsleepForTest() kosmos.setSceneTransition(Idle(Scenes.Lockscreen)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isFalse() } @Test @EnableSceneContainer fun isLockscreenOrShadeInteractive_deviceActiveAndShadeIsClosed() = testScope.runTest { powerInteractor.setAwakeForTest() kosmos.setSceneTransition(Idle(Scenes.Gone)) val actual by collectLastValue(underTest.isLockscreenOrShadeInteractive) assertThat(actual).isFalse() } @Test fun activeNotifications_hasNotifications() = testScope.runTest { Loading Loading @@ -135,6 +206,7 @@ class NotificationLoggerViewModelTest : SysuiTestCase() { assertThat(isOnLockScreen).isTrue() } @Test fun isOnLockScreen_false() = testScope.runTest { Loading