Fix flaky test

Test: this
Fixes: 149846720
Change-Id: I7087c7e21b8f29be2bdf0336da80a1f13926804a
This commit is contained in:
Julia Reynolds
2020-02-19 16:10:50 -05:00
parent 0792b12f99
commit 23c9b1f27e

View File

@@ -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),