Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VolumePanelRoot.kt +0 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier Loading @@ -43,16 +42,7 @@ private val padding = 24.dp fun VolumePanelRoot( viewModel: VolumePanelViewModel, modifier: Modifier = Modifier, onDismiss: () -> Unit ) { LaunchedEffect(viewModel) { viewModel.volumePanelState.collect { if (!it.isVisible) { onDismiss() } } } val accessibilityTitle = stringResource(R.string.accessibility_volume_settings) val state: VolumePanelState by viewModel.volumePanelState.collectAsStateWithLifecycle() val components by viewModel.componentsLayout.collectAsStateWithLifecycle(null) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/bottombar/ui/viewmodel/BottomBarViewModelTest.kt +7 −6 Original line number Diff line number Diff line Loading @@ -24,13 +24,13 @@ import androidx.test.filters.SmallTest import com.android.internal.logging.uiEventLogger import com.android.internal.logging.uiEventLoggerFake import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.activityStarter import com.android.systemui.testKosmos import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.eq import com.android.systemui.volume.panel.data.repository.volumePanelGlobalStateRepository import com.android.systemui.volume.panel.ui.VolumePanelUiEvent import com.android.systemui.volume.panel.ui.viewmodel.volumePanelViewModel import com.google.common.truth.Truth.assertThat Loading @@ -56,7 +56,10 @@ class BottomBarViewModelTest : SysuiTestCase() { @Captor private lateinit var activityStartedCaptor: ArgumentCaptor<ActivityStarter.Callback> private val kosmos = testKosmos() private val kosmos = testKosmos().apply { volumePanelGlobalStateRepository.updateVolumePanelState { it.copy(isVisible = true) } } private lateinit var underTest: BottomBarViewModel Loading @@ -75,8 +78,7 @@ class BottomBarViewModelTest : SysuiTestCase() { underTest.onDoneClicked() runCurrent() val volumePanelState by collectLastValue(volumePanelViewModel.volumePanelState) assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } } Loading Loading @@ -106,8 +108,7 @@ class BottomBarViewModelTest : SysuiTestCase() { .isEqualTo(VolumePanelUiEvent.VOLUME_PANEL_SOUND_SETTINGS_CLICKED.id) activityStartedCaptor.value.onActivityStarted(ActivityManager.START_SUCCESS) val volumePanelState by collectLastValue(volumePanelViewModel.volumePanelState) assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/domain/interactor/VolumePanelGlobalStateInteractorTest.kt 0 → 100644 +48 −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.volume.panel.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.testScope 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 @SmallTest @RunWith(AndroidJUnit4::class) class VolumePanelGlobalStateInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() private val underTest = kosmos.volumePanelGlobalStateInteractor @Test fun changeVisibility_changesVisibility() = with(kosmos) { testScope.runTest { underTest.setVisible(false) assertThat(underTest.globalState.value.isVisible).isFalse() underTest.setVisible(true) assertThat(underTest.globalState.value.isVisible).isTrue() } } } packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/DefaultComponentsLayoutManagerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ class DefaultComponentsLayoutManagerTest : SysuiTestCase() { val component5 = ComponentState(COMPONENT_5, kosmos.mockVolumePanelUiComponent, false) val layout = underTest.layout( VolumePanelState(0, false, false), VolumePanelState(orientation = 0, isLargeScreen = false), setOf( bottomBarComponentState, component1, Loading Loading @@ -79,7 +79,7 @@ class DefaultComponentsLayoutManagerTest : SysuiTestCase() { val component1State = ComponentState(COMPONENT_1, kosmos.mockVolumePanelUiComponent, false) val component2State = ComponentState(COMPONENT_2, kosmos.mockVolumePanelUiComponent, false) underTest.layout( VolumePanelState(0, false, false), VolumePanelState(orientation = 0, isLargeScreen = false), setOf( component1State, component2State, Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/VolumePanelViewModelTest.kt +8 −8 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.policy.fakeConfigurationController import com.android.systemui.testKosmos import com.android.systemui.volume.panel.data.repository.volumePanelGlobalStateRepository import com.android.systemui.volume.panel.domain.interactor.criteriaByKey import com.android.systemui.volume.panel.domain.unavailableCriteria import com.android.systemui.volume.panel.shared.model.VolumePanelComponentKey Loading @@ -49,7 +50,10 @@ import org.junit.runner.RunWith class VolumePanelViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().apply { componentsLayoutManager = DefaultComponentsLayoutManager(BOTTOM_BAR) } testKosmos().apply { componentsLayoutManager = DefaultComponentsLayoutManager(BOTTOM_BAR) volumePanelGlobalStateRepository.updateVolumePanelState { it.copy(isVisible = true) } } private val testableResources = context.orCreateTestableResources Loading @@ -58,12 +62,10 @@ class VolumePanelViewModelTest : SysuiTestCase() { @Test fun dismissingPanel_changesVisibility() = test { testScope.runTest { assertThat(underTest.volumePanelState.value.isVisible).isTrue() underTest.dismissPanel() runCurrent() assertThat(underTest.volumePanelState.value.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } Loading Loading @@ -114,11 +116,10 @@ class VolumePanelViewModelTest : SysuiTestCase() { @Test fun dismissPanel_dismissesPanel() = test { testScope.runTest { val volumePanelState by collectLastValue(underTest.volumePanelState) underTest.dismissPanel() runCurrent() assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } Loading @@ -126,14 +127,13 @@ class VolumePanelViewModelTest : SysuiTestCase() { fun dismissBroadcast_dismissesPanel() = test { testScope.runTest { runCurrent() // run the flows to let allow the receiver to be registered val volumePanelState by collectLastValue(underTest.volumePanelState) broadcastDispatcher.sendIntentToMatchingReceiversOnly( applicationContext, Intent(DISMISS_ACTION), ) runCurrent() assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VolumePanelRoot.kt +0 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier Loading @@ -43,16 +42,7 @@ private val padding = 24.dp fun VolumePanelRoot( viewModel: VolumePanelViewModel, modifier: Modifier = Modifier, onDismiss: () -> Unit ) { LaunchedEffect(viewModel) { viewModel.volumePanelState.collect { if (!it.isVisible) { onDismiss() } } } val accessibilityTitle = stringResource(R.string.accessibility_volume_settings) val state: VolumePanelState by viewModel.volumePanelState.collectAsStateWithLifecycle() val components by viewModel.componentsLayout.collectAsStateWithLifecycle(null) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/bottombar/ui/viewmodel/BottomBarViewModelTest.kt +7 −6 Original line number Diff line number Diff line Loading @@ -24,13 +24,13 @@ import androidx.test.filters.SmallTest import com.android.internal.logging.uiEventLogger import com.android.internal.logging.uiEventLoggerFake import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.activityStarter import com.android.systemui.testKosmos import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.eq import com.android.systemui.volume.panel.data.repository.volumePanelGlobalStateRepository import com.android.systemui.volume.panel.ui.VolumePanelUiEvent import com.android.systemui.volume.panel.ui.viewmodel.volumePanelViewModel import com.google.common.truth.Truth.assertThat Loading @@ -56,7 +56,10 @@ class BottomBarViewModelTest : SysuiTestCase() { @Captor private lateinit var activityStartedCaptor: ArgumentCaptor<ActivityStarter.Callback> private val kosmos = testKosmos() private val kosmos = testKosmos().apply { volumePanelGlobalStateRepository.updateVolumePanelState { it.copy(isVisible = true) } } private lateinit var underTest: BottomBarViewModel Loading @@ -75,8 +78,7 @@ class BottomBarViewModelTest : SysuiTestCase() { underTest.onDoneClicked() runCurrent() val volumePanelState by collectLastValue(volumePanelViewModel.volumePanelState) assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } } Loading Loading @@ -106,8 +108,7 @@ class BottomBarViewModelTest : SysuiTestCase() { .isEqualTo(VolumePanelUiEvent.VOLUME_PANEL_SOUND_SETTINGS_CLICKED.id) activityStartedCaptor.value.onActivityStarted(ActivityManager.START_SUCCESS) val volumePanelState by collectLastValue(volumePanelViewModel.volumePanelState) assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/domain/interactor/VolumePanelGlobalStateInteractorTest.kt 0 → 100644 +48 −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.volume.panel.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.testScope 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 @SmallTest @RunWith(AndroidJUnit4::class) class VolumePanelGlobalStateInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() private val underTest = kosmos.volumePanelGlobalStateInteractor @Test fun changeVisibility_changesVisibility() = with(kosmos) { testScope.runTest { underTest.setVisible(false) assertThat(underTest.globalState.value.isVisible).isFalse() underTest.setVisible(true) assertThat(underTest.globalState.value.isVisible).isTrue() } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/DefaultComponentsLayoutManagerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ class DefaultComponentsLayoutManagerTest : SysuiTestCase() { val component5 = ComponentState(COMPONENT_5, kosmos.mockVolumePanelUiComponent, false) val layout = underTest.layout( VolumePanelState(0, false, false), VolumePanelState(orientation = 0, isLargeScreen = false), setOf( bottomBarComponentState, component1, Loading Loading @@ -79,7 +79,7 @@ class DefaultComponentsLayoutManagerTest : SysuiTestCase() { val component1State = ComponentState(COMPONENT_1, kosmos.mockVolumePanelUiComponent, false) val component2State = ComponentState(COMPONENT_2, kosmos.mockVolumePanelUiComponent, false) underTest.layout( VolumePanelState(0, false, false), VolumePanelState(orientation = 0, isLargeScreen = false), setOf( component1State, component2State, Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/VolumePanelViewModelTest.kt +8 −8 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.policy.fakeConfigurationController import com.android.systemui.testKosmos import com.android.systemui.volume.panel.data.repository.volumePanelGlobalStateRepository import com.android.systemui.volume.panel.domain.interactor.criteriaByKey import com.android.systemui.volume.panel.domain.unavailableCriteria import com.android.systemui.volume.panel.shared.model.VolumePanelComponentKey Loading @@ -49,7 +50,10 @@ import org.junit.runner.RunWith class VolumePanelViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().apply { componentsLayoutManager = DefaultComponentsLayoutManager(BOTTOM_BAR) } testKosmos().apply { componentsLayoutManager = DefaultComponentsLayoutManager(BOTTOM_BAR) volumePanelGlobalStateRepository.updateVolumePanelState { it.copy(isVisible = true) } } private val testableResources = context.orCreateTestableResources Loading @@ -58,12 +62,10 @@ class VolumePanelViewModelTest : SysuiTestCase() { @Test fun dismissingPanel_changesVisibility() = test { testScope.runTest { assertThat(underTest.volumePanelState.value.isVisible).isTrue() underTest.dismissPanel() runCurrent() assertThat(underTest.volumePanelState.value.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } Loading Loading @@ -114,11 +116,10 @@ class VolumePanelViewModelTest : SysuiTestCase() { @Test fun dismissPanel_dismissesPanel() = test { testScope.runTest { val volumePanelState by collectLastValue(underTest.volumePanelState) underTest.dismissPanel() runCurrent() assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } Loading @@ -126,14 +127,13 @@ class VolumePanelViewModelTest : SysuiTestCase() { fun dismissBroadcast_dismissesPanel() = test { testScope.runTest { runCurrent() // run the flows to let allow the receiver to be registered val volumePanelState by collectLastValue(underTest.volumePanelState) broadcastDispatcher.sendIntentToMatchingReceiversOnly( applicationContext, Intent(DISMISS_ACTION), ) runCurrent() assertThat(volumePanelState!!.isVisible).isFalse() assertThat(volumePanelGlobalStateRepository.globalState.value.isVisible).isFalse() } } Loading