summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-03-18 11:11:50 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-18 11:11:50 -0700
commitac720fbb8d5c52e4a9607c8e8aae4b91f19d76f4 (patch)
tree762723c8928b74f52afc62128fef7e56a74dd605
parentaa0835e28b7c77b7359817c98999544ba357edee (diff)
parent0a9108cd357c51ee56c4a82fc53495ec3c0a435d (diff)
Merge "Reset dialog timeout when warning appears" into main
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelTest.kt82
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialogPlugin.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModel.kt8
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCsdWarningInteractorKosmos.kt26
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelKosmos.kt41
5 files changed, 159 insertions, 0 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelTest.kt
new file mode 100644
index 000000000000..0847281d9b42
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelTest.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2025 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.ui.viewmodel
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.accessibility.data.repository.accessibilityRepository
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.collectLastValue
+import com.android.systemui.kosmos.runTest
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
+import com.android.systemui.volume.Events
+import com.android.systemui.volume.dialog.data.repository.volumeDialogVisibilityRepository
+import com.android.systemui.volume.dialog.domain.interactor.volumeDialogVisibilityInteractor
+import com.android.systemui.volume.dialog.shared.model.VolumeDialogVisibilityModel
+import com.google.common.truth.Truth.assertThat
+import kotlin.time.Duration.Companion.seconds
+import kotlinx.coroutines.test.advanceTimeBy
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class VolumeDialogPluginViewModelTest : SysuiTestCase() {
+
+ private val kosmos: Kosmos = testKosmos()
+
+ private val underTest: VolumeDialogPluginViewModel by lazy {
+ kosmos.volumeDialogPluginViewModel
+ }
+
+ @Before
+ fun setUp() =
+ with(kosmos) {
+ volumeDialogVisibilityRepository.updateVisibility {
+ VolumeDialogVisibilityModel.Visible(Events.SHOW_REASON_VOLUME_CHANGED, false, 0)
+ }
+ }
+
+ @Test
+ fun safetyWarningAppears_timeoutReset() =
+ kosmos.runTest {
+ accessibilityRepository.setRecommendedTimeout(3.seconds)
+ val visibility by collectLastValue(volumeDialogVisibilityInteractor.dialogVisibility)
+ testScope.advanceTimeBy(2.seconds)
+ assertThat(visibility).isInstanceOf(VolumeDialogVisibilityModel.Visible::class.java)
+
+ underTest.onSafetyWarningDialogShown()
+ testScope.advanceTimeBy(2.seconds)
+ assertThat(visibility).isInstanceOf(VolumeDialogVisibilityModel.Visible::class.java)
+ }
+
+ @Test
+ fun csdWarningAppears_timeoutReset() =
+ kosmos.runTest {
+ accessibilityRepository.setRecommendedTimeout(3.seconds)
+ val visibility by collectLastValue(volumeDialogVisibilityInteractor.dialogVisibility)
+ testScope.advanceTimeBy(2.seconds)
+ assertThat(visibility).isInstanceOf(VolumeDialogVisibilityModel.Visible::class.java)
+
+ underTest.onCsdWarningDialogShown()
+ testScope.advanceTimeBy(2.seconds)
+ assertThat(visibility).isInstanceOf(VolumeDialogVisibilityModel.Visible::class.java)
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialogPlugin.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialogPlugin.kt
index 938e313771ad..b06a3b7784f8 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialogPlugin.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialogPlugin.kt
@@ -68,6 +68,7 @@ constructor(
viewModel.isShowingSafetyWarning
.mapLatest { isShowingSafetyWarning ->
if (isShowingSafetyWarning) {
+ viewModel.onSafetyWarningDialogShown()
showSafetyWarningVisibility { viewModel.onSafetyWarningDismissed() }
}
}
@@ -76,6 +77,7 @@ constructor(
viewModel.csdWarning
.mapLatest { csdWarning ->
if (csdWarning != null) {
+ viewModel.onCsdWarningDialogShown()
showCsdWarningDialog(csdWarning, viewModel.csdWarningConfigModel.actions) {
viewModel.onCsdWarningDismissed()
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModel.kt
index 6d16300bf56e..87cc1830af28 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModel.kt
@@ -70,10 +70,18 @@ constructor(
val isShowingSafetyWarning: Flow<Boolean> = dialogSafetyWarningInteractor.isShowingSafetyWarning
val csdWarning: Flow<Int?> = dialogCsdWarningInteractor.csdWarning
+ fun onSafetyWarningDialogShown() {
+ dialogVisibilityInteractor.resetDismissTimeout()
+ }
+
fun onSafetyWarningDismissed() {
dialogSafetyWarningInteractor.onSafetyWarningDismissed()
}
+ fun onCsdWarningDialogShown() {
+ dialogVisibilityInteractor.resetDismissTimeout()
+ }
+
fun onCsdWarningDismissed() {
dialogCsdWarningInteractor.onCsdWarningDismissed()
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCsdWarningInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCsdWarningInteractorKosmos.kt
new file mode 100644
index 000000000000..fc7fc0f4e5b4
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCsdWarningInteractorKosmos.kt
@@ -0,0 +1,26 @@
+/*
+ * 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.domain.interactor
+
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.volume.dialog.shared.model.CsdWarningConfigModel
+
+val Kosmos.volumeDialogCsdWarningInteractor: VolumeDialogCsdWarningInteractor by
+ Kosmos.Fixture { VolumeDialogCsdWarningInteractor(volumeDialogStateInteractor) }
+
+val Kosmos.csdWarningConfigModel: CsdWarningConfigModel by
+ Kosmos.Fixture { CsdWarningConfigModel(emptyList()) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelKosmos.kt
new file mode 100644
index 000000000000..5a58599eaade
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogPluginViewModelKosmos.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2025 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.ui.viewmodel
+
+import com.android.internal.logging.uiEventLogger
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.backgroundScope
+import com.android.systemui.volume.dialog.domain.interactor.csdWarningConfigModel
+import com.android.systemui.volume.dialog.domain.interactor.volumeDialogCsdWarningInteractor
+import com.android.systemui.volume.dialog.domain.interactor.volumeDialogSafetyWarningInteractor
+import com.android.systemui.volume.dialog.domain.interactor.volumeDialogVisibilityInteractor
+import com.android.systemui.volume.dialog.shared.volumeDialogLogger
+import com.android.systemui.volume.dialog.volumeDialog
+
+val Kosmos.volumeDialogPluginViewModel: VolumeDialogPluginViewModel by
+ Kosmos.Fixture {
+ VolumeDialogPluginViewModel(
+ backgroundScope,
+ volumeDialogVisibilityInteractor,
+ volumeDialogSafetyWarningInteractor,
+ volumeDialogCsdWarningInteractor,
+ { volumeDialog },
+ volumeDialogLogger,
+ csdWarningConfigModel,
+ uiEventLogger,
+ )
+ }