Loading packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/AccessibilityQsShortcutsRepositoryImplTest.kt +7 −8 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule import org.junit.Test Loading @@ -40,8 +41,6 @@ import org.mockito.junit.MockitoRule @RunWith(AndroidJUnit4::class) class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { private val kosmos = testKosmos() private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope private val secureSettings = kosmos.fakeSettings @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() Loading @@ -55,8 +54,8 @@ class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { return UserA11yQsShortcutsRepository( userId, secureSettings, testScope.backgroundScope, testDispatcher, kosmos.testScope.backgroundScope, kosmos.testDispatcher, ) } } Loading @@ -69,13 +68,13 @@ class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { AccessibilityQsShortcutsRepositoryImpl( a11yManager, userA11yQsShortcutsRepositoryFactory, testDispatcher kosmos.testDispatcher, ) } @Test fun a11yQsShortcutTargetsForCorrectUsers() = testScope.runTest { kosmos.runTest { val user0 = 0 val targetsForUser0 = setOf("a", "b", "c") val user1 = 1 Loading @@ -94,7 +93,7 @@ class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { secureSettings.putStringForUser( SETTING_NAME, a11yQsTargets.joinToString(separator = ":"), forUser forUser, ) } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +14 −15 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.ui.viewmodel.lockscreenUserActionsViewModel import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope Loading Loading @@ -153,7 +154,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { @Test fun swipeUpOnLockscreen_enterCorrectPin_unlocksDevice() = kosmos.runTest { val actions by testScope.collectLastValue(kosmos.lockscreenUserActionsViewModel.actions) val actions by collectLastValue(kosmos.lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) Loading @@ -170,7 +171,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { kosmos.runTest { setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) Loading @@ -180,7 +181,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { @Test fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenNotDismissed_goesToLockscreen() = kosmos.runTest { val actions by testScope.collectLastValue(shadeUserActionsViewModel.actions) val actions by collectLastValue(shadeUserActionsViewModel.actions) setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) assertCurrentScene(Scenes.Lockscreen) Loading @@ -197,8 +198,8 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { @Test fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenDismissed_goesToGone() = kosmos.runTest { val actions by testScope.collectLastValue(shadeUserActionsViewModel.actions) val canSwipeToEnter by testScope.collectLastValue(deviceEntryInteractor.canSwipeToEnter) val actions by collectLastValue(shadeUserActionsViewModel.actions) val canSwipeToEnter by collectLastValue(deviceEntryInteractor.canSwipeToEnter) setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) Loading Loading @@ -279,7 +280,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { fun swipeUpOnLockscreenWhileUnlocked_dismissesLockscreen() = kosmos.runTest { unlockDevice() val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) Loading @@ -302,7 +303,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { fun dismissingIme_whileOnPasswordBouncer_navigatesToLockscreen() = kosmos.runTest { setAuthMethod(AuthenticationMethodModel.Password) val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) Loading @@ -319,14 +320,13 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { fun bouncerActionButtonClick_opensEmergencyServicesDialer() = kosmos.runTest { setAuthMethod(AuthenticationMethodModel.Password) val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition(to = upDestinationSceneKey) val bouncerActionButton by testScope.collectLastValue(bouncerSceneContentViewModel.actionButton) val bouncerActionButton by collectLastValue(bouncerSceneContentViewModel.actionButton) assertWithMessage("Bouncer action button not visible") .that(bouncerActionButton) .isNotNull() Loading @@ -341,14 +341,13 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { kosmos.runTest { setAuthMethod(AuthenticationMethodModel.Password) startPhoneCall() val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition(to = upDestinationSceneKey) val bouncerActionButton by testScope.collectLastValue(bouncerSceneContentViewModel.actionButton) val bouncerActionButton by collectLastValue(bouncerSceneContentViewModel.actionButton) assertWithMessage("Bouncer action button not visible during call") .that(bouncerActionButton) .isNotNull() Loading Loading @@ -574,7 +573,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { .that(getCurrentSceneInUi()) .isEqualTo(Scenes.Bouncer) val authMethodViewModel by testScope.collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) assertWithMessage("Cannot enter PIN when not using a PIN authentication method!") .that(authMethodViewModel) .isInstanceOf(PinBouncerViewModel::class.java) Loading Loading @@ -603,7 +602,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { .that(getCurrentSceneInUi()) .isEqualTo(Scenes.Bouncer) val authMethodViewModel by testScope.collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) assertWithMessage("Cannot enter PIN when not using a PIN authentication method!") .that(authMethodViewModel) .isInstanceOf(PinBouncerViewModel::class.java) Loading packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt +4 −0 Original line number Diff line number Diff line package com.android.systemui.kosmos import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.Kosmos.Fixture import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher Loading Loading @@ -45,3 +47,5 @@ fun Kosmos.runTest(testBody: suspend Kosmos.() -> Unit) = testScope.runTest { this@runTest.testBody() } fun Kosmos.runCurrent() = testScope.runCurrent() fun <T> Kosmos.collectLastValue(flow: Flow<T>) = testScope.collectLastValue(flow) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/AccessibilityQsShortcutsRepositoryImplTest.kt +7 −8 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Rule import org.junit.Test Loading @@ -40,8 +41,6 @@ import org.mockito.junit.MockitoRule @RunWith(AndroidJUnit4::class) class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { private val kosmos = testKosmos() private val testDispatcher = kosmos.testDispatcher private val testScope = kosmos.testScope private val secureSettings = kosmos.fakeSettings @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() Loading @@ -55,8 +54,8 @@ class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { return UserA11yQsShortcutsRepository( userId, secureSettings, testScope.backgroundScope, testDispatcher, kosmos.testScope.backgroundScope, kosmos.testDispatcher, ) } } Loading @@ -69,13 +68,13 @@ class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { AccessibilityQsShortcutsRepositoryImpl( a11yManager, userA11yQsShortcutsRepositoryFactory, testDispatcher kosmos.testDispatcher, ) } @Test fun a11yQsShortcutTargetsForCorrectUsers() = testScope.runTest { kosmos.runTest { val user0 = 0 val targetsForUser0 = setOf("a", "b", "c") val user1 = 1 Loading @@ -94,7 +93,7 @@ class AccessibilityQsShortcutsRepositoryImplTest : SysuiTestCase() { secureSettings.putStringForUser( SETTING_NAME, a11yQsTargets.joinToString(separator = ":"), forUser forUser, ) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +14 −15 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.ui.viewmodel.lockscreenUserActionsViewModel import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope Loading Loading @@ -153,7 +154,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { @Test fun swipeUpOnLockscreen_enterCorrectPin_unlocksDevice() = kosmos.runTest { val actions by testScope.collectLastValue(kosmos.lockscreenUserActionsViewModel.actions) val actions by collectLastValue(kosmos.lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) Loading @@ -170,7 +171,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { kosmos.runTest { setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) Loading @@ -180,7 +181,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { @Test fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenNotDismissed_goesToLockscreen() = kosmos.runTest { val actions by testScope.collectLastValue(shadeUserActionsViewModel.actions) val actions by collectLastValue(shadeUserActionsViewModel.actions) setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) assertCurrentScene(Scenes.Lockscreen) Loading @@ -197,8 +198,8 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { @Test fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenDismissed_goesToGone() = kosmos.runTest { val actions by testScope.collectLastValue(shadeUserActionsViewModel.actions) val canSwipeToEnter by testScope.collectLastValue(deviceEntryInteractor.canSwipeToEnter) val actions by collectLastValue(shadeUserActionsViewModel.actions) val canSwipeToEnter by collectLastValue(deviceEntryInteractor.canSwipeToEnter) setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true) Loading Loading @@ -279,7 +280,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { fun swipeUpOnLockscreenWhileUnlocked_dismissesLockscreen() = kosmos.runTest { unlockDevice() val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone) Loading @@ -302,7 +303,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { fun dismissingIme_whileOnPasswordBouncer_navigatesToLockscreen() = kosmos.runTest { setAuthMethod(AuthenticationMethodModel.Password) val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) Loading @@ -319,14 +320,13 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { fun bouncerActionButtonClick_opensEmergencyServicesDialer() = kosmos.runTest { setAuthMethod(AuthenticationMethodModel.Password) val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition(to = upDestinationSceneKey) val bouncerActionButton by testScope.collectLastValue(bouncerSceneContentViewModel.actionButton) val bouncerActionButton by collectLastValue(bouncerSceneContentViewModel.actionButton) assertWithMessage("Bouncer action button not visible") .that(bouncerActionButton) .isNotNull() Loading @@ -341,14 +341,13 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { kosmos.runTest { setAuthMethod(AuthenticationMethodModel.Password) startPhoneCall() val actions by testScope.collectLastValue(lockscreenUserActionsViewModel.actions) val actions by collectLastValue(lockscreenUserActionsViewModel.actions) val upDestinationSceneKey = (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer) emulateUserDrivenTransition(to = upDestinationSceneKey) val bouncerActionButton by testScope.collectLastValue(bouncerSceneContentViewModel.actionButton) val bouncerActionButton by collectLastValue(bouncerSceneContentViewModel.actionButton) assertWithMessage("Bouncer action button not visible during call") .that(bouncerActionButton) .isNotNull() Loading Loading @@ -574,7 +573,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { .that(getCurrentSceneInUi()) .isEqualTo(Scenes.Bouncer) val authMethodViewModel by testScope.collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) assertWithMessage("Cannot enter PIN when not using a PIN authentication method!") .that(authMethodViewModel) .isInstanceOf(PinBouncerViewModel::class.java) Loading Loading @@ -603,7 +602,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { .that(getCurrentSceneInUi()) .isEqualTo(Scenes.Bouncer) val authMethodViewModel by testScope.collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) collectLastValue(bouncerSceneContentViewModel.authMethodViewModel) assertWithMessage("Cannot enter PIN when not using a PIN authentication method!") .that(authMethodViewModel) .isInstanceOf(PinBouncerViewModel::class.java) Loading
packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt +4 −0 Original line number Diff line number Diff line package com.android.systemui.kosmos import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.Kosmos.Fixture import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher Loading Loading @@ -45,3 +47,5 @@ fun Kosmos.runTest(testBody: suspend Kosmos.() -> Unit) = testScope.runTest { this@runTest.testBody() } fun Kosmos.runCurrent() = testScope.runCurrent() fun <T> Kosmos.collectLastValue(flow: Flow<T>) = testScope.collectLastValue(flow)