Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt +72 −6 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ class CallChipViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel(startTimeMs = 1000, notificationIcon = mock<StatusBarIconView>()) inCallModel(startTimeMs = 1000, notificationIcon = createStatusBarIconViewOrNull()) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -147,11 +147,12 @@ class CallChipViewModelTest : SysuiTestCase() { @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON) @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chip_positiveStartTime_notifIconFlagOn_iconIsNotifIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) val notifIcon = mock<StatusBarIconView>() val notifIcon = createStatusBarIconViewOrNull() repo.setOngoingCallState(inCallModel(startTimeMs = 1000, notificationIcon = notifIcon)) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -163,6 +164,24 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(actualIcon).isEqualTo(notifIcon) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_positiveStartTime_notifIconFlagOn_cdFlagOn_iconIsNotifKeyIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel( startTimeMs = 1000, notificationIcon = createStatusBarIconViewOrNull(), notificationKey = "notifKey", ) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey")) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_positiveStartTime_notifIconAndConnectedDisplaysFlagOn_iconIsNotifIcon() = Loading Loading @@ -192,7 +211,7 @@ class CallChipViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel(startTimeMs = 0, notificationIcon = mock<StatusBarIconView>()) inCallModel(startTimeMs = 0, notificationIcon = createStatusBarIconViewOrNull()) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -207,11 +226,12 @@ class CallChipViewModelTest : SysuiTestCase() { @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON) fun chip_zeroStartTime_notifIconFlagOn_iconIsNotifIcon() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chip_zeroStartTime_notifIconFlagOn_cdFlagOff_iconIsNotifIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) val notifIcon = mock<StatusBarIconView>() val notifIcon = createStatusBarIconViewOrNull() repo.setOngoingCallState(inCallModel(startTimeMs = 0, notificationIcon = notifIcon)) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -223,9 +243,28 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(actualIcon).isEqualTo(notifIcon) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_zeroStartTime_notifIconFlagOn_cdFlagOn_iconIsNotifKeyIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel( startTimeMs = 0, notificationIcon = createStatusBarIconViewOrNull(), notificationKey = "notifKey", ) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey")) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON) fun chip_notifIconFlagOn_butNullNotifIcon_iconIsPhone() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chip_notifIconFlagOn_butNullNotifIcon_cdFlagOff_iconIsPhone() = testScope.runTest { val latest by collectLastValue(underTest.chip) Loading @@ -241,6 +280,24 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(icon.contentDescription).isNotNull() } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_notifIconFlagOn_butNullNotifIcon_iconNotifKey() = testScope.runTest { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel( startTimeMs = 1000, notificationIcon = null, notificationKey = "notifKey", ) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey")) } @Test fun chip_positiveStartTime_colorsAreThemed() = testScope.runTest { Loading Loading @@ -330,4 +387,13 @@ class CallChipViewModelTest : SysuiTestCase() { verify(kosmos.activityStarter).postStartActivityDismissingKeyguard(intent, null) } companion object { fun createStatusBarIconViewOrNull(): StatusBarIconView? = if (StatusBarConnectedDisplays.isEnabled) { null } else { mock<StatusBarIconView>() } } } packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt +49 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.notification.domain.interactor import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading Loading @@ -148,7 +149,8 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { } @Test fun notificationChip_missingStatusBarIconChipView_inConstructor_emitsNull() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_missingStatusBarIconChipView_cdFlagDisabled_inConstructor_emitsNull() = kosmos.runTest { val underTest = factory.create( Loading @@ -165,6 +167,25 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { assertThat(latest).isNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_missingStatusBarIconChipView_cdFlagEnabled_inConstructor_emitsNotNull() = kosmos.runTest { val underTest = factory.create( activeNotificationModel( key = "notif1", statusBarChipIcon = null, promotedContent = PROMOTED_CONTENT, ), 32L, ) val latest by collectLastValue(underTest.notificationChip) assertThat(latest).isNotNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_cdEnabled_missingStatusBarIconChipView_inConstructor_emitsNotNull() = Loading @@ -186,7 +207,8 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { } @Test fun notificationChip_missingStatusBarIconChipView_inSet_emitsNull() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_cdFlagDisabled_missingStatusBarIconChipView_inSet_emitsNull() = kosmos.runTest { val startingNotif = activeNotificationModel( Loading @@ -209,6 +231,31 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { assertThat(latest).isNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_cdFlagEnabled_missingStatusBarIconChipView_inSet_emitsNotNull() = kosmos.runTest { val startingNotif = activeNotificationModel( key = "notif1", statusBarChipIcon = mock(), promotedContent = PROMOTED_CONTENT, ) val underTest = factory.create(startingNotif, 123L) val latest by collectLastValue(underTest.notificationChip) assertThat(latest).isNotNull() underTest.setNotification( activeNotificationModel( key = "notif1", statusBarChipIcon = null, promotedContent = PROMOTED_CONTENT, ) ) assertThat(latest).isNotNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_missingStatusBarIconChipView_inSet_cdEnabled_emitsNotNull() = Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/StatusBarNotificationChipsInteractorTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.core.StatusBarConnectedDisplays 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.activeNotificationListRepository Loading Loading @@ -83,7 +84,8 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() { @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) fun notificationChips_notifMissingStatusBarChipIconView_empty() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChips_notifMissingStatusBarChipIconView_cdFlagOff_empty() = kosmos.runTest { val latest by collectLastValue(underTest.notificationChips) Loading @@ -100,6 +102,25 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() { assertThat(latest).isEmpty() } @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME, StatusBarConnectedDisplays.FLAG_NAME) fun notificationChips_notifMissingStatusBarChipIconView_cdFlagOn_notEmpty() = kosmos.runTest { val latest by collectLastValue(underTest.notificationChips) setNotifs( listOf( activeNotificationModel( key = "notif", statusBarChipIcon = null, promotedContent = PromotedNotificationContentModel.Builder("notif").build(), ) ) ) assertThat(latest).isNotEmpty() } @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) fun notificationChips_onePromotedNotif_statusBarIconViewMatches() = Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +56 −26 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.kosmos.collectLastValue Loading @@ -31,6 +30,7 @@ import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.call.ui.viewmodel.CallChipViewModelTest.Companion.createStatusBarIconViewOrNull import com.android.systemui.statusbar.chips.notification.domain.interactor.statusBarNotificationChipsInteractor import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ui.model.ColorsModel Loading @@ -48,7 +48,6 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.runner.RunWith import org.mockito.kotlin.mock Loading Loading @@ -84,8 +83,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_notifMissingStatusBarChipIconView_empty() = @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY, StatusBarConnectedDisplays.FLAG_NAME) fun chips_notifMissingStatusBarChipIconView_cdFlagDisabled_empty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -102,13 +101,33 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).isEmpty() } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chips_notifMissingStatusBarChipIconView_cdFlagEnabled_notEmpty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) setNotifs( listOf( activeNotificationModel( key = "notif", statusBarChipIcon = null, promotedContent = PromotedNotificationContentModel.Builder("notif").build(), ) ) ) assertThat(latest).isNotEmpty() } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_statusBarIconViewMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val icon = mock<StatusBarIconView>() val icon = createStatusBarIconViewOrNull() setNotifs( listOf( activeNotificationModel( Loading @@ -121,8 +140,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).hasSize(1) val chip = latest!![0] assertThat(chip).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(chip.icon).isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarView(icon)) assertIsNotifChip(chip, icon, "notif") } @Test Loading Loading @@ -168,7 +186,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading @@ -187,8 +205,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { kosmos.runTest { val latest by collectLastValue(underTest.chips) val firstIcon = mock<StatusBarIconView>() val secondIcon = mock<StatusBarIconView>() val firstIcon = createStatusBarIconViewOrNull() val secondIcon = createStatusBarIconViewOrNull() setNotifs( listOf( activeNotificationModel( Loading @@ -203,15 +221,15 @@ class NotifChipsViewModelTest : SysuiTestCase() { ), activeNotificationModel( key = "notif3", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = null, ), ) ) assertThat(latest).hasSize(2) assertIsNotifChip(latest!![0], firstIcon) assertIsNotifChip(latest!![1], secondIcon) assertIsNotifChip(latest!![0], firstIcon, "notif1") assertIsNotifChip(latest!![1], secondIcon, "notif2") } @Test Loading Loading @@ -269,7 +287,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading @@ -293,7 +311,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -323,7 +341,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -353,7 +371,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -382,7 +400,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -411,7 +429,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -439,7 +457,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -467,7 +485,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -499,7 +517,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -531,7 +549,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "clickTest", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentModel.Builder("clickTest").build(), ) Loading @@ -552,9 +570,21 @@ class NotifChipsViewModelTest : SysuiTestCase() { } companion object { fun assertIsNotifChip(latest: OngoingActivityChipModel?, expectedIcon: StatusBarIconView) { assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarView(expectedIcon)) fun assertIsNotifChip( latest: OngoingActivityChipModel?, expectedIcon: StatusBarIconView?, notificationKey: String, ) { val shown = latest as OngoingActivityChipModel.Shown if (StatusBarConnectedDisplays.isEnabled) { assertThat(shown.icon) .isEqualTo( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon(notificationKey) ) } else { assertThat(latest.icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarView(expectedIcon!!)) } } fun assertIsNotifKey(latest: OngoingActivityChipModel?, expectedKey: String) { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt +32 −8 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.Me 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.view.ChipBackgroundContainer import com.android.systemui.statusbar.core.StatusBarConnectedDisplays import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.mockSystemUIDialogFactory import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository Loading Loading @@ -169,29 +170,35 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { @Test fun primaryChip_screenRecordAndShareToAppAndCastToOtherHideAndCallShown_callShown() = testScope.runTest { val notificationKey = "call" screenRecordState.value = ScreenRecordModel.DoingNothing // MediaProjection covers both share-to-app and cast-to-other-device mediaProjectionState.value = MediaProjectionState.NotProjecting callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState( inCallModel(startTimeMs = 34, notificationKey = notificationKey) ) val latest by collectLastValue(underTest.primaryChip) assertIsCallChip(latest) assertIsCallChip(latest, notificationKey) } @Test fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() = testScope.runTest { // Start with just the lowest priority chip shown callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) val callNotificationKey = "call" callRepo.setOngoingCallState( inCallModel(startTimeMs = 34, notificationKey = callNotificationKey) ) // And everything else hidden mediaProjectionState.value = MediaProjectionState.NotProjecting screenRecordState.value = ScreenRecordModel.DoingNothing val latest by collectLastValue(underTest.primaryChip) assertIsCallChip(latest) assertIsCallChip(latest, callNotificationKey) // WHEN the higher priority media projection chip is added mediaProjectionState.value = Loading @@ -218,7 +225,10 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { screenRecordState.value = ScreenRecordModel.Recording mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) val callNotificationKey = "call" callRepo.setOngoingCallState( inCallModel(startTimeMs = 34, notificationKey = callNotificationKey) ) val latest by collectLastValue(underTest.primaryChip) Loading @@ -235,7 +245,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { mediaProjectionState.value = MediaProjectionState.NotProjecting // THEN the lower priority call is used assertIsCallChip(latest) assertIsCallChip(latest, callNotificationKey) } /** Regression test for b/347726238. */ Loading Loading @@ -364,13 +374,27 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { assertThat(icon.res).isEqualTo(R.drawable.ic_present_to_all) } fun assertIsCallChip(latest: OngoingActivityChipModel?) { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) fun assertIsCallChip(latest: OngoingActivityChipModel?, notificationKey: String) { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) if (StatusBarConnectedDisplays.isEnabled) { assertNotificationIcon(latest, notificationKey) return } val icon = (((latest as OngoingActivityChipModel.Shown).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(com.android.internal.R.drawable.ic_phone) } private fun assertNotificationIcon( latest: OngoingActivityChipModel?, notificationKey: String, ) { val shown = latest as OngoingActivityChipModel.Shown val notificationIcon = shown.icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon assertThat(notificationIcon.notificationKey).isEqualTo(notificationKey) } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt +72 −6 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ class CallChipViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel(startTimeMs = 1000, notificationIcon = mock<StatusBarIconView>()) inCallModel(startTimeMs = 1000, notificationIcon = createStatusBarIconViewOrNull()) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -147,11 +147,12 @@ class CallChipViewModelTest : SysuiTestCase() { @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON) @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chip_positiveStartTime_notifIconFlagOn_iconIsNotifIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) val notifIcon = mock<StatusBarIconView>() val notifIcon = createStatusBarIconViewOrNull() repo.setOngoingCallState(inCallModel(startTimeMs = 1000, notificationIcon = notifIcon)) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -163,6 +164,24 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(actualIcon).isEqualTo(notifIcon) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_positiveStartTime_notifIconFlagOn_cdFlagOn_iconIsNotifKeyIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel( startTimeMs = 1000, notificationIcon = createStatusBarIconViewOrNull(), notificationKey = "notifKey", ) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey")) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_positiveStartTime_notifIconAndConnectedDisplaysFlagOn_iconIsNotifIcon() = Loading Loading @@ -192,7 +211,7 @@ class CallChipViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel(startTimeMs = 0, notificationIcon = mock<StatusBarIconView>()) inCallModel(startTimeMs = 0, notificationIcon = createStatusBarIconViewOrNull()) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -207,11 +226,12 @@ class CallChipViewModelTest : SysuiTestCase() { @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON) fun chip_zeroStartTime_notifIconFlagOn_iconIsNotifIcon() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chip_zeroStartTime_notifIconFlagOn_cdFlagOff_iconIsNotifIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) val notifIcon = mock<StatusBarIconView>() val notifIcon = createStatusBarIconViewOrNull() repo.setOngoingCallState(inCallModel(startTimeMs = 0, notificationIcon = notifIcon)) assertThat((latest as OngoingActivityChipModel.Shown).icon) Loading @@ -223,9 +243,28 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(actualIcon).isEqualTo(notifIcon) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_zeroStartTime_notifIconFlagOn_cdFlagOn_iconIsNotifKeyIcon() = testScope.runTest { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel( startTimeMs = 0, notificationIcon = createStatusBarIconViewOrNull(), notificationKey = "notifKey", ) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey")) } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON) fun chip_notifIconFlagOn_butNullNotifIcon_iconIsPhone() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chip_notifIconFlagOn_butNullNotifIcon_cdFlagOff_iconIsPhone() = testScope.runTest { val latest by collectLastValue(underTest.chip) Loading @@ -241,6 +280,24 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(icon.contentDescription).isNotNull() } @Test @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME) fun chip_notifIconFlagOn_butNullNotifIcon_iconNotifKey() = testScope.runTest { val latest by collectLastValue(underTest.chip) repo.setOngoingCallState( inCallModel( startTimeMs = 1000, notificationIcon = null, notificationKey = "notifKey", ) ) assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey")) } @Test fun chip_positiveStartTime_colorsAreThemed() = testScope.runTest { Loading Loading @@ -330,4 +387,13 @@ class CallChipViewModelTest : SysuiTestCase() { verify(kosmos.activityStarter).postStartActivityDismissingKeyguard(intent, null) } companion object { fun createStatusBarIconViewOrNull(): StatusBarIconView? = if (StatusBarConnectedDisplays.isEnabled) { null } else { mock<StatusBarIconView>() } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt +49 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.notification.domain.interactor import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading Loading @@ -148,7 +149,8 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { } @Test fun notificationChip_missingStatusBarIconChipView_inConstructor_emitsNull() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_missingStatusBarIconChipView_cdFlagDisabled_inConstructor_emitsNull() = kosmos.runTest { val underTest = factory.create( Loading @@ -165,6 +167,25 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { assertThat(latest).isNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_missingStatusBarIconChipView_cdFlagEnabled_inConstructor_emitsNotNull() = kosmos.runTest { val underTest = factory.create( activeNotificationModel( key = "notif1", statusBarChipIcon = null, promotedContent = PROMOTED_CONTENT, ), 32L, ) val latest by collectLastValue(underTest.notificationChip) assertThat(latest).isNotNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_cdEnabled_missingStatusBarIconChipView_inConstructor_emitsNotNull() = Loading @@ -186,7 +207,8 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { } @Test fun notificationChip_missingStatusBarIconChipView_inSet_emitsNull() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_cdFlagDisabled_missingStatusBarIconChipView_inSet_emitsNull() = kosmos.runTest { val startingNotif = activeNotificationModel( Loading @@ -209,6 +231,31 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() { assertThat(latest).isNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_cdFlagEnabled_missingStatusBarIconChipView_inSet_emitsNotNull() = kosmos.runTest { val startingNotif = activeNotificationModel( key = "notif1", statusBarChipIcon = mock(), promotedContent = PROMOTED_CONTENT, ) val underTest = factory.create(startingNotif, 123L) val latest by collectLastValue(underTest.notificationChip) assertThat(latest).isNotNull() underTest.setNotification( activeNotificationModel( key = "notif1", statusBarChipIcon = null, promotedContent = PROMOTED_CONTENT, ) ) assertThat(latest).isNotNull() } @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChip_missingStatusBarIconChipView_inSet_cdEnabled_emitsNotNull() = Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/StatusBarNotificationChipsInteractorTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.core.StatusBarConnectedDisplays 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.activeNotificationListRepository Loading Loading @@ -83,7 +84,8 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() { @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) fun notificationChips_notifMissingStatusBarChipIconView_empty() = @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun notificationChips_notifMissingStatusBarChipIconView_cdFlagOff_empty() = kosmos.runTest { val latest by collectLastValue(underTest.notificationChips) Loading @@ -100,6 +102,25 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() { assertThat(latest).isEmpty() } @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME, StatusBarConnectedDisplays.FLAG_NAME) fun notificationChips_notifMissingStatusBarChipIconView_cdFlagOn_notEmpty() = kosmos.runTest { val latest by collectLastValue(underTest.notificationChips) setNotifs( listOf( activeNotificationModel( key = "notif", statusBarChipIcon = null, promotedContent = PromotedNotificationContentModel.Builder("notif").build(), ) ) ) assertThat(latest).isNotEmpty() } @Test @EnableFlags(StatusBarNotifChips.FLAG_NAME) fun notificationChips_onePromotedNotif_statusBarIconViewMatches() = Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +56 −26 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.kosmos.collectLastValue Loading @@ -31,6 +30,7 @@ import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.chips.call.ui.viewmodel.CallChipViewModelTest.Companion.createStatusBarIconViewOrNull import com.android.systemui.statusbar.chips.notification.domain.interactor.statusBarNotificationChipsInteractor import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips import com.android.systemui.statusbar.chips.ui.model.ColorsModel Loading @@ -48,7 +48,6 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.runner.RunWith import org.mockito.kotlin.mock Loading Loading @@ -84,8 +83,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_notifMissingStatusBarChipIconView_empty() = @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY, StatusBarConnectedDisplays.FLAG_NAME) fun chips_notifMissingStatusBarChipIconView_cdFlagDisabled_empty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -102,13 +101,33 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).isEmpty() } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) fun chips_notifMissingStatusBarChipIconView_cdFlagEnabled_notEmpty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) setNotifs( listOf( activeNotificationModel( key = "notif", statusBarChipIcon = null, promotedContent = PromotedNotificationContentModel.Builder("notif").build(), ) ) ) assertThat(latest).isNotEmpty() } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_statusBarIconViewMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val icon = mock<StatusBarIconView>() val icon = createStatusBarIconViewOrNull() setNotifs( listOf( activeNotificationModel( Loading @@ -121,8 +140,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).hasSize(1) val chip = latest!![0] assertThat(chip).isInstanceOf(OngoingActivityChipModel.Shown::class.java) assertThat(chip.icon).isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarView(icon)) assertIsNotifChip(chip, icon, "notif") } @Test Loading Loading @@ -168,7 +186,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading @@ -187,8 +205,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { kosmos.runTest { val latest by collectLastValue(underTest.chips) val firstIcon = mock<StatusBarIconView>() val secondIcon = mock<StatusBarIconView>() val firstIcon = createStatusBarIconViewOrNull() val secondIcon = createStatusBarIconViewOrNull() setNotifs( listOf( activeNotificationModel( Loading @@ -203,15 +221,15 @@ class NotifChipsViewModelTest : SysuiTestCase() { ), activeNotificationModel( key = "notif3", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = null, ), ) ) assertThat(latest).hasSize(2) assertIsNotifChip(latest!![0], firstIcon) assertIsNotifChip(latest!![1], secondIcon) assertIsNotifChip(latest!![0], firstIcon, "notif1") assertIsNotifChip(latest!![1], secondIcon, "notif2") } @Test Loading Loading @@ -269,7 +287,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading @@ -293,7 +311,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -323,7 +341,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -353,7 +371,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -382,7 +400,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -411,7 +429,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -439,7 +457,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -467,7 +485,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -499,7 +517,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = promotedContentBuilder.build(), ) ) Loading Loading @@ -531,7 +549,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { listOf( activeNotificationModel( key = "clickTest", statusBarChipIcon = mock<StatusBarIconView>(), statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentModel.Builder("clickTest").build(), ) Loading @@ -552,9 +570,21 @@ class NotifChipsViewModelTest : SysuiTestCase() { } companion object { fun assertIsNotifChip(latest: OngoingActivityChipModel?, expectedIcon: StatusBarIconView) { assertThat((latest as OngoingActivityChipModel.Shown).icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarView(expectedIcon)) fun assertIsNotifChip( latest: OngoingActivityChipModel?, expectedIcon: StatusBarIconView?, notificationKey: String, ) { val shown = latest as OngoingActivityChipModel.Shown if (StatusBarConnectedDisplays.isEnabled) { assertThat(shown.icon) .isEqualTo( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon(notificationKey) ) } else { assertThat(latest.icon) .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarView(expectedIcon!!)) } } fun assertIsNotifKey(latest: OngoingActivityChipModel?, expectedKey: String) { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt +32 −8 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.Me 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.view.ChipBackgroundContainer import com.android.systemui.statusbar.core.StatusBarConnectedDisplays import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.mockSystemUIDialogFactory import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository Loading Loading @@ -169,29 +170,35 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { @Test fun primaryChip_screenRecordAndShareToAppAndCastToOtherHideAndCallShown_callShown() = testScope.runTest { val notificationKey = "call" screenRecordState.value = ScreenRecordModel.DoingNothing // MediaProjection covers both share-to-app and cast-to-other-device mediaProjectionState.value = MediaProjectionState.NotProjecting callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) callRepo.setOngoingCallState( inCallModel(startTimeMs = 34, notificationKey = notificationKey) ) val latest by collectLastValue(underTest.primaryChip) assertIsCallChip(latest) assertIsCallChip(latest, notificationKey) } @Test fun primaryChip_higherPriorityChipAdded_lowerPriorityChipReplaced() = testScope.runTest { // Start with just the lowest priority chip shown callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) val callNotificationKey = "call" callRepo.setOngoingCallState( inCallModel(startTimeMs = 34, notificationKey = callNotificationKey) ) // And everything else hidden mediaProjectionState.value = MediaProjectionState.NotProjecting screenRecordState.value = ScreenRecordModel.DoingNothing val latest by collectLastValue(underTest.primaryChip) assertIsCallChip(latest) assertIsCallChip(latest, callNotificationKey) // WHEN the higher priority media projection chip is added mediaProjectionState.value = Loading @@ -218,7 +225,10 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { screenRecordState.value = ScreenRecordModel.Recording mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) callRepo.setOngoingCallState(inCallModel(startTimeMs = 34)) val callNotificationKey = "call" callRepo.setOngoingCallState( inCallModel(startTimeMs = 34, notificationKey = callNotificationKey) ) val latest by collectLastValue(underTest.primaryChip) Loading @@ -235,7 +245,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { mediaProjectionState.value = MediaProjectionState.NotProjecting // THEN the lower priority call is used assertIsCallChip(latest) assertIsCallChip(latest, callNotificationKey) } /** Regression test for b/347726238. */ Loading Loading @@ -364,13 +374,27 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { assertThat(icon.res).isEqualTo(R.drawable.ic_present_to_all) } fun assertIsCallChip(latest: OngoingActivityChipModel?) { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) fun assertIsCallChip(latest: OngoingActivityChipModel?, notificationKey: String) { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) if (StatusBarConnectedDisplays.isEnabled) { assertNotificationIcon(latest, notificationKey) return } val icon = (((latest as OngoingActivityChipModel.Shown).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(com.android.internal.R.drawable.ic_phone) } private fun assertNotificationIcon( latest: OngoingActivityChipModel?, notificationKey: String, ) { val shown = latest as OngoingActivityChipModel.Shown val notificationIcon = shown.icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon assertThat(notificationIcon.notificationKey).isEqualTo(notificationKey) } } }