Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorTest.kt +18 −23 Original line number Diff line number Diff line Loading @@ -21,10 +21,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.configurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.qs.panels.data.repository.QSColumnsRepository import com.android.systemui.qs.panels.data.repository.qsColumnsRepository import com.android.systemui.res.R Loading @@ -33,7 +34,6 @@ import com.android.systemui.shade.domain.interactor.enableSingleShade import com.android.systemui.shade.domain.interactor.enableSplitShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -41,8 +41,9 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class QSColumnsInteractorTest : SysuiTestCase() { private val kosmos = testKosmos().apply { testKosmos().useUnconfinedTestDispatcher().apply { testCase.context.orCreateTestableResources.addOverride( R.integer.quick_settings_infinite_grid_num_columns, 1, Loading @@ -61,43 +62,37 @@ class QSColumnsInteractorTest : SysuiTestCase() { @Before fun setUp() { underTest = with(kosmos) { qsColumnsInteractor } underTest = kosmos.qsColumnsInteractor } @Test fun withSingleShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { kosmos.runTest { val latest by collectLastValue(underTest.columns) kosmos.enableSingleShade() enableSingleShade() assertThat(latest).isEqualTo(1) } } @Test @EnableSceneContainer fun withDualShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { kosmos.runTest { val latest by collectLastValue(underTest.columns) kosmos.enableDualShade() enableDualShade() assertThat(latest).isEqualTo(2) } } @Test fun withSplitShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { kosmos.runTest { val latest by collectLastValue(underTest.columns) kosmos.enableSplitShade() enableSplitShade() assertThat(latest).isEqualTo(3) } } } packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelTest.kt +62 −87 Original line number Diff line number Diff line Loading @@ -23,9 +23,10 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.configurationRepository import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager.Companion.LOCATION_QQS import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager.Companion.LOCATION_QS Loading @@ -40,15 +41,15 @@ import com.android.systemui.shade.domain.interactor.disableDualShade import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @SmallTest class QSColumnsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().apply { testKosmos().useUnconfinedTestDispatcher().apply { usingMediaInComposeFragment = true testCase.context.orCreateTestableResources.addOverride( R.integer.quick_settings_infinite_grid_num_columns, Loading @@ -67,146 +68,120 @@ class QSColumnsViewModelTest : SysuiTestCase() { @Test fun mediaLocationNull_singleOrSplit_alwaysSingleShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(null) underTest.activateIn(testScope) kosmos.disableDualShade() disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QQS, visible = true) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) } } @Test @EnableSceneContainer fun mediaLocationNull_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(null) underTest.activateIn(testScope) kosmos.enableDualShade() enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QQS, visible = true) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) } } @Test @EnableSceneContainer fun mediaLocationQS_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QS) underTest.activateIn(testScope) kosmos.enableDualShade() enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) } } @Test @EnableSceneContainer fun mediaLocationQQS_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QQS) underTest.activateIn(testScope) kosmos.enableDualShade() enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QQS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) } } @Test fun mediaLocationQS_singleOrSplit_halfColumnsOnCorrectConfigurationAndVisible() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QS) underTest.activateIn(testScope) kosmos.disableDualShade() disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS / 2) } } @Test fun mediaLocationQQS_singleOrSplit_halfColumnsOnCorrectConfigurationAndVisible() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QQS) underTest.activateIn(testScope) kosmos.disableDualShade() disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) makeMediaVisible(LOCATION_QQS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS / 2) } } companion object { private const val SINGLE_SPLIT_SHADE_COLUMNS = 4 Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorTest.kt +18 −23 Original line number Diff line number Diff line Loading @@ -21,10 +21,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.configurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.qs.panels.data.repository.QSColumnsRepository import com.android.systemui.qs.panels.data.repository.qsColumnsRepository import com.android.systemui.res.R Loading @@ -33,7 +34,6 @@ import com.android.systemui.shade.domain.interactor.enableSingleShade import com.android.systemui.shade.domain.interactor.enableSplitShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -41,8 +41,9 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class QSColumnsInteractorTest : SysuiTestCase() { private val kosmos = testKosmos().apply { testKosmos().useUnconfinedTestDispatcher().apply { testCase.context.orCreateTestableResources.addOverride( R.integer.quick_settings_infinite_grid_num_columns, 1, Loading @@ -61,43 +62,37 @@ class QSColumnsInteractorTest : SysuiTestCase() { @Before fun setUp() { underTest = with(kosmos) { qsColumnsInteractor } underTest = kosmos.qsColumnsInteractor } @Test fun withSingleShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { kosmos.runTest { val latest by collectLastValue(underTest.columns) kosmos.enableSingleShade() enableSingleShade() assertThat(latest).isEqualTo(1) } } @Test @EnableSceneContainer fun withDualShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { kosmos.runTest { val latest by collectLastValue(underTest.columns) kosmos.enableDualShade() enableDualShade() assertThat(latest).isEqualTo(2) } } @Test fun withSplitShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { kosmos.runTest { val latest by collectLastValue(underTest.columns) kosmos.enableSplitShade() enableSplitShade() assertThat(latest).isEqualTo(3) } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelTest.kt +62 −87 Original line number Diff line number Diff line Loading @@ -23,9 +23,10 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.configurationRepository import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager.Companion.LOCATION_QQS import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager.Companion.LOCATION_QS Loading @@ -40,15 +41,15 @@ import com.android.systemui.shade.domain.interactor.disableDualShade import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @SmallTest class QSColumnsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().apply { testKosmos().useUnconfinedTestDispatcher().apply { usingMediaInComposeFragment = true testCase.context.orCreateTestableResources.addOverride( R.integer.quick_settings_infinite_grid_num_columns, Loading @@ -67,146 +68,120 @@ class QSColumnsViewModelTest : SysuiTestCase() { @Test fun mediaLocationNull_singleOrSplit_alwaysSingleShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(null) underTest.activateIn(testScope) kosmos.disableDualShade() disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QQS, visible = true) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) } } @Test @EnableSceneContainer fun mediaLocationNull_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(null) underTest.activateIn(testScope) kosmos.enableDualShade() enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QQS, visible = true) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) } } @Test @EnableSceneContainer fun mediaLocationQS_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QS) underTest.activateIn(testScope) kosmos.enableDualShade() enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) } } @Test @EnableSceneContainer fun mediaLocationQQS_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QQS) underTest.activateIn(testScope) kosmos.enableDualShade() enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) makeMediaVisible(LOCATION_QQS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(DUAL_SHADE_COLUMNS) } } @Test fun mediaLocationQS_singleOrSplit_halfColumnsOnCorrectConfigurationAndVisible() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QS) underTest.activateIn(testScope) kosmos.disableDualShade() disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) makeMediaVisible(LOCATION_QS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS / 2) } } @Test fun mediaLocationQQS_singleOrSplit_halfColumnsOnCorrectConfigurationAndVisible() = with(kosmos) { testScope.runTest { kosmos.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QQS) underTest.activateIn(testScope) kosmos.disableDualShade() disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) setConfigurationForMediaInRow(mediaInRow = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS) makeMediaVisible(LOCATION_QQS, visible = true) runCurrent() assertThat(underTest.columns).isEqualTo(SINGLE_SPLIT_SHADE_COLUMNS / 2) } } companion object { private const val SINGLE_SPLIT_SHADE_COLUMNS = 4 Loading