Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryTest.kt 0 → 100644 +83 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.qs.panels.data.repository import android.platform.test.annotations.EnableFlags 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.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.shade.shared.flag.DualShade 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 @SmallTest @RunWith(AndroidJUnit4::class) class QSColumnsRepositoryTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var underTest: QSColumnsRepository @Before fun setUp() { underTest = with(kosmos) { qsColumnsRepository } } @Test fun configChanges_triggerColumnsUpdate() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) setColumnsInConfig(4) assertThat(latest).isEqualTo(4) setColumnsInConfig(8) assertThat(latest).isEqualTo(8) } } @Test @EnableFlags(DualShade.FLAG_NAME) fun withDualShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) assertThat(latest).isEqualTo(4) setColumnsInConfig(8, id = R.integer.quick_settings_dual_shade_num_columns) // Asserts config changes are ignored assertThat(latest).isEqualTo(4) } } private fun setColumnsInConfig( columns: Int, id: Int = R.integer.quick_settings_infinite_grid_num_columns, ) = with(kosmos) { testCase.context.orCreateTestableResources.addOverride(id, columns) fakeConfigurationRepository.onConfigurationChange() } } packages/SystemUI/res/values-land/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ <integer name="quick_settings_num_columns">4</integer> <!-- The number of columns in the infinite grid QuickSettings --> <integer name="quick_settings_infinite_grid_num_columns">8</integer> <!-- The number of columns that the top level tiles span in the QuickSettings --> <integer name="quick_settings_user_time_settings_tile_span">2</integer> Loading packages/SystemUI/res/values-sw600dp-port/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,9 @@ <!-- The number of columns in the QuickSettings --> <integer name="quick_settings_num_columns">3</integer> <!-- The number of columns in the infinite grid QuickSettings --> <integer name="quick_settings_infinite_grid_num_columns">6</integer> <integer name="power_menu_lite_max_columns">2</integer> <integer name="power_menu_lite_max_rows">3</integer> Loading packages/SystemUI/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ <!-- The number of columns in the infinite grid QuickSettings --> <integer name="quick_settings_infinite_grid_num_columns">4</integer> <!-- The number of columns in the Dual Shade QuickSettings --> <integer name="quick_settings_dual_shade_num_columns">4</integer> <!-- Override column number for quick settings. For now, this value has effect only when flag lockscreen.enable_landscape is enabled. TODO (b/293252410) - change this comment/resource when flag is enabled --> Loading packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt +3 −3 Original line number Diff line number Diff line Loading @@ -31,12 +31,12 @@ import com.android.systemui.qs.panels.ui.compose.GridLayout import com.android.systemui.qs.panels.ui.compose.PaginatableGridLayout import com.android.systemui.qs.panels.ui.compose.PaginatedGridLayout import com.android.systemui.qs.panels.ui.compose.infinitegrid.InfiniteGridLayout import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModel import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.IconLabelVisibilityViewModel import com.android.systemui.qs.panels.ui.viewmodel.IconLabelVisibilityViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModel import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsSizeViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsViewModel import dagger.Binds import dagger.Module import dagger.Provides Loading @@ -55,7 +55,7 @@ interface PanelsModule { @Binds fun bindIconTilesViewModel(impl: IconTilesViewModelImpl): IconTilesViewModel @Binds fun bindGridSizeViewModel(impl: FixedColumnsSizeViewModelImpl): FixedColumnsSizeViewModel @Binds fun bindQSColumnsViewModel(impl: QSColumnsSizeViewModelImpl): QSColumnsViewModel @Binds fun bindIconLabelVisibilityViewModel( Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSColumnsRepositoryTest.kt 0 → 100644 +83 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.qs.panels.data.repository import android.platform.test.annotations.EnableFlags 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.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.shade.shared.flag.DualShade 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 @SmallTest @RunWith(AndroidJUnit4::class) class QSColumnsRepositoryTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var underTest: QSColumnsRepository @Before fun setUp() { underTest = with(kosmos) { qsColumnsRepository } } @Test fun configChanges_triggerColumnsUpdate() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) setColumnsInConfig(4) assertThat(latest).isEqualTo(4) setColumnsInConfig(8) assertThat(latest).isEqualTo(8) } } @Test @EnableFlags(DualShade.FLAG_NAME) fun withDualShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) assertThat(latest).isEqualTo(4) setColumnsInConfig(8, id = R.integer.quick_settings_dual_shade_num_columns) // Asserts config changes are ignored assertThat(latest).isEqualTo(4) } } private fun setColumnsInConfig( columns: Int, id: Int = R.integer.quick_settings_infinite_grid_num_columns, ) = with(kosmos) { testCase.context.orCreateTestableResources.addOverride(id, columns) fakeConfigurationRepository.onConfigurationChange() } }
packages/SystemUI/res/values-land/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ <integer name="quick_settings_num_columns">4</integer> <!-- The number of columns in the infinite grid QuickSettings --> <integer name="quick_settings_infinite_grid_num_columns">8</integer> <!-- The number of columns that the top level tiles span in the QuickSettings --> <integer name="quick_settings_user_time_settings_tile_span">2</integer> Loading
packages/SystemUI/res/values-sw600dp-port/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,9 @@ <!-- The number of columns in the QuickSettings --> <integer name="quick_settings_num_columns">3</integer> <!-- The number of columns in the infinite grid QuickSettings --> <integer name="quick_settings_infinite_grid_num_columns">6</integer> <integer name="power_menu_lite_max_columns">2</integer> <integer name="power_menu_lite_max_rows">3</integer> Loading
packages/SystemUI/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ <!-- The number of columns in the infinite grid QuickSettings --> <integer name="quick_settings_infinite_grid_num_columns">4</integer> <!-- The number of columns in the Dual Shade QuickSettings --> <integer name="quick_settings_dual_shade_num_columns">4</integer> <!-- Override column number for quick settings. For now, this value has effect only when flag lockscreen.enable_landscape is enabled. TODO (b/293252410) - change this comment/resource when flag is enabled --> Loading
packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt +3 −3 Original line number Diff line number Diff line Loading @@ -31,12 +31,12 @@ import com.android.systemui.qs.panels.ui.compose.GridLayout import com.android.systemui.qs.panels.ui.compose.PaginatableGridLayout import com.android.systemui.qs.panels.ui.compose.PaginatedGridLayout import com.android.systemui.qs.panels.ui.compose.infinitegrid.InfiniteGridLayout import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModel import com.android.systemui.qs.panels.ui.viewmodel.FixedColumnsSizeViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.IconLabelVisibilityViewModel import com.android.systemui.qs.panels.ui.viewmodel.IconLabelVisibilityViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModel import com.android.systemui.qs.panels.ui.viewmodel.IconTilesViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsSizeViewModelImpl import com.android.systemui.qs.panels.ui.viewmodel.QSColumnsViewModel import dagger.Binds import dagger.Module import dagger.Provides Loading @@ -55,7 +55,7 @@ interface PanelsModule { @Binds fun bindIconTilesViewModel(impl: IconTilesViewModelImpl): IconTilesViewModel @Binds fun bindGridSizeViewModel(impl: FixedColumnsSizeViewModelImpl): FixedColumnsSizeViewModel @Binds fun bindQSColumnsViewModel(impl: QSColumnsSizeViewModelImpl): QSColumnsViewModel @Binds fun bindIconLabelVisibilityViewModel( Loading