Loading packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt +7 −0 Original line number Diff line number Diff line Loading @@ -17,9 +17,12 @@ package com.android.systemui.common.ui.compose import android.content.Context import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import com.android.systemui.common.shared.model.Text import com.android.systemui.common.shared.model.Text.Companion.loadText /** Returns the loaded [String] or `null` if there isn't one. */ @Composable Loading @@ -29,3 +32,7 @@ fun Text.load(): String? { is Text.Resource -> stringResource(res) } } fun Text.toAnnotatedString(context: Context): AnnotatedString? { return loadText(context)?.let { AnnotatedString(it) } } packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.qs.panels.data.repository import android.content.ComponentName import android.content.packageManager import android.content.pm.PackageManager import android.content.pm.ServiceInfo import android.content.pm.UserInfo import android.graphics.drawable.TestStubDrawable import androidx.test.ext.junit.runners.AndroidJUnit4 Loading @@ -35,6 +34,7 @@ import com.android.systemui.qs.pipeline.data.repository.FakeInstalledTilesCompon import com.android.systemui.qs.pipeline.data.repository.fakeInstalledTilesRepository import com.android.systemui.qs.pipeline.data.repository.installedTilesRepository import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.shared.model.TileCategory import com.android.systemui.settings.FakeUserTracker import com.android.systemui.settings.fakeUserTracker import com.android.systemui.testKosmos Loading Loading @@ -100,6 +100,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() { Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)), Text.Loaded(tileService1), Text.Loaded(appName1), TileCategory.PROVIDED_BY_APP, ) val expectedData2 = EditTileData( Loading @@ -107,6 +108,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() { Icon.Loaded(drawable2, ContentDescription.Loaded(tileService2)), Text.Loaded(tileService2), Text.Loaded(appName2), TileCategory.PROVIDED_BY_APP, ) assertThat(editTileDataList).containsExactly(expectedData1, expectedData2) Loading Loading @@ -144,6 +146,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() { Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)), Text.Loaded(tileService1), Text.Loaded(appName1), TileCategory.PROVIDED_BY_APP, ) val editTileDataList = underTest.getCustomTileData() Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt +5 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.qs.panels.shared.model.EditTileData import com.android.systemui.qs.pipeline.data.repository.FakeInstalledTilesComponentRepository import com.android.systemui.qs.pipeline.data.repository.fakeInstalledTilesRepository import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.shared.model.TileCategory import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig import com.android.systemui.qs.tiles.impl.internet.qsInternetTileConfig Loading Loading @@ -132,6 +133,7 @@ class EditTilesListInteractorTest : SysuiTestCase() { icon = Icon.Loaded(icon, ContentDescription.Loaded(tileName)), label = Text.Loaded(tileName), appName = Text.Loaded(appName), category = TileCategory.PROVIDED_BY_APP, ) assertThat(editTiles.customTiles).hasSize(1) Loading Loading @@ -181,7 +183,8 @@ class EditTilesListInteractorTest : SysuiTestCase() { tileSpec = this, icon = Icon.Resource(android.R.drawable.star_on, ContentDescription.Loaded(spec)), label = Text.Loaded(spec), appName = null appName = null, category = TileCategory.UNKNOWN, ) } Loading @@ -192,6 +195,7 @@ class EditTilesListInteractorTest : SysuiTestCase() { Icon.Resource(uiConfig.iconRes, ContentDescription.Resource(uiConfig.labelRes)), label = Text.Resource(uiConfig.labelRes), appName = null, category = category, ) } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt +4 −2 Original line number Diff line number Diff line Loading @@ -16,11 +16,11 @@ package com.android.systemui.qs.panels.ui.compose import androidx.compose.ui.text.AnnotatedString import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text import com.android.systemui.qs.panels.shared.model.SizedTile import com.android.systemui.qs.panels.shared.model.SizedTileImpl import com.android.systemui.qs.panels.ui.model.GridCell Loading @@ -28,6 +28,7 @@ import com.android.systemui.qs.panels.ui.model.SpacerGridCell import com.android.systemui.qs.panels.ui.model.TileGridCell import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.shared.model.TileCategory import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -141,10 +142,11 @@ class EditTileListStateTest : SysuiTestCase() { EditTileViewModel( tileSpec = TileSpec.create(tileSpec), icon = Icon.Resource(0, null), label = Text.Loaded("unused"), label = AnnotatedString("unused"), appName = null, isCurrent = true, availableEditActions = emptySet(), category = TileCategory.UNKNOWN, ), width, ) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt +14 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text import com.android.systemui.common.ui.compose.toAnnotatedString import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope Loading @@ -42,6 +43,7 @@ import com.android.systemui.qs.pipeline.data.repository.fakeMinimumTilesReposito import com.android.systemui.qs.pipeline.domain.interactor.currentTilesInteractor import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.qsTileFactory import com.android.systemui.qs.shared.model.TileCategory import com.android.systemui.qs.tiles.impl.alarm.qsAlarmTileConfig import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig Loading Loading @@ -190,7 +192,7 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { .forEach { val data = getEditTileData(it.tileSpec) assertThat(it.label).isEqualTo(data.label) assertThat(it.label).isEqualTo(data.label.toAnnotatedString(context)) assertThat(it.icon).isEqualTo(data.icon) assertThat(it.appName).isNull() } Loading Loading @@ -224,15 +226,19 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { // service1 val model1 = tiles!!.first { it.tileSpec == TileSpec.create(component1) } assertThat(model1.label).isEqualTo(Text.Loaded(tileService1)) assertThat(model1.appName).isEqualTo(Text.Loaded(appName1)) assertThat(model1.label) .isEqualTo(Text.Loaded(tileService1).toAnnotatedString(context)) assertThat(model1.appName) .isEqualTo(Text.Loaded(appName1).toAnnotatedString(context)) assertThat(model1.icon) .isEqualTo(Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1))) // service2 val model2 = tiles!!.first { it.tileSpec == TileSpec.create(component2) } assertThat(model2.label).isEqualTo(Text.Loaded(tileService2)) assertThat(model2.appName).isEqualTo(Text.Loaded(appName2)) assertThat(model2.label) .isEqualTo(Text.Loaded(tileService2).toAnnotatedString(context)) assertThat(model2.appName) .isEqualTo(Text.Loaded(appName2).toAnnotatedString(context)) assertThat(model2.icon) .isEqualTo(Icon.Loaded(drawable2, ContentDescription.Loaded(tileService2))) } Loading Loading @@ -559,7 +565,8 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { tileSpec = this, icon = Icon.Resource(R.drawable.star_on, ContentDescription.Loaded(spec)), label = Text.Loaded(spec), appName = null appName = null, category = TileCategory.UNKNOWN, ) } Loading @@ -570,6 +577,7 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { Icon.Resource(uiConfig.iconRes, ContentDescription.Resource(uiConfig.labelRes)), label = Text.Resource(uiConfig.labelRes), appName = null, category = category, ) } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt +7 −0 Original line number Diff line number Diff line Loading @@ -17,9 +17,12 @@ package com.android.systemui.common.ui.compose import android.content.Context import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import com.android.systemui.common.shared.model.Text import com.android.systemui.common.shared.model.Text.Companion.loadText /** Returns the loaded [String] or `null` if there isn't one. */ @Composable Loading @@ -29,3 +32,7 @@ fun Text.load(): String? { is Text.Resource -> stringResource(res) } } fun Text.toAnnotatedString(context: Context): AnnotatedString? { return loadText(context)?.let { AnnotatedString(it) } }
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt +4 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.qs.panels.data.repository import android.content.ComponentName import android.content.packageManager import android.content.pm.PackageManager import android.content.pm.ServiceInfo import android.content.pm.UserInfo import android.graphics.drawable.TestStubDrawable import androidx.test.ext.junit.runners.AndroidJUnit4 Loading @@ -35,6 +34,7 @@ import com.android.systemui.qs.pipeline.data.repository.FakeInstalledTilesCompon import com.android.systemui.qs.pipeline.data.repository.fakeInstalledTilesRepository import com.android.systemui.qs.pipeline.data.repository.installedTilesRepository import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.shared.model.TileCategory import com.android.systemui.settings.FakeUserTracker import com.android.systemui.settings.fakeUserTracker import com.android.systemui.testKosmos Loading Loading @@ -100,6 +100,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() { Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)), Text.Loaded(tileService1), Text.Loaded(appName1), TileCategory.PROVIDED_BY_APP, ) val expectedData2 = EditTileData( Loading @@ -107,6 +108,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() { Icon.Loaded(drawable2, ContentDescription.Loaded(tileService2)), Text.Loaded(tileService2), Text.Loaded(appName2), TileCategory.PROVIDED_BY_APP, ) assertThat(editTileDataList).containsExactly(expectedData1, expectedData2) Loading Loading @@ -144,6 +146,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() { Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)), Text.Loaded(tileService1), Text.Loaded(appName1), TileCategory.PROVIDED_BY_APP, ) val editTileDataList = underTest.getCustomTileData() Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt +5 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.qs.panels.shared.model.EditTileData import com.android.systemui.qs.pipeline.data.repository.FakeInstalledTilesComponentRepository import com.android.systemui.qs.pipeline.data.repository.fakeInstalledTilesRepository import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.shared.model.TileCategory import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig import com.android.systemui.qs.tiles.impl.internet.qsInternetTileConfig Loading Loading @@ -132,6 +133,7 @@ class EditTilesListInteractorTest : SysuiTestCase() { icon = Icon.Loaded(icon, ContentDescription.Loaded(tileName)), label = Text.Loaded(tileName), appName = Text.Loaded(appName), category = TileCategory.PROVIDED_BY_APP, ) assertThat(editTiles.customTiles).hasSize(1) Loading Loading @@ -181,7 +183,8 @@ class EditTilesListInteractorTest : SysuiTestCase() { tileSpec = this, icon = Icon.Resource(android.R.drawable.star_on, ContentDescription.Loaded(spec)), label = Text.Loaded(spec), appName = null appName = null, category = TileCategory.UNKNOWN, ) } Loading @@ -192,6 +195,7 @@ class EditTilesListInteractorTest : SysuiTestCase() { Icon.Resource(uiConfig.iconRes, ContentDescription.Resource(uiConfig.labelRes)), label = Text.Resource(uiConfig.labelRes), appName = null, category = category, ) } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt +4 −2 Original line number Diff line number Diff line Loading @@ -16,11 +16,11 @@ package com.android.systemui.qs.panels.ui.compose import androidx.compose.ui.text.AnnotatedString import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text import com.android.systemui.qs.panels.shared.model.SizedTile import com.android.systemui.qs.panels.shared.model.SizedTileImpl import com.android.systemui.qs.panels.ui.model.GridCell Loading @@ -28,6 +28,7 @@ import com.android.systemui.qs.panels.ui.model.SpacerGridCell import com.android.systemui.qs.panels.ui.model.TileGridCell import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.shared.model.TileCategory import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -141,10 +142,11 @@ class EditTileListStateTest : SysuiTestCase() { EditTileViewModel( tileSpec = TileSpec.create(tileSpec), icon = Icon.Resource(0, null), label = Text.Loaded("unused"), label = AnnotatedString("unused"), appName = null, isCurrent = true, availableEditActions = emptySet(), category = TileCategory.UNKNOWN, ), width, ) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt +14 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text import com.android.systemui.common.ui.compose.toAnnotatedString import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope Loading @@ -42,6 +43,7 @@ import com.android.systemui.qs.pipeline.data.repository.fakeMinimumTilesReposito import com.android.systemui.qs.pipeline.domain.interactor.currentTilesInteractor import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.qsTileFactory import com.android.systemui.qs.shared.model.TileCategory import com.android.systemui.qs.tiles.impl.alarm.qsAlarmTileConfig import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig Loading Loading @@ -190,7 +192,7 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { .forEach { val data = getEditTileData(it.tileSpec) assertThat(it.label).isEqualTo(data.label) assertThat(it.label).isEqualTo(data.label.toAnnotatedString(context)) assertThat(it.icon).isEqualTo(data.icon) assertThat(it.appName).isNull() } Loading Loading @@ -224,15 +226,19 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { // service1 val model1 = tiles!!.first { it.tileSpec == TileSpec.create(component1) } assertThat(model1.label).isEqualTo(Text.Loaded(tileService1)) assertThat(model1.appName).isEqualTo(Text.Loaded(appName1)) assertThat(model1.label) .isEqualTo(Text.Loaded(tileService1).toAnnotatedString(context)) assertThat(model1.appName) .isEqualTo(Text.Loaded(appName1).toAnnotatedString(context)) assertThat(model1.icon) .isEqualTo(Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1))) // service2 val model2 = tiles!!.first { it.tileSpec == TileSpec.create(component2) } assertThat(model2.label).isEqualTo(Text.Loaded(tileService2)) assertThat(model2.appName).isEqualTo(Text.Loaded(appName2)) assertThat(model2.label) .isEqualTo(Text.Loaded(tileService2).toAnnotatedString(context)) assertThat(model2.appName) .isEqualTo(Text.Loaded(appName2).toAnnotatedString(context)) assertThat(model2.icon) .isEqualTo(Icon.Loaded(drawable2, ContentDescription.Loaded(tileService2))) } Loading Loading @@ -559,7 +565,8 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { tileSpec = this, icon = Icon.Resource(R.drawable.star_on, ContentDescription.Loaded(spec)), label = Text.Loaded(spec), appName = null appName = null, category = TileCategory.UNKNOWN, ) } Loading @@ -570,6 +577,7 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { Icon.Resource(uiConfig.iconRes, ContentDescription.Resource(uiConfig.labelRes)), label = Text.Resource(uiConfig.labelRes), appName = null, category = category, ) } Loading