Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/sliders/domain/interactor/VolumeDialogSliderInteractorTest.kt 0 → 100644 +90 −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.dialog.sliders.domain.interactor import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.VolumeDialogController import com.android.systemui.plugins.fakeVolumeDialogController import com.android.systemui.testKosmos import com.android.systemui.volume.dialog.sliders.domain.model.volumeDialogSliderType import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper class VolumeDialogSliderInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var underTest: VolumeDialogSliderInteractor @Before fun setUp() { underTest = kosmos.volumeDialogSliderInteractor } @Test fun settingStreamVolume_setsActiveStream() = with(kosmos) { testScope.runTest { runCurrent() // initialize the stream model fakeVolumeDialogController.setStreamVolume(volumeDialogSliderType.audioStream, 0) val sliderModel by collectLastValue(underTest.slider) underTest.setStreamVolume(1) runCurrent() assertThat(sliderModel!!.isActive).isTrue() } } @Test fun streamVolumeIs_minMaxAreEnforced() = with(kosmos) { testScope.runTest { runCurrent() fakeVolumeDialogController.updateState { states.put( volumeDialogSliderType.audioStream, VolumeDialogController.StreamState().apply { levelMin = 0 level = 2 levelMax = 1 }, ) } val sliderModel by collectLastValue(underTest.slider) runCurrent() assertThat(sliderModel!!.level).isEqualTo(1) } } } packages/SystemUI/res/layout-land-television/volume_dialog.xml +2 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android:showDividers="middle" /> <LinearLayout android:id="@+id/volume_dialog" android:layout_width="@dimen/volume_dialog_width" android:layout_height="wrap_content" android:background="@drawable/volume_dialog_background" Loading @@ -50,9 +51,7 @@ android:layout_width="@dimen/volume_dialog_button_size" android:layout_height="@dimen/volume_dialog_button_size" /> <include android:id="@+id/volume_dialog_slider" layout="@layout/volume_dialog_slider" /> <include layout="@layout/volume_dialog_slider" /> <Button android:id="@+id/volume_dialog_settings" Loading packages/SystemUI/res/layout-land/volume_dialog.xml +2 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android:showDividers="middle" /> <LinearLayout android:id="@+id/volume_dialog" android:layout_width="@dimen/volume_dialog_width" android:layout_height="wrap_content" android:background="@drawable/volume_dialog_background" Loading @@ -50,9 +51,7 @@ android:layout_width="@dimen/volume_dialog_button_size" android:layout_height="@dimen/volume_dialog_button_size" /> <include android:id="@+id/volume_dialog_slider" layout="@layout/volume_dialog_slider" /> <include layout="@layout/volume_dialog_slider" /> <Button android:id="@+id/volume_dialog_settings" Loading packages/SystemUI/res/layout/volume_dialog.xml +2 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android:showDividers="middle" /> <LinearLayout android:id="@+id/volume_dialog" android:layout_width="@dimen/volume_dialog_width" android:layout_height="wrap_content" android:background="@drawable/volume_dialog_background" Loading @@ -50,9 +51,7 @@ android:layout_width="@dimen/volume_dialog_button_size" android:layout_height="@dimen/volume_dialog_button_size" /> <include android:id="@+id/volume_dialog_slider" layout="@layout/volume_dialog_slider" /> <include layout="@layout/volume_dialog_slider" /> <Button android:id="@+id/volume_dialog_settings" Loading packages/SystemUI/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCallbacksInteractor.kt +2 −2 Original line number Diff line number Diff line Loading @@ -105,8 +105,8 @@ constructor( scope.trySend(VolumeDialogEventModel.ShowSafetyWarning(flags)) } override fun onAccessibilityModeChanged(showA11yStream: Boolean) { scope.trySend(VolumeDialogEventModel.AccessibilityModeChanged(showA11yStream)) override fun onAccessibilityModeChanged(showA11yStream: Boolean?) { scope.trySend(VolumeDialogEventModel.AccessibilityModeChanged(showA11yStream == true)) } // Captions button is remove from the Volume Dialog Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/sliders/domain/interactor/VolumeDialogSliderInteractorTest.kt 0 → 100644 +90 −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.dialog.sliders.domain.interactor import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.VolumeDialogController import com.android.systemui.plugins.fakeVolumeDialogController import com.android.systemui.testKosmos import com.android.systemui.volume.dialog.sliders.domain.model.volumeDialogSliderType import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper class VolumeDialogSliderInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var underTest: VolumeDialogSliderInteractor @Before fun setUp() { underTest = kosmos.volumeDialogSliderInteractor } @Test fun settingStreamVolume_setsActiveStream() = with(kosmos) { testScope.runTest { runCurrent() // initialize the stream model fakeVolumeDialogController.setStreamVolume(volumeDialogSliderType.audioStream, 0) val sliderModel by collectLastValue(underTest.slider) underTest.setStreamVolume(1) runCurrent() assertThat(sliderModel!!.isActive).isTrue() } } @Test fun streamVolumeIs_minMaxAreEnforced() = with(kosmos) { testScope.runTest { runCurrent() fakeVolumeDialogController.updateState { states.put( volumeDialogSliderType.audioStream, VolumeDialogController.StreamState().apply { levelMin = 0 level = 2 levelMax = 1 }, ) } val sliderModel by collectLastValue(underTest.slider) runCurrent() assertThat(sliderModel!!.level).isEqualTo(1) } } }
packages/SystemUI/res/layout-land-television/volume_dialog.xml +2 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android:showDividers="middle" /> <LinearLayout android:id="@+id/volume_dialog" android:layout_width="@dimen/volume_dialog_width" android:layout_height="wrap_content" android:background="@drawable/volume_dialog_background" Loading @@ -50,9 +51,7 @@ android:layout_width="@dimen/volume_dialog_button_size" android:layout_height="@dimen/volume_dialog_button_size" /> <include android:id="@+id/volume_dialog_slider" layout="@layout/volume_dialog_slider" /> <include layout="@layout/volume_dialog_slider" /> <Button android:id="@+id/volume_dialog_settings" Loading
packages/SystemUI/res/layout-land/volume_dialog.xml +2 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android:showDividers="middle" /> <LinearLayout android:id="@+id/volume_dialog" android:layout_width="@dimen/volume_dialog_width" android:layout_height="wrap_content" android:background="@drawable/volume_dialog_background" Loading @@ -50,9 +51,7 @@ android:layout_width="@dimen/volume_dialog_button_size" android:layout_height="@dimen/volume_dialog_button_size" /> <include android:id="@+id/volume_dialog_slider" layout="@layout/volume_dialog_slider" /> <include layout="@layout/volume_dialog_slider" /> <Button android:id="@+id/volume_dialog_settings" Loading
packages/SystemUI/res/layout/volume_dialog.xml +2 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ android:showDividers="middle" /> <LinearLayout android:id="@+id/volume_dialog" android:layout_width="@dimen/volume_dialog_width" android:layout_height="wrap_content" android:background="@drawable/volume_dialog_background" Loading @@ -50,9 +51,7 @@ android:layout_width="@dimen/volume_dialog_button_size" android:layout_height="@dimen/volume_dialog_button_size" /> <include android:id="@+id/volume_dialog_slider" layout="@layout/volume_dialog_slider" /> <include layout="@layout/volume_dialog_slider" /> <Button android:id="@+id/volume_dialog_settings" Loading
packages/SystemUI/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCallbacksInteractor.kt +2 −2 Original line number Diff line number Diff line Loading @@ -105,8 +105,8 @@ constructor( scope.trySend(VolumeDialogEventModel.ShowSafetyWarning(flags)) } override fun onAccessibilityModeChanged(showA11yStream: Boolean) { scope.trySend(VolumeDialogEventModel.AccessibilityModeChanged(showA11yStream)) override fun onAccessibilityModeChanged(showA11yStream: Boolean?) { scope.trySend(VolumeDialogEventModel.AccessibilityModeChanged(showA11yStream == true)) } // Captions button is remove from the Volume Dialog Loading