Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ced6d079 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Introduce a new internal CallChipViewModel that uses `isHidden`.

This is in preparation to support return animations.

Bug: 202516970
Flag: EXEMPT moving code only
Test: atest CallChipViewModelTest OngoingActivityChipsViewModelTest OngoingActivityChipsWithNotifsViewModelTest OngoingCallInteractorTest

Change-Id: I089b4f66e17da269762e088b3f33cb4bdf9518e1
parent 6975150c
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -2110,3 +2110,10 @@ flag {
    description: "Enables moving the launching window on top of the origin window in the Animation library."
    description: "Enables moving the launching window on top of the origin window in the Animation library."
    bug: "390422470"
    bug: "390422470"
}
}

flag {
    name: "status_bar_chips_return_animations"
    namespace: "systemui"
    description: "Enables return animations for status bar chips"
    bug: "202516970"
}
+103 −6
Original line number Original line Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.systemui.statusbar.chips.call.ui.viewmodel
import android.app.PendingIntent
import android.app.PendingIntent
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 android.platform.test.flag.junit.FlagsParameterization
import android.view.View
import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.Expandable
import com.android.systemui.animation.Expandable
@@ -33,13 +33,16 @@ import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.plugins.activityStarter
import com.android.systemui.plugins.activityStarter
import com.android.systemui.res.R
import com.android.systemui.res.R
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.StatusBarChipsReturnAnimations
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.chips.ui.view.ChipBackgroundContainer
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.core.StatusBarRootModernization
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.phone.ongoingcall.DisableChipsModernization
import com.android.systemui.statusbar.phone.ongoingcall.DisableChipsModernization
import com.android.systemui.statusbar.phone.ongoingcall.EnableChipsModernization
import com.android.systemui.statusbar.phone.ongoingcall.EnableChipsModernization
import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.addOngoingCallState
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.addOngoingCallState
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.removeOngoingCallState
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.removeOngoingCallState
import com.android.systemui.testKosmos
import com.android.systemui.testKosmos
@@ -51,10 +54,16 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.mock
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
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters


@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWith(ParameterizedAndroidJunit4::class)
class CallChipViewModelTest : SysuiTestCase() {
class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
    init {
        mSetFlagsRule.setFlagsParameterization(flags)
    }

    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()


    private val chipBackgroundView = mock<ChipBackgroundContainer>()
    private val chipBackgroundView = mock<ChipBackgroundContainer>()
@@ -87,9 +96,10 @@ class CallChipViewModelTest : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)
            val latest by collectLastValue(underTest.chip)


            addOngoingCallState(startTimeMs = 0)
            addOngoingCallState(startTimeMs = 0, isAppVisible = false)


            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java)
            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse()
        }
        }


    @Test
    @Test
@@ -97,9 +107,10 @@ class CallChipViewModelTest : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)
            val latest by collectLastValue(underTest.chip)


            addOngoingCallState(startTimeMs = -2)
            addOngoingCallState(startTimeMs = -2, isAppVisible = false)


            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java)
            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse()
        }
        }


    @Test
    @Test
