Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/AppsShortcutCategoryRepositoryTest.kt +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategory import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType import com.android.systemui.keyboard.shortcut.shared.model.ShortcutIcon import com.android.systemui.keyboard.shortcut.shared.model.ShortcutSubCategory import com.android.systemui.keyboard.shortcut.shortcutHelperTestHelper import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.res.R Loading @@ -50,6 +51,7 @@ class AppsShortcutCategoryRepositoryTest : SysuiTestCase() { private val fakeLauncherApps = kosmos.fakeLauncherApps private val userTracker = kosmos.fakeUserTracker private val testScope = kosmos.testScope private val helper = kosmos.shortcutHelperTestHelper @Before fun setup() { Loading @@ -76,6 +78,18 @@ class AppsShortcutCategoryRepositoryTest : SysuiTestCase() { ICON_RES_ID_2, TEST_PACKAGE_LABEL_2, ) helper.showFromActivity() } @Test fun categories_emitsEmptyList_whenShortcutHelperIsInactive() { testScope.runTest { val categories by collectLastValue(repo.categories) helper.hideFromActivity() assertThat(categories).isEmpty() } } @Test Loading packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/AppsShortcutCategoryRepository.kt +11 −4 Original line number Diff line number Diff line Loading @@ -22,22 +22,29 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyboard.shortcut.shared.model.Shortcut import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategory import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType import com.android.systemui.keyboard.shortcut.shared.model.ShortcutHelperState import com.android.systemui.keyboard.shortcut.shared.model.ShortcutIcon import com.android.systemui.keyboard.shortcut.shared.model.ShortcutSubCategory import com.android.systemui.res.R import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map @SysUISingleton class AppsShortcutCategoryRepository @Inject constructor(userVisibleAppsRepository: UserVisibleAppsRepository, context: Context) : ShortcutCategoriesRepository { constructor( userVisibleAppsRepository: UserVisibleAppsRepository, context: Context, stateRepository: ShortcutHelperStateRepository, ) : ShortcutCategoriesRepository { override val categories: Flow<List<ShortcutCategory>> = userVisibleAppsRepository.userVisibleApps.map { userVisibleApps -> if (userVisibleApps.isEmpty()) { stateRepository.state.combine(userVisibleAppsRepository.userVisibleApps) { state, userVisibleApps -> if (state is ShortcutHelperState.Inactive || userVisibleApps.isEmpty()) { emptyList() } else { listOf( Loading packages/SystemUI/tests/utils/src/com/android/systemui/keyboard/shortcut/KeyboardShortcutHelperKosmos.kt +7 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,13 @@ val Kosmos.shortcutHelperStateInteractor by } var Kosmos.appsShortcutCategoryRepository: ShortcutCategoriesRepository by Kosmos.Fixture { AppsShortcutCategoryRepository(userVisibleAppsRepository, applicationContext) } Kosmos.Fixture { AppsShortcutCategoryRepository( userVisibleAppsRepository, applicationContext, shortcutHelperStateRepository, ) } val Kosmos.shortcutHelperCategoriesInteractor by Kosmos.Fixture { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/AppsShortcutCategoryRepositoryTest.kt +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategory import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType import com.android.systemui.keyboard.shortcut.shared.model.ShortcutIcon import com.android.systemui.keyboard.shortcut.shared.model.ShortcutSubCategory import com.android.systemui.keyboard.shortcut.shortcutHelperTestHelper import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.res.R Loading @@ -50,6 +51,7 @@ class AppsShortcutCategoryRepositoryTest : SysuiTestCase() { private val fakeLauncherApps = kosmos.fakeLauncherApps private val userTracker = kosmos.fakeUserTracker private val testScope = kosmos.testScope private val helper = kosmos.shortcutHelperTestHelper @Before fun setup() { Loading @@ -76,6 +78,18 @@ class AppsShortcutCategoryRepositoryTest : SysuiTestCase() { ICON_RES_ID_2, TEST_PACKAGE_LABEL_2, ) helper.showFromActivity() } @Test fun categories_emitsEmptyList_whenShortcutHelperIsInactive() { testScope.runTest { val categories by collectLastValue(repo.categories) helper.hideFromActivity() assertThat(categories).isEmpty() } } @Test Loading
packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/AppsShortcutCategoryRepository.kt +11 −4 Original line number Diff line number Diff line Loading @@ -22,22 +22,29 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyboard.shortcut.shared.model.Shortcut import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategory import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType import com.android.systemui.keyboard.shortcut.shared.model.ShortcutHelperState import com.android.systemui.keyboard.shortcut.shared.model.ShortcutIcon import com.android.systemui.keyboard.shortcut.shared.model.ShortcutSubCategory import com.android.systemui.res.R import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map @SysUISingleton class AppsShortcutCategoryRepository @Inject constructor(userVisibleAppsRepository: UserVisibleAppsRepository, context: Context) : ShortcutCategoriesRepository { constructor( userVisibleAppsRepository: UserVisibleAppsRepository, context: Context, stateRepository: ShortcutHelperStateRepository, ) : ShortcutCategoriesRepository { override val categories: Flow<List<ShortcutCategory>> = userVisibleAppsRepository.userVisibleApps.map { userVisibleApps -> if (userVisibleApps.isEmpty()) { stateRepository.state.combine(userVisibleAppsRepository.userVisibleApps) { state, userVisibleApps -> if (state is ShortcutHelperState.Inactive || userVisibleApps.isEmpty()) { emptyList() } else { listOf( Loading
packages/SystemUI/tests/utils/src/com/android/systemui/keyboard/shortcut/KeyboardShortcutHelperKosmos.kt +7 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,13 @@ val Kosmos.shortcutHelperStateInteractor by } var Kosmos.appsShortcutCategoryRepository: ShortcutCategoriesRepository by Kosmos.Fixture { AppsShortcutCategoryRepository(userVisibleAppsRepository, applicationContext) } Kosmos.Fixture { AppsShortcutCategoryRepository( userVisibleAppsRepository, applicationContext, shortcutHelperStateRepository, ) } val Kosmos.shortcutHelperCategoriesInteractor by Kosmos.Fixture { Loading