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

Commit 318b60a8 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Notif] HeadsUpManagerImplTest: Move "has HUNs?"-related tests.

Bug: 378142453
Flag: EXEMPT refactor
Test: atest HeadsUpManagerImplOldTest HeadsUpManagerImplTest
Change-Id: Id7ce26cb317dd18490d0f41130545c6d470a2d50
parent 9691b18b
Loading
Loading
Loading
Loading
+0 −53
Original line number Diff line number Diff line
@@ -150,59 +150,6 @@ open class HeadsUpManagerImplOldTest(flags: FlagsParameterization?) : SysuiTestC
        Mockito.`when`(mKosmos.keyguardBypassController.bypassEnabled).thenReturn(false)
    }

    @Test
    fun testHasNotifications_headsUpManagerMapNotEmpty_true() {
        val bhum = createHeadsUpManager()
        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        bhum.showNotification(entry)

        Truth.assertThat(bhum.mHeadsUpEntryMap).isNotEmpty()
        Truth.assertThat(bhum.hasNotifications()).isTrue()
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testHasNotifications_avalancheMapNotEmpty_true() {
        val bhum = createHeadsUpManager()
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val headsUpEntry = bhum.createHeadsUpEntry(notifEntry)
        mAvalancheController!!.addToNext(headsUpEntry) {}

        Truth.assertThat(mAvalancheController!!.getWaitingEntryList()).isNotEmpty()
        Truth.assertThat(bhum.hasNotifications()).isTrue()
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testHasNotifications_false() {
        val bhum = createHeadsUpManager()
        Truth.assertThat(bhum.mHeadsUpEntryMap).isEmpty()
        Truth.assertThat(mAvalancheController!!.getWaitingEntryList()).isEmpty()
        Truth.assertThat(bhum.hasNotifications()).isFalse()
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testGetHeadsUpEntryList_includesAvalancheEntryList() {
        val bhum = createHeadsUpManager()
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val headsUpEntry = bhum.createHeadsUpEntry(notifEntry)
        mAvalancheController!!.addToNext(headsUpEntry) {}

        Truth.assertThat(bhum.headsUpEntryList).contains(headsUpEntry)
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testGetHeadsUpEntry_returnsAvalancheEntry() {
        val bhum = createHeadsUpManager()
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val headsUpEntry = bhum.createHeadsUpEntry(notifEntry)
        mAvalancheController!!.addToNext(headsUpEntry) {}

        Truth.assertThat(bhum.getHeadsUpEntry(notifEntry.key)).isEqualTo(headsUpEntry)
    }

    @Test
    fun testShowNotification_addsEntry() {
        val alm = createHeadsUpManager()
+49 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.systemui.statusbar.sysuiStatusBarStateController
import com.android.systemui.testKosmos
import com.android.systemui.util.concurrency.mockExecutorHandler
import com.android.systemui.util.kotlin.JavaAdapter
import com.google.common.truth.Truth
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Ignore
@@ -134,6 +135,54 @@ class HeadsUpManagerImplTest(flags: FlagsParameterization) : HeadsUpManagerImplO
            )
    }

    @Test
    fun testHasNotifications_headsUpManagerMapNotEmpty_true() {
        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        underTest.showNotification(entry)

        assertThat(underTest.mHeadsUpEntryMap).isNotEmpty()
        assertThat(underTest.hasNotifications()).isTrue()
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testHasNotifications_avalancheMapNotEmpty_true() {
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val headsUpEntry = underTest.createHeadsUpEntry(notifEntry)
        avalancheController.addToNext(headsUpEntry) {}

        assertThat(avalancheController.getWaitingEntryList()).isNotEmpty()
        assertThat(underTest.hasNotifications()).isTrue()
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testHasNotifications_false() {
        assertThat(underTest.mHeadsUpEntryMap).isEmpty()
        assertThat(avalancheController.getWaitingEntryList()).isEmpty()
        assertThat(underTest.hasNotifications()).isFalse()
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testGetHeadsUpEntryList_includesAvalancheEntryList() {
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val headsUpEntry = underTest.createHeadsUpEntry(notifEntry)
        avalancheController.addToNext(headsUpEntry) {}

        assertThat(underTest.headsUpEntryList).contains(headsUpEntry)
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testGetHeadsUpEntry_returnsAvalancheEntry() {
        val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)
        val headsUpEntry = underTest.createHeadsUpEntry(notifEntry)
        avalancheController.addToNext(headsUpEntry) {}

        assertThat(underTest.getHeadsUpEntry(notifEntry.key)).isEqualTo(headsUpEntry)
    }

    @Test
    fun testSnooze() {
        val entry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext)