Loading packages/SystemUI/aconfig/systemui.aconfig +2 −2 Original line number Original line Diff line number Diff line Loading @@ -421,9 +421,9 @@ flag { } } flag { flag { name: "status_bar_notification_chips" name: "status_bar_ron_chips" namespace: "systemui" namespace: "systemui" description: "Show promoted ongoing notifications as chips in the status bar" description: "Show rich ongoing notifications as chips in the status bar" bug: "361346412" bug: "361346412" } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +3 −2 Original line number Original line Diff line number Diff line Loading @@ -19,11 +19,12 @@ package com.android.systemui.statusbar.chips.notification.ui.viewmodel import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ron.ui.viewmodel.notifChipsViewModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore Loading @@ -41,7 +42,7 @@ import org.mockito.kotlin.mock @SmallTest @SmallTest @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class) @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) class NotifChipsViewModelTest : SysuiTestCase() { class NotifChipsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testScope = kosmos.testScope Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/demo/ui/viewmodel/DemoNotifChipViewModelTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ron/demo/ui/viewmodel/DemoRonChipViewModelTest.kt +21 −21 Original line number Original line Diff line number Diff line Loading @@ -14,17 +14,17 @@ * limitations under the License. * limitations under the License. */ */ package com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel package com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel import android.content.packageManager import android.content.packageManager import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.commandline.CommandRegistry Loading @@ -40,13 +40,13 @@ import org.mockito.kotlin.any import org.mockito.kotlin.whenever import org.mockito.kotlin.whenever @SmallTest @SmallTest class DemoNotifChipViewModelTest : SysuiTestCase() { class DemoRonChipViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testScope = kosmos.testScope private val commandRegistry = kosmos.commandRegistry private val commandRegistry = kosmos.commandRegistry private val pw = PrintWriter(StringWriter()) private val pw = PrintWriter(StringWriter()) private val underTest = kosmos.demoNotifChipViewModel private val underTest = kosmos.demoRonChipViewModel @Before @Before fun setUp() { fun setUp() { Loading @@ -56,61 +56,61 @@ class DemoNotifChipViewModelTest : SysuiTestCase() { } } @Test @Test @DisableFlags(StatusBarNotifChips.FLAG_NAME) @DisableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_flagOff_hidden() = fun chip_flagOff_hidden() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) addDemoNotifChip() addDemoRonChip() assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_noPackage_hidden() = fun chip_noPackage_hidden() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand(pw, arrayOf("demo-notif")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron")) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_hasPackage_shown() = fun chip_hasPackage_shown() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand(pw, arrayOf("demo-notif", "-p", "com.android.systemui")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron", "-p", "com.android.systemui")) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_hasText_shownWithText() = fun chip_hasText_shownWithText() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand( commandRegistry.onShellCommand( pw, pw, arrayOf("demo-notif", "-p", "com.android.systemui", "-t", "test"), arrayOf("demo-ron", "-p", "com.android.systemui", "-t", "test") ) ) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Text::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Text::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_supportsColor() = fun chip_supportsColor() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand( commandRegistry.onShellCommand( pw, pw, arrayOf("demo-notif", "-p", "com.android.systemui", "-c", "#434343"), arrayOf("demo-ron", "-p", "com.android.systemui", "-c", "#434343") ) ) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) Loading @@ -119,28 +119,28 @@ class DemoNotifChipViewModelTest : SysuiTestCase() { } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_hasHideArg_hidden() = fun chip_hasHideArg_hidden() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) // First, show a chip // First, show a chip addDemoNotifChip() addDemoRonChip() assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) // Then, hide the chip // Then, hide the chip commandRegistry.onShellCommand(pw, arrayOf("demo-notif", "--hide")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron", "--hide")) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } private fun addDemoNotifChip() { private fun addDemoRonChip() { addDemoNotifChip(commandRegistry, pw) Companion.addDemoRonChip(commandRegistry, pw) } } companion object { companion object { fun addDemoNotifChip(commandRegistry: CommandRegistry, pw: PrintWriter) { fun addDemoRonChip(commandRegistry: CommandRegistry, pw: PrintWriter) { commandRegistry.onShellCommand(pw, arrayOf("demo-notif", "-p", "com.android.systemui")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron", "-p", "com.android.systemui")) } } } } } } packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt +9 −7 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.platform.test.annotations.DisableFlags import android.view.View import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Icon import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue Loading @@ -39,8 +40,7 @@ import com.android.systemui.screenrecord.data.model.ScreenRecordModel import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel.demoNotifChipViewModel import com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel.demoRonChipViewModel import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.SystemUIDialog Loading @@ -66,11 +66,13 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.mockito.kotlin.whenever /** Tests for [OngoingActivityChipsViewModel] when the [StatusBarNotifChips] flag is disabled. */ /** * Tests for [OngoingActivityChipsViewModel] when the [FLAG_STATUS_BAR_RON_CHIPS] flag is disabled. */ @SmallTest @SmallTest @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class) @DisableFlags(StatusBarNotifChips.FLAG_NAME) @DisableFlags(FLAG_STATUS_BAR_RON_CHIPS) class OngoingActivityChipsViewModelTest : SysuiTestCase() { class OngoingActivityChipsViewModelTest : SysuiTestCase() { private val kosmos = Kosmos().also { it.testCase = this } private val kosmos = Kosmos().also { it.testCase = this } private val testScope = kosmos.testScope private val testScope = kosmos.testScope Loading @@ -97,11 +99,11 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { setUpPackageManagerForMediaProjection(kosmos) setUpPackageManagerForMediaProjection(kosmos) kosmos.demoNotifChipViewModel.start() kosmos.demoRonChipViewModel.start() val icon = val icon = BitmapDrawable( BitmapDrawable( context.resources, context.resources, Bitmap.createBitmap(/* width= */ 100, /* height= */ 100, Bitmap.Config.ARGB_8888), Bitmap.createBitmap(/* width= */ 100, /* height= */ 100, Bitmap.Config.ARGB_8888) ) ) whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) } } Loading Loading @@ -323,7 +325,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { latest: OngoingActivityChipModel?, latest: OngoingActivityChipModel?, chipView: View, chipView: View, dialog: SystemUIDialog, dialog: SystemUIDialog, kosmos: Kosmos, kosmos: Kosmos ): DialogInterface.OnClickListener { ): DialogInterface.OnClickListener { // Capture the action that would get invoked when the user clicks "Stop" on the dialog // Capture the action that would get invoked when the user clicks "Stop" on the dialog lateinit var dialogStopAction: DialogInterface.OnClickListener lateinit var dialogStopAction: DialogInterface.OnClickListener Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithNotifsViewModelTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithRonsViewModelTest.kt +27 −25 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.platform.test.annotations.EnableFlags import android.view.View import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope Loading @@ -36,10 +37,9 @@ import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel.DemoNotifChipViewModelTest.Companion.addDemoNotifChip import com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel.demoNotifChipViewModel import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.notification.ui.viewmodel.NotifChipsViewModelTest.Companion.assertIsNotifChip import com.android.systemui.statusbar.chips.notification.ui.viewmodel.NotifChipsViewModelTest.Companion.assertIsNotifChip import com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel.DemoRonChipViewModelTest.Companion.addDemoRonChip import com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel.demoRonChipViewModel import com.android.systemui.statusbar.chips.ui.model.MultipleOngoingActivityChipsModel import com.android.systemui.statusbar.chips.ui.model.MultipleOngoingActivityChipsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer Loading Loading @@ -73,12 +73,14 @@ import org.mockito.kotlin.any import org.mockito.kotlin.mock import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import org.mockito.kotlin.whenever /** Tests for [OngoingActivityChipsViewModel] when the [StatusBarNotifChips] flag is enabled. */ /** * Tests for [OngoingActivityChipsViewModel] when the [FLAG_STATUS_BAR_RON_CHIPS] flag is enabled. */ @SmallTest @SmallTest @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class) @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { class OngoingActivityChipsWithRonsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testScope = kosmos.testScope private val systemClock = kosmos.fakeSystemClock private val systemClock = kosmos.fakeSystemClock Loading Loading @@ -108,7 +110,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { setUpPackageManagerForMediaProjection(kosmos) setUpPackageManagerForMediaProjection(kosmos) kosmos.demoNotifChipViewModel.start() kosmos.demoRonChipViewModel.start() val icon = val icon = BitmapDrawable( BitmapDrawable( context.resources, context.resources, Loading @@ -117,7 +119,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) } } // Even though the `primaryChip` flow isn't used when the notifs flag is on, still test that the // Even though the `primaryChip` flow isn't used when the RONs flag is on, still test that the // flow has the right behavior to verify that we don't break any existing functionality. // flow has the right behavior to verify that we don't break any existing functionality. @Test @Test Loading Loading @@ -254,13 +256,13 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { testScope.runTest { testScope.runTest { screenRecordState.value = ScreenRecordModel.Recording screenRecordState.value = ScreenRecordModel.Recording callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) val latest by collectLastValue(underTest.chips) val latest by collectLastValue(underTest.chips) assertIsScreenRecordChip(latest!!.primary) assertIsScreenRecordChip(latest!!.primary) assertIsCallChip(latest!!.secondary) assertIsCallChip(latest!!.secondary) // Demo notif chip is dropped // Demo RON chip is dropped } } @Test @Test Loading Loading @@ -387,7 +389,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() = fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() = testScope.runTest { testScope.runTest { // Start with just the lowest priority chip shown // Start with just the lowest priority chip shown addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) // And everything else hidden // And everything else hidden callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) mediaProjectionState.value = MediaProjectionState.NotProjecting mediaProjectionState.value = MediaProjectionState.NotProjecting Loading @@ -395,7 +397,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.primaryChip) val latest by collectLastValue(underTest.primaryChip) assertIsDemoNotifChip(latest) assertIsDemoRonChip(latest) // WHEN the higher priority call chip is added // WHEN the higher priority call chip is added callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) Loading Loading @@ -429,7 +431,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { mediaProjectionState.value = mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) val latest by collectLastValue(underTest.primaryChip) val latest by collectLastValue(underTest.primaryChip) Loading @@ -451,15 +453,15 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // WHEN the higher priority call is removed // WHEN the higher priority call is removed callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) // THEN the lower priority demo notif is used // THEN the lower priority demo RON is used assertIsDemoNotifChip(latest) assertIsDemoRonChip(latest) } } @Test @Test fun chips_movesChipsAroundAccordingToPriority() = fun chips_movesChipsAroundAccordingToPriority() = testScope.runTest { testScope.runTest { // Start with just the lowest priority chip shown // Start with just the lowest priority chip shown addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) // And everything else hidden // And everything else hidden callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) mediaProjectionState.value = MediaProjectionState.NotProjecting mediaProjectionState.value = MediaProjectionState.NotProjecting Loading @@ -467,16 +469,16 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chips) val latest by collectLastValue(underTest.chips) assertIsDemoNotifChip(latest!!.primary) assertIsDemoRonChip(latest!!.primary) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) // WHEN the higher priority call chip is added // WHEN the higher priority call chip is added callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) // THEN the higher priority call chip is used as primary and demo notif is demoted to // THEN the higher priority call chip is used as primary and demo ron is demoted to // secondary // secondary assertIsCallChip(latest!!.primary) assertIsCallChip(latest!!.primary) assertIsDemoNotifChip(latest!!.secondary) assertIsDemoRonChip(latest!!.secondary) // WHEN the higher priority media projection chip is added // WHEN the higher priority media projection chip is added mediaProjectionState.value = mediaProjectionState.value = Loading @@ -487,7 +489,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { ) ) // THEN the higher priority media projection chip is used as primary and call is demoted // THEN the higher priority media projection chip is used as primary and call is demoted // to secondary (and demo notif is dropped altogether) // to secondary (and demo RON is dropped altogether) assertIsShareToAppChip(latest!!.primary) assertIsShareToAppChip(latest!!.primary) assertIsCallChip(latest!!.secondary) assertIsCallChip(latest!!.secondary) Loading @@ -501,15 +503,15 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { screenRecordState.value = ScreenRecordModel.DoingNothing screenRecordState.value = ScreenRecordModel.DoingNothing callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) // THEN media projection and demo notif remain // THEN media projection and demo RON remain assertIsShareToAppChip(latest!!.primary) assertIsShareToAppChip(latest!!.primary) assertIsDemoNotifChip(latest!!.secondary) assertIsDemoRonChip(latest!!.secondary) // WHEN media projection is dropped // WHEN media projection is dropped mediaProjectionState.value = MediaProjectionState.NotProjecting mediaProjectionState.value = MediaProjectionState.NotProjecting // THEN demo notif is promoted to primary // THEN demo RON is promoted to primary assertIsDemoNotifChip(latest!!.primary) assertIsDemoRonChip(latest!!.primary) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } Loading Loading @@ -622,7 +624,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) } } private fun assertIsDemoNotifChip(latest: OngoingActivityChipModel?) { private fun assertIsDemoRonChip(latest: OngoingActivityChipModel?) { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat((latest as OngoingActivityChipModel.Shown).icon) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isInstanceOf(OngoingActivityChipModel.ChipIcon.FullColorAppIcon::class.java) .isInstanceOf(OngoingActivityChipModel.ChipIcon.FullColorAppIcon::class.java) Loading Loading
packages/SystemUI/aconfig/systemui.aconfig +2 −2 Original line number Original line Diff line number Diff line Loading @@ -421,9 +421,9 @@ flag { } } flag { flag { name: "status_bar_notification_chips" name: "status_bar_ron_chips" namespace: "systemui" namespace: "systemui" description: "Show promoted ongoing notifications as chips in the status bar" description: "Show rich ongoing notifications as chips in the status bar" bug: "361346412" bug: "361346412" } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +3 −2 Original line number Original line Diff line number Diff line Loading @@ -19,11 +19,12 @@ package com.android.systemui.statusbar.chips.notification.ui.viewmodel import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ron.ui.viewmodel.notifChipsViewModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore Loading @@ -41,7 +42,7 @@ import org.mockito.kotlin.mock @SmallTest @SmallTest @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class) @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) class NotifChipsViewModelTest : SysuiTestCase() { class NotifChipsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testScope = kosmos.testScope Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/demo/ui/viewmodel/DemoNotifChipViewModelTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ron/demo/ui/viewmodel/DemoRonChipViewModelTest.kt +21 −21 Original line number Original line Diff line number Diff line Loading @@ -14,17 +14,17 @@ * limitations under the License. * limitations under the License. */ */ package com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel package com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel import android.content.packageManager import android.content.packageManager import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.commandline.CommandRegistry Loading @@ -40,13 +40,13 @@ import org.mockito.kotlin.any import org.mockito.kotlin.whenever import org.mockito.kotlin.whenever @SmallTest @SmallTest class DemoNotifChipViewModelTest : SysuiTestCase() { class DemoRonChipViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testScope = kosmos.testScope private val commandRegistry = kosmos.commandRegistry private val commandRegistry = kosmos.commandRegistry private val pw = PrintWriter(StringWriter()) private val pw = PrintWriter(StringWriter()) private val underTest = kosmos.demoNotifChipViewModel private val underTest = kosmos.demoRonChipViewModel @Before @Before fun setUp() { fun setUp() { Loading @@ -56,61 +56,61 @@ class DemoNotifChipViewModelTest : SysuiTestCase() { } } @Test @Test @DisableFlags(StatusBarNotifChips.FLAG_NAME) @DisableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_flagOff_hidden() = fun chip_flagOff_hidden() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) addDemoNotifChip() addDemoRonChip() assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_noPackage_hidden() = fun chip_noPackage_hidden() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand(pw, arrayOf("demo-notif")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron")) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_hasPackage_shown() = fun chip_hasPackage_shown() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand(pw, arrayOf("demo-notif", "-p", "com.android.systemui")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron", "-p", "com.android.systemui")) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_hasText_shownWithText() = fun chip_hasText_shownWithText() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand( commandRegistry.onShellCommand( pw, pw, arrayOf("demo-notif", "-p", "com.android.systemui", "-t", "test"), arrayOf("demo-ron", "-p", "com.android.systemui", "-t", "test") ) ) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Text::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Text::class.java) } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_supportsColor() = fun chip_supportsColor() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) commandRegistry.onShellCommand( commandRegistry.onShellCommand( pw, pw, arrayOf("demo-notif", "-p", "com.android.systemui", "-c", "#434343"), arrayOf("demo-ron", "-p", "com.android.systemui", "-c", "#434343") ) ) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) Loading @@ -119,28 +119,28 @@ class DemoNotifChipViewModelTest : SysuiTestCase() { } } @Test @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) fun chip_hasHideArg_hidden() = fun chip_hasHideArg_hidden() = testScope.runTest { testScope.runTest { val latest by collectLastValue(underTest.chip) val latest by collectLastValue(underTest.chip) // First, show a chip // First, show a chip addDemoNotifChip() addDemoRonChip() assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) // Then, hide the chip // Then, hide the chip commandRegistry.onShellCommand(pw, arrayOf("demo-notif", "--hide")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron", "--hide")) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } private fun addDemoNotifChip() { private fun addDemoRonChip() { addDemoNotifChip(commandRegistry, pw) Companion.addDemoRonChip(commandRegistry, pw) } } companion object { companion object { fun addDemoNotifChip(commandRegistry: CommandRegistry, pw: PrintWriter) { fun addDemoRonChip(commandRegistry: CommandRegistry, pw: PrintWriter) { commandRegistry.onShellCommand(pw, arrayOf("demo-notif", "-p", "com.android.systemui")) commandRegistry.onShellCommand(pw, arrayOf("demo-ron", "-p", "com.android.systemui")) } } } } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt +9 −7 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.platform.test.annotations.DisableFlags import android.view.View import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Icon import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue Loading @@ -39,8 +40,7 @@ import com.android.systemui.screenrecord.data.model.ScreenRecordModel import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel.demoNotifChipViewModel import com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel.demoRonChipViewModel import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.SystemUIDialog Loading @@ -66,11 +66,13 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.mockito.kotlin.whenever /** Tests for [OngoingActivityChipsViewModel] when the [StatusBarNotifChips] flag is disabled. */ /** * Tests for [OngoingActivityChipsViewModel] when the [FLAG_STATUS_BAR_RON_CHIPS] flag is disabled. */ @SmallTest @SmallTest @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class) @DisableFlags(StatusBarNotifChips.FLAG_NAME) @DisableFlags(FLAG_STATUS_BAR_RON_CHIPS) class OngoingActivityChipsViewModelTest : SysuiTestCase() { class OngoingActivityChipsViewModelTest : SysuiTestCase() { private val kosmos = Kosmos().also { it.testCase = this } private val kosmos = Kosmos().also { it.testCase = this } private val testScope = kosmos.testScope private val testScope = kosmos.testScope Loading @@ -97,11 +99,11 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { setUpPackageManagerForMediaProjection(kosmos) setUpPackageManagerForMediaProjection(kosmos) kosmos.demoNotifChipViewModel.start() kosmos.demoRonChipViewModel.start() val icon = val icon = BitmapDrawable( BitmapDrawable( context.resources, context.resources, Bitmap.createBitmap(/* width= */ 100, /* height= */ 100, Bitmap.Config.ARGB_8888), Bitmap.createBitmap(/* width= */ 100, /* height= */ 100, Bitmap.Config.ARGB_8888) ) ) whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) } } Loading Loading @@ -323,7 +325,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { latest: OngoingActivityChipModel?, latest: OngoingActivityChipModel?, chipView: View, chipView: View, dialog: SystemUIDialog, dialog: SystemUIDialog, kosmos: Kosmos, kosmos: Kosmos ): DialogInterface.OnClickListener { ): DialogInterface.OnClickListener { // Capture the action that would get invoked when the user clicks "Stop" on the dialog // Capture the action that would get invoked when the user clicks "Stop" on the dialog lateinit var dialogStopAction: DialogInterface.OnClickListener lateinit var dialogStopAction: DialogInterface.OnClickListener Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithNotifsViewModelTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithRonsViewModelTest.kt +27 −25 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.platform.test.annotations.EnableFlags import android.view.View import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_STATUS_BAR_RON_CHIPS import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope Loading @@ -36,10 +37,9 @@ import com.android.systemui.screenrecord.data.repository.screenRecordRepository import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection import com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel.DemoNotifChipViewModelTest.Companion.addDemoNotifChip import com.android.systemui.statusbar.chips.notification.demo.ui.viewmodel.demoNotifChipViewModel import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.notification.ui.viewmodel.NotifChipsViewModelTest.Companion.assertIsNotifChip import com.android.systemui.statusbar.chips.notification.ui.viewmodel.NotifChipsViewModelTest.Companion.assertIsNotifChip import com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel.DemoRonChipViewModelTest.Companion.addDemoRonChip import com.android.systemui.statusbar.chips.ron.demo.ui.viewmodel.demoRonChipViewModel import com.android.systemui.statusbar.chips.ui.model.MultipleOngoingActivityChipsModel import com.android.systemui.statusbar.chips.ui.model.MultipleOngoingActivityChipsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer Loading Loading @@ -73,12 +73,14 @@ import org.mockito.kotlin.any import org.mockito.kotlin.mock import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import org.mockito.kotlin.whenever /** Tests for [OngoingActivityChipsViewModel] when the [StatusBarNotifChips] flag is enabled. */ /** * Tests for [OngoingActivityChipsViewModel] when the [FLAG_STATUS_BAR_RON_CHIPS] flag is enabled. */ @SmallTest @SmallTest @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class) @EnableFlags(StatusBarNotifChips.FLAG_NAME) @EnableFlags(FLAG_STATUS_BAR_RON_CHIPS) class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { class OngoingActivityChipsWithRonsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val testScope = kosmos.testScope private val systemClock = kosmos.fakeSystemClock private val systemClock = kosmos.fakeSystemClock Loading Loading @@ -108,7 +110,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { setUpPackageManagerForMediaProjection(kosmos) setUpPackageManagerForMediaProjection(kosmos) kosmos.demoNotifChipViewModel.start() kosmos.demoRonChipViewModel.start() val icon = val icon = BitmapDrawable( BitmapDrawable( context.resources, context.resources, Loading @@ -117,7 +119,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) whenever(kosmos.packageManager.getApplicationIcon(any<String>())).thenReturn(icon) } } // Even though the `primaryChip` flow isn't used when the notifs flag is on, still test that the // Even though the `primaryChip` flow isn't used when the RONs flag is on, still test that the // flow has the right behavior to verify that we don't break any existing functionality. // flow has the right behavior to verify that we don't break any existing functionality. @Test @Test Loading Loading @@ -254,13 +256,13 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { testScope.runTest { testScope.runTest { screenRecordState.value = ScreenRecordModel.Recording screenRecordState.value = ScreenRecordModel.Recording callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) val latest by collectLastValue(underTest.chips) val latest by collectLastValue(underTest.chips) assertIsScreenRecordChip(latest!!.primary) assertIsScreenRecordChip(latest!!.primary) assertIsCallChip(latest!!.secondary) assertIsCallChip(latest!!.secondary) // Demo notif chip is dropped // Demo RON chip is dropped } } @Test @Test Loading Loading @@ -387,7 +389,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() = fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() = testScope.runTest { testScope.runTest { // Start with just the lowest priority chip shown // Start with just the lowest priority chip shown addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) // And everything else hidden // And everything else hidden callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) mediaProjectionState.value = MediaProjectionState.NotProjecting mediaProjectionState.value = MediaProjectionState.NotProjecting Loading @@ -395,7 +397,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.primaryChip) val latest by collectLastValue(underTest.primaryChip) assertIsDemoNotifChip(latest) assertIsDemoRonChip(latest) // WHEN the higher priority call chip is added // WHEN the higher priority call chip is added callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) Loading Loading @@ -429,7 +431,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { mediaProjectionState.value = mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) val latest by collectLastValue(underTest.primaryChip) val latest by collectLastValue(underTest.primaryChip) Loading @@ -451,15 +453,15 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // WHEN the higher priority call is removed // WHEN the higher priority call is removed callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) // THEN the lower priority demo notif is used // THEN the lower priority demo RON is used assertIsDemoNotifChip(latest) assertIsDemoRonChip(latest) } } @Test @Test fun chips_movesChipsAroundAccordingToPriority() = fun chips_movesChipsAroundAccordingToPriority() = testScope.runTest { testScope.runTest { // Start with just the lowest priority chip shown // Start with just the lowest priority chip shown addDemoNotifChip(commandRegistry, pw) addDemoRonChip(commandRegistry, pw) // And everything else hidden // And everything else hidden callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) mediaProjectionState.value = MediaProjectionState.NotProjecting mediaProjectionState.value = MediaProjectionState.NotProjecting Loading @@ -467,16 +469,16 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chips) val latest by collectLastValue(underTest.chips) assertIsDemoNotifChip(latest!!.primary) assertIsDemoRonChip(latest!!.primary) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) // WHEN the higher priority call chip is added // WHEN the higher priority call chip is added callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) // THEN the higher priority call chip is used as primary and demo notif is demoted to // THEN the higher priority call chip is used as primary and demo ron is demoted to // secondary // secondary assertIsCallChip(latest!!.primary) assertIsCallChip(latest!!.primary) assertIsDemoNotifChip(latest!!.secondary) assertIsDemoRonChip(latest!!.secondary) // WHEN the higher priority media projection chip is added // WHEN the higher priority media projection chip is added mediaProjectionState.value = mediaProjectionState.value = Loading @@ -487,7 +489,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { ) ) // THEN the higher priority media projection chip is used as primary and call is demoted // THEN the higher priority media projection chip is used as primary and call is demoted // to secondary (and demo notif is dropped altogether) // to secondary (and demo RON is dropped altogether) assertIsShareToAppChip(latest!!.primary) assertIsShareToAppChip(latest!!.primary) assertIsCallChip(latest!!.secondary) assertIsCallChip(latest!!.secondary) Loading @@ -501,15 +503,15 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { screenRecordState.value = ScreenRecordModel.DoingNothing screenRecordState.value = ScreenRecordModel.DoingNothing callRepo.setOngoingCallState(OngoingCallModel.NoCall) callRepo.setOngoingCallState(OngoingCallModel.NoCall) // THEN media projection and demo notif remain // THEN media projection and demo RON remain assertIsShareToAppChip(latest!!.primary) assertIsShareToAppChip(latest!!.primary) assertIsDemoNotifChip(latest!!.secondary) assertIsDemoRonChip(latest!!.secondary) // WHEN media projection is dropped // WHEN media projection is dropped mediaProjectionState.value = MediaProjectionState.NotProjecting mediaProjectionState.value = MediaProjectionState.NotProjecting // THEN demo notif is promoted to primary // THEN demo RON is promoted to primary assertIsDemoNotifChip(latest!!.primary) assertIsDemoRonChip(latest!!.primary) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) } } Loading Loading @@ -622,7 +624,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) } } private fun assertIsDemoNotifChip(latest: OngoingActivityChipModel?) { private fun assertIsDemoRonChip(latest: OngoingActivityChipModel?) { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat((latest as OngoingActivityChipModel.Shown).icon) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isInstanceOf(OngoingActivityChipModel.ChipIcon.FullColorAppIcon::class.java) .isInstanceOf(OngoingActivityChipModel.ChipIcon.FullColorAppIcon::class.java) Loading