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

Commit 08cfc5f3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix flaky test"

parents 0dbd37be 23c9b1f2
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.mock
import org.mockito.Mockito.`when` as whenever

@SmallTest
@RunWith(AndroidTestingRunner::class)
@@ -52,18 +53,20 @@ class NotificationRankingManagerTest : SysuiTestCase() {
    }
    private lateinit var personNotificationIdentifier: PeopleNotificationIdentifier
    private lateinit var rankingManager: TestableNotificationRankingManager
    private lateinit var sectionsManager: NotificationSectionsFeatureManager

    @Before
    fun setup() {
        personNotificationIdentifier =
                mock(PeopleNotificationIdentifier::class.java)
        sectionsManager = mock(NotificationSectionsFeatureManager::class.java)
        rankingManager = TestableNotificationRankingManager(
                lazyMedia,
                mock(NotificationGroupManager::class.java),
                mock(HeadsUpManager::class.java),
                mock(NotificationFilter::class.java),
                mock(NotificationEntryManagerLogger::class.java),
                mock(NotificationSectionsFeatureManager::class.java),
                sectionsManager,
                personNotificationIdentifier,
                HighPriorityProvider(personNotificationIdentifier)
        )
@@ -146,39 +149,42 @@ class NotificationRankingManagerTest : SysuiTestCase() {

    @Test
    fun testSort_importantPeople() {
        whenever(sectionsManager.isFilteringEnabled()).thenReturn(true)
        val aN = Notification.Builder(mContext, "test")
                .setStyle(Notification.MessagingStyle(""))
                .build()
        val aC = NotificationChannel("test", "", IMPORTANCE_DEFAULT)
        aC.setConversationId("parent", "convo")
        val a = NotificationEntryBuilder()
                .setImportance(IMPORTANCE_HIGH)
                .setPkg("pkg")
                .setOpPkg("pkg")
                .setTag("tag")
                .setNotification(aN)
                .setChannel(aC)
                .setChannel(NotificationChannel("test", "", IMPORTANCE_DEFAULT))
                .setUser(mContext.getUser())
                .setOverrideGroupKey("")
                .build()
        whenever(personNotificationIdentifier.isImportantPeopleNotification(a.sbn, a.ranking))
                .thenReturn(false)
        whenever(personNotificationIdentifier.isPeopleNotification(a.sbn, a.ranking))
                .thenReturn(true)

        val bN = Notification.Builder(mContext, "test")
                .setStyle(Notification.MessagingStyle(""))
                .build()
        val bC = NotificationChannel("test", "", IMPORTANCE_DEFAULT)
        bC.setConversationId("parent", "convo")
        bC.setImportantConversation(true)
        val b = NotificationEntryBuilder()
                .setImportance(IMPORTANCE_HIGH)
                .setPkg("pkg2")
                .setOpPkg("pkg2")
                .setTag("tag")
                .setNotification(bN)
                .setChannel(bC)
                .setChannel(NotificationChannel("test", "", IMPORTANCE_DEFAULT))
                .setUser(mContext.getUser())
                .setOverrideGroupKey("")
                .build()

        whenever(personNotificationIdentifier.isImportantPeopleNotification(a.sbn, a.ranking))
                .thenReturn(false)
        whenever(personNotificationIdentifier.isPeopleNotification(a.sbn, a.ranking))
                .thenReturn(true)

        assertEquals(
                listOf(b, a),