@@ -107,9 +118,82 @@ class CallChipViewModelTest : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)
            val latest by collectLastValue(underTest.chip)


            addOngoingCallState(startTimeMs = 345)
            addOngoingCallState(startTimeMs = 345, isAppVisible = false)


            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java)
            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).isHidden).isFalse()
        }

    @Test
    @DisableFlags(StatusBarChipsReturnAnimations.FLAG_NAME)
    fun chipLegacy_inCallWithVisibleApp_zeroStartTime_isHiddenAsInactive() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)

            addOngoingCallState(startTimeMs = 0, isAppVisible = true)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java)
        }

    @Test
    @EnableFlags(StatusBarChipsReturnAnimations.FLAG_NAME)
    @EnableChipsModernization
    fun chipWithReturnAnimation_inCallWithVisibleApp_zeroStartTime_isHiddenAsIconOnly() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)

            addOngoingCallState(startTimeMs = 0, isAppVisible = true)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).isHidden).isTrue()
        }

    @Test
    @DisableFlags(StatusBarChipsReturnAnimations.FLAG_NAME)
    fun chipLegacy_inCallWithVisibleApp_negativeStartTime_isHiddenAsInactive() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)

            addOngoingCallState(startTimeMs = -2, isAppVisible = true)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java)
        }

    @Test
    @EnableFlags(StatusBarChipsReturnAnimations.FLAG_NAME)
    @EnableChipsModernization
    fun chipWithReturnAnimation_inCallWithVisibleApp_negativeStartTime_isHiddenAsIconOnly() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)

            addOngoingCallState(startTimeMs = -2, isAppVisible = true)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).isHidden).isTrue()
        }

    @Test
    @DisableFlags(StatusBarChipsReturnAnimations.FLAG_NAME)
    fun chipLegacy_inCallWithVisibleApp_positiveStartTime_isHiddenAsInactive() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)

            addOngoingCallState(startTimeMs = 345, isAppVisible = true)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java)
        }

    @Test
    @EnableFlags(StatusBarChipsReturnAnimations.FLAG_NAME)
    @EnableChipsModernization
    fun chipWithReturnAnimation_inCallWithVisibleApp_positiveStartTime_isHiddenAsTimer() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chip)

            addOngoingCallState(startTimeMs = 345, isAppVisible = true)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).isHidden).isTrue()
        }
        }


    @Test
    @Test
@@ -418,5 +502,18 @@ class CallChipViewModelTest : SysuiTestCase() {


        private const val PROMOTED_BACKGROUND_COLOR = 65
        private const val PROMOTED_BACKGROUND_COLOR = 65
        private const val PROMOTED_PRIMARY_TEXT_COLOR = 98
        private const val PROMOTED_PRIMARY_TEXT_COLOR = 98

        @get:Parameters(name = "{0}")
        @JvmStatic
        val flags: List<FlagsParameterization>
            get() = buildList {
                addAll(
                    FlagsParameterization.allCombinationsOf(
                        StatusBarRootModernization.FLAG_NAME,
                        StatusBarChipsModernization.FLAG_NAME,
                        StatusBarChipsReturnAnimations.FLAG_NAME,
                    )
                )
            }
    }
    }
}
}
+5 −5
Original line number Original line Diff line number Diff line
@@ -137,7 +137,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording


            addOngoingCallState()
            addOngoingCallState(isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


@@ -163,7 +163,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
            screenRecordState.value = ScreenRecordModel.DoingNothing
            screenRecordState.value = ScreenRecordModel.DoingNothing
            mediaProjectionState.value =
            mediaProjectionState.value =
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
            addOngoingCallState()
            addOngoingCallState(isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


@@ -178,7 +178,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
            // MediaProjection covers both share-to-app and cast-to-other-device
            // MediaProjection covers both share-to-app and cast-to-other-device
            mediaProjectionState.value = MediaProjectionState.NotProjecting
            mediaProjectionState.value = MediaProjectionState.NotProjecting


            addOngoingCallState(key = notificationKey)
            addOngoingCallState(key = notificationKey, isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


@@ -190,7 +190,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            // Start with just the lowest priority chip shown
            // Start with just the lowest priority chip shown
            val callNotificationKey = "call"
            val callNotificationKey = "call"
            addOngoingCallState(key = callNotificationKey)
            addOngoingCallState(key = callNotificationKey, isAppVisible = false)
            // And everything else hidden
            // And everything else hidden
            mediaProjectionState.value = MediaProjectionState.NotProjecting
            mediaProjectionState.value = MediaProjectionState.NotProjecting
            screenRecordState.value = ScreenRecordModel.DoingNothing
            screenRecordState.value = ScreenRecordModel.DoingNothing
@@ -225,7 +225,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {
            mediaProjectionState.value =
            mediaProjectionState.value =
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
            val callNotificationKey = "call"
            val callNotificationKey = "call"
            addOngoingCallState(key = callNotificationKey)
            addOngoingCallState(key = callNotificationKey, isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


+17 −17
Original line number Original line Diff line number Diff line
@@ -235,7 +235,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    fun primaryChip_screenRecordShowAndCallShow_screenRecordShown() =
    fun primaryChip_screenRecordShowAndCallShow_screenRecordShown() =
        kosmos.runTest {
        kosmos.runTest {
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            addOngoingCallState("call")
            addOngoingCallState("call", isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


@@ -248,7 +248,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            val callNotificationKey = "call"
            val callNotificationKey = "call"
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            addOngoingCallState(callNotificationKey)
            addOngoingCallState(callNotificationKey, isAppVisible = false)


            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)
            val unused by collectLastValue(underTest.chips)
            val unused by collectLastValue(underTest.chips)
@@ -295,7 +295,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    @Test
    @Test
    fun chipsLegacy_oneChip_notSquished() =
    fun chipsLegacy_oneChip_notSquished() =
        kosmos.runTest {
        kosmos.runTest {
            addOngoingCallState()
            addOngoingCallState(isAppVisible = false)


            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)


@@ -322,7 +322,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    fun chipsLegacy_twoTimerChips_isSmallPortrait_bothSquished() =
    fun chipsLegacy_twoTimerChips_isSmallPortrait_bothSquished() =
        kosmos.runTest {
        kosmos.runTest {
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)


@@ -354,7 +354,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    fun chipsLegacy_countdownChipAndTimerChip_countdownNotSquished_butTimerSquished() =
    fun chipsLegacy_countdownChipAndTimerChip_countdownNotSquished_butTimerSquished() =
        kosmos.runTest {
        kosmos.runTest {
            screenRecordState.value = ScreenRecordModel.Starting(millisUntilStarted = 2000)
            screenRecordState.value = ScreenRecordModel.Starting(millisUntilStarted = 2000)
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)


@@ -400,7 +400,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
                .isInstanceOf(OngoingActivityChipModel.Inactive::class.java)
                .isInstanceOf(OngoingActivityChipModel.Inactive::class.java)


            // WHEN there's 2 chips
            // WHEN there's 2 chips
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            // THEN they both become squished
            // THEN they both become squished
            assertThat(latest!!.primary)
            assertThat(latest!!.primary)
@@ -456,7 +456,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    fun chipsLegacy_twoChips_isLandscape_notSquished() =
    fun chipsLegacy_twoChips_isLandscape_notSquished() =
        kosmos.runTest {
        kosmos.runTest {
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            // WHEN we're in landscape
            // WHEN we're in landscape
            val config =
            val config =
@@ -502,7 +502,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    fun chipsLegacy_twoChips_isLargeScreen_notSquished() =
    fun chipsLegacy_twoChips_isLargeScreen_notSquished() =
        kosmos.runTest {
        kosmos.runTest {
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            // WHEN we're on a large screen
            // WHEN we're on a large screen
            kosmos.displayStateRepository.setIsLargeScreen(true)
            kosmos.displayStateRepository.setIsLargeScreen(true)
@@ -596,7 +596,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            screenRecordState.value = ScreenRecordModel.DoingNothing
            screenRecordState.value = ScreenRecordModel.DoingNothing
            mediaProjectionState.value =
            mediaProjectionState.value =
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


@@ -611,7 +611,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            screenRecordState.value = ScreenRecordModel.DoingNothing
            screenRecordState.value = ScreenRecordModel.DoingNothing
            mediaProjectionState.value =
            mediaProjectionState.value =
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
            addOngoingCallState(key = "call")
            addOngoingCallState(key = "call", isAppVisible = false)


            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)
            val unused by collectLastValue(underTest.chips)
            val unused by collectLastValue(underTest.chips)
@@ -650,7 +650,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            mediaProjectionState.value = MediaProjectionState.NotProjecting
            mediaProjectionState.value = MediaProjectionState.NotProjecting


            val callNotificationKey = "call"
            val callNotificationKey = "call"
            addOngoingCallState(key = callNotificationKey)
            addOngoingCallState(key = callNotificationKey, isAppVisible = false)


            val latest by collectLastValue(underTest.primaryChip)
            val latest by collectLastValue(underTest.primaryChip)


@@ -666,7 +666,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            // MediaProjection covers both share-to-app and cast-to-other-device
            // MediaProjection covers both share-to-app and cast-to-other-device
            mediaProjectionState.value = MediaProjectionState.NotProjecting
            mediaProjectionState.value = MediaProjectionState.NotProjecting


            addOngoingCallState(key = callNotificationKey)
            addOngoingCallState(key = callNotificationKey, isAppVisible = false)


            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)
            val unused by collectLastValue(underTest.chips)
            val unused by collectLastValue(underTest.chips)
@@ -930,7 +930,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            val unused by collectLastValue(underTest.chips)
            val unused by collectLastValue(underTest.chips)


            val callNotificationKey = "call"
            val callNotificationKey = "call"
            addOngoingCallState(callNotificationKey)
            addOngoingCallState(callNotificationKey, isAppVisible = false)


            val firstIcon = createStatusBarIconViewOrNull()
            val firstIcon = createStatusBarIconViewOrNull()
            activeNotificationListRepository.addNotifs(
            activeNotificationListRepository.addNotifs(
@@ -1000,7 +1000,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            val latest by collectLastValue(underTest.chipsLegacy)
            val latest by collectLastValue(underTest.chipsLegacy)
            val unused by collectLastValue(underTest.chips)
            val unused by collectLastValue(underTest.chips)


            addOngoingCallState(callNotificationKey)
            addOngoingCallState(callNotificationKey, isAppVisible = false)
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            activeNotificationListRepository.addNotif(
            activeNotificationListRepository.addNotif(
                activeNotificationModel(
                activeNotificationModel(
@@ -1089,7 +1089,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            assertIsNotifChip(latest, context, notifIcon, "notif")
            assertIsNotifChip(latest, context, notifIcon, "notif")


            // WHEN the higher priority call chip is added
            // WHEN the higher priority call chip is added
            addOngoingCallState(callNotificationKey)
            addOngoingCallState(callNotificationKey, isAppVisible = false)


            // THEN the higher priority call chip is used
            // THEN the higher priority call chip is used
            assertIsCallChip(latest, callNotificationKey, context)
            assertIsCallChip(latest, callNotificationKey, context)
@@ -1120,7 +1120,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            screenRecordState.value = ScreenRecordModel.Recording
            screenRecordState.value = ScreenRecordModel.Recording
            mediaProjectionState.value =
            mediaProjectionState.value =
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)
            addOngoingCallState(callNotificationKey)
            addOngoingCallState(callNotificationKey, isAppVisible = false)
            val notifIcon = createStatusBarIconViewOrNull()
            val notifIcon = createStatusBarIconViewOrNull()
            activeNotificationListRepository.addNotif(
            activeNotificationListRepository.addNotif(
                activeNotificationModel(
                activeNotificationModel(
@@ -1182,7 +1182,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
            assertThat(unused).isEqualTo(MultipleOngoingActivityChipsModel())
            assertThat(unused).isEqualTo(MultipleOngoingActivityChipsModel())


            // WHEN the higher priority call chip is added
            // WHEN the higher priority call chip is added
            addOngoingCallState(callNotificationKey)
            addOngoingCallState(callNotificationKey, isAppVisible = false)


            // THEN the higher priority call chip is used as primary and notif is demoted to
            // THEN the higher priority call chip is used as primary and notif is demoted to
            // secondary
            // secondary
+6 −10
Original line number Original line Diff line number Diff line
@@ -82,6 +82,7 @@ class OngoingCallInteractorTest : SysuiTestCase() {
                statusBarChipIconView = testIconView,
                statusBarChipIconView = testIconView,
                contentIntent = testIntent,
                contentIntent = testIntent,
                promotedContent = testPromotedContent,
                promotedContent = testPromotedContent,
                isAppVisible = false,
            )
            )


            // Verify model is InCall and has the correct icon, intent, and promoted content.
            // Verify model is InCall and has the correct icon, intent, and promoted content.
@@ -98,7 +99,6 @@ class OngoingCallInteractorTest : SysuiTestCase() {
    @Test
    @Test
    fun ongoingCallNotification_setsAllFields_withAppVisible() =
    fun ongoingCallNotification_setsAllFields_withAppVisible() =
        kosmos.runTest {
        kosmos.runTest {
            kosmos.activityManagerRepository.fake.startingIsAppVisibleValue = true
            val latest by collectLastValue(underTest.ongoingCallState)
            val latest by collectLastValue(underTest.ongoingCallState)


            // Set up notification with icon view and intent
            // Set up notification with icon view and intent
@@ -113,6 +113,7 @@ class OngoingCallInteractorTest : SysuiTestCase() {
                statusBarChipIconView = testIconView,
                statusBarChipIconView = testIconView,
                contentIntent = testIntent,
                contentIntent = testIntent,
                promotedContent = testPromotedContent,
                promotedContent = testPromotedContent,
                isAppVisible = true,
            )
            )


            // Verify model is InCall with visible app and has the correct icon, intent, and
            // Verify model is InCall with visible app and has the correct icon, intent, and
@@ -141,10 +142,9 @@ class OngoingCallInteractorTest : SysuiTestCase() {
    @Test
    @Test
    fun ongoingCallNotification_appVisibleInitially_emitsInCallWithVisibleApp() =
    fun ongoingCallNotification_appVisibleInitially_emitsInCallWithVisibleApp() =
        kosmos.runTest {
        kosmos.runTest {
            kosmos.activityManagerRepository.fake.startingIsAppVisibleValue = true
            val latest by collectLastValue(underTest.ongoingCallState)
            val latest by collectLastValue(underTest.ongoingCallState)


            addOngoingCallState(uid = UID)
            addOngoingCallState(uid = UID, isAppVisible = true)


            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat((latest as OngoingCallModel.InCall).isAppVisible).isTrue()
            assertThat((latest as OngoingCallModel.InCall).isAppVisible).isTrue()
@@ -153,10 +153,9 @@ class OngoingCallInteractorTest : SysuiTestCase() {
    @Test
    @Test
    fun ongoingCallNotification_appNotVisibleInitially_emitsInCall() =
    fun ongoingCallNotification_appNotVisibleInitially_emitsInCall() =
        kosmos.runTest {
        kosmos.runTest {
            kosmos.activityManagerRepository.fake.startingIsAppVisibleValue = false
            val latest by collectLastValue(underTest.ongoingCallState)
            val latest by collectLastValue(underTest.ongoingCallState)


            addOngoingCallState(uid = UID)
            addOngoingCallState(uid = UID, isAppVisible = false)


            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat((latest as OngoingCallModel.InCall).isAppVisible).isFalse()
            assertThat((latest as OngoingCallModel.InCall).isAppVisible).isFalse()
@@ -168,8 +167,7 @@ class OngoingCallInteractorTest : SysuiTestCase() {
            val latest by collectLastValue(underTest.ongoingCallState)
            val latest by collectLastValue(underTest.ongoingCallState)


            // Start with notification and app not visible
            // Start with notification and app not visible
            kosmos.activityManagerRepository.fake.startingIsAppVisibleValue = false
            addOngoingCallState(uid = UID, isAppVisible = false)
            addOngoingCallState(uid = UID)
            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat((latest as OngoingCallModel.InCall).isAppVisible).isFalse()
            assertThat((latest as OngoingCallModel.InCall).isAppVisible).isFalse()


@@ -245,9 +243,7 @@ class OngoingCallInteractorTest : SysuiTestCase() {
                        .ongoingProcessRequiresStatusBarVisible
                        .ongoingProcessRequiresStatusBarVisible
                )
                )


            kosmos.activityManagerRepository.fake.startingIsAppVisibleValue = false
            addOngoingCallState(uid = UID, isAppVisible = false)

            addOngoingCallState(uid = UID)


            assertThat(ongoingCallState).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat(ongoingCallState).isInstanceOf(OngoingCallModel.InCall::class.java)
            assertThat((ongoingCallState as OngoingCallModel.InCall).isAppVisible).isFalse()
            assertThat((ongoingCallState as OngoingCallModel.InCall).isAppVisible).isFalse()
Loading