Improve FakeActiveNotificationsProvider.
This commit is contained in:
parent
46106c96f7
commit
d55bb57fa4
2 changed files with 16 additions and 10 deletions
|
|
@ -72,7 +72,7 @@ class DefaultNotificationDrawerManagerTest {
|
||||||
// For now just call all the API. Later, add more valuable tests.
|
// For now just call all the API. Later, add more valuable tests.
|
||||||
val matrixUser = aMatrixUser(id = A_SESSION_ID.value, displayName = "alice", avatarUrl = "mxc://data")
|
val matrixUser = aMatrixUser(id = A_SESSION_ID.value, displayName = "alice", avatarUrl = "mxc://data")
|
||||||
val mockRoomGroupMessageCreator = FakeRoomGroupMessageCreator(
|
val mockRoomGroupMessageCreator = FakeRoomGroupMessageCreator(
|
||||||
createRoomMessageResult = lambdaRecorder { user, _, roomId, _, existingNotification, ->
|
createRoomMessageResult = lambdaRecorder { user, _, roomId, _, existingNotification ->
|
||||||
assertThat(user).isEqualTo(matrixUser)
|
assertThat(user).isEqualTo(matrixUser)
|
||||||
assertThat(roomId).isEqualTo(A_ROOM_ID)
|
assertThat(roomId).isEqualTo(A_ROOM_ID)
|
||||||
assertThat(existingNotification).isNull()
|
assertThat(existingNotification).isNull()
|
||||||
|
|
@ -167,11 +167,12 @@ class DefaultNotificationDrawerManagerTest {
|
||||||
}
|
}
|
||||||
val summaryId = NotificationIdProvider.getSummaryNotificationId(A_SESSION_ID)
|
val summaryId = NotificationIdProvider.getSummaryNotificationId(A_SESSION_ID)
|
||||||
val activeNotificationsProvider = FakeActiveNotificationsProvider(
|
val activeNotificationsProvider = FakeActiveNotificationsProvider(
|
||||||
mutableListOf(
|
getSummaryNotificationResult = {
|
||||||
mockk {
|
mockk {
|
||||||
every { id } returns summaryId
|
every { id } returns summaryId
|
||||||
}
|
}
|
||||||
)
|
},
|
||||||
|
countResult = { 1 },
|
||||||
)
|
)
|
||||||
val defaultNotificationDrawerManager = createDefaultNotificationDrawerManager(
|
val defaultNotificationDrawerManager = createDefaultNotificationDrawerManager(
|
||||||
notificationManager = notificationManager,
|
notificationManager = notificationManager,
|
||||||
|
|
|
||||||
|
|
@ -22,29 +22,34 @@ import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import io.element.android.libraries.push.impl.notifications.ActiveNotificationsProvider
|
import io.element.android.libraries.push.impl.notifications.ActiveNotificationsProvider
|
||||||
|
|
||||||
class FakeActiveNotificationsProvider(
|
class FakeActiveNotificationsProvider(
|
||||||
var activeNotifications: MutableList<StatusBarNotification> = mutableListOf(),
|
private val getMessageNotificationsForRoomResult: (SessionId, RoomId) -> List<StatusBarNotification> = { _, _ -> emptyList() },
|
||||||
|
private val getNotificationsForSessionResult: (SessionId) -> List<StatusBarNotification> = { emptyList() },
|
||||||
|
private val getMembershipNotificationForSessionResult: (SessionId) -> List<StatusBarNotification> = { emptyList() },
|
||||||
|
private val getMembershipNotificationForRoomResult: (SessionId, RoomId) -> List<StatusBarNotification> = { _, _ -> emptyList() },
|
||||||
|
private val getSummaryNotificationResult: (SessionId) -> StatusBarNotification? = { null },
|
||||||
|
private val countResult: (SessionId) -> Int = { 0 },
|
||||||
) : ActiveNotificationsProvider {
|
) : ActiveNotificationsProvider {
|
||||||
override fun getMessageNotificationsForRoom(sessionId: SessionId, roomId: RoomId): List<StatusBarNotification> {
|
override fun getMessageNotificationsForRoom(sessionId: SessionId, roomId: RoomId): List<StatusBarNotification> {
|
||||||
return activeNotifications
|
return getMessageNotificationsForRoomResult(sessionId, roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNotificationsForSession(sessionId: SessionId): List<StatusBarNotification> {
|
override fun getNotificationsForSession(sessionId: SessionId): List<StatusBarNotification> {
|
||||||
return activeNotifications
|
return getNotificationsForSessionResult(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMembershipNotificationForSession(sessionId: SessionId): List<StatusBarNotification> {
|
override fun getMembershipNotificationForSession(sessionId: SessionId): List<StatusBarNotification> {
|
||||||
return activeNotifications
|
return getMembershipNotificationForSessionResult(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMembershipNotificationForRoom(sessionId: SessionId, roomId: RoomId): List<StatusBarNotification> {
|
override fun getMembershipNotificationForRoom(sessionId: SessionId, roomId: RoomId): List<StatusBarNotification> {
|
||||||
return activeNotifications
|
return getMembershipNotificationForRoomResult(sessionId, roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSummaryNotification(sessionId: SessionId): StatusBarNotification? {
|
override fun getSummaryNotification(sessionId: SessionId): StatusBarNotification? {
|
||||||
return activeNotifications.firstOrNull()
|
return getSummaryNotificationResult(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun count(sessionId: SessionId): Int {
|
override fun count(sessionId: SessionId): Int {
|
||||||
return activeNotifications.size
|
return countResult(sessionId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue