Browse Source

Remove unused method ActiveNotificationsProvider.getAllNotifications()

pull/3320/head
Benoit Marty 3 weeks ago
parent
commit
46106c96f7
  1. 5
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/ActiveNotificationsProvider.kt
  2. 21
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultActiveNotificationsProviderTest.kt
  3. 4
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeActiveNotificationsProvider.kt

5
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/ActiveNotificationsProvider.kt

@ -26,7 +26,6 @@ import io.element.android.libraries.push.api.notifications.NotificationIdProvide @@ -26,7 +26,6 @@ import io.element.android.libraries.push.api.notifications.NotificationIdProvide
import javax.inject.Inject
interface ActiveNotificationsProvider {
fun getAllNotifications(): List<StatusBarNotification>
fun getMessageNotificationsForRoom(sessionId: SessionId, roomId: RoomId): List<StatusBarNotification>
fun getNotificationsForSession(sessionId: SessionId): List<StatusBarNotification>
fun getMembershipNotificationForSession(sessionId: SessionId): List<StatusBarNotification>
@ -39,10 +38,6 @@ interface ActiveNotificationsProvider { @@ -39,10 +38,6 @@ interface ActiveNotificationsProvider {
class DefaultActiveNotificationsProvider @Inject constructor(
private val notificationManager: NotificationManagerCompat,
) : ActiveNotificationsProvider {
override fun getAllNotifications(): List<StatusBarNotification> {
return notificationManager.activeNotifications
}
override fun getNotificationsForSession(sessionId: SessionId): List<StatusBarNotification> {
return notificationManager.activeNotifications.filter { it.notification.group == sessionId.value }
}

21
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultActiveNotificationsProviderTest.kt

@ -36,27 +36,6 @@ import org.robolectric.RobolectricTestRunner @@ -36,27 +36,6 @@ import org.robolectric.RobolectricTestRunner
class DefaultActiveNotificationsProviderTest {
private val notificationIdProvider = NotificationIdProvider
@Test
fun `getAllNotifications with no active notifications returns empty list`() {
val activeNotificationsProvider = createActiveNotificationsProvider(activeNotifications = emptyList())
val emptyNotifications = activeNotificationsProvider.getAllNotifications()
assertThat(emptyNotifications).isEmpty()
}
@Test
fun `getAllNotifications with active notifications returns all`() {
val activeNotifications = listOf(
aStatusBarNotification(id = notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID), groupId = A_SESSION_ID.value),
aStatusBarNotification(id = notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), groupId = A_SESSION_ID.value),
aStatusBarNotification(id = notificationIdProvider.getRoomInvitationNotificationId(A_SESSION_ID), groupId = A_SESSION_ID.value),
)
val activeNotificationsProvider = createActiveNotificationsProvider(activeNotifications = activeNotifications)
val result = activeNotificationsProvider.getAllNotifications()
assertThat(result).hasSize(3)
}
@Test
fun `getNotificationsForSession returns only notifications for that session id`() {
val activeNotifications = listOf(

4
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeActiveNotificationsProvider.kt

@ -24,10 +24,6 @@ import io.element.android.libraries.push.impl.notifications.ActiveNotificationsP @@ -24,10 +24,6 @@ import io.element.android.libraries.push.impl.notifications.ActiveNotificationsP
class FakeActiveNotificationsProvider(
var activeNotifications: MutableList<StatusBarNotification> = mutableListOf(),
) : ActiveNotificationsProvider {
override fun getAllNotifications(): List<StatusBarNotification> {
return activeNotifications
}
override fun getMessageNotificationsForRoom(sessionId: SessionId, roomId: RoomId): List<StatusBarNotification> {
return activeNotifications
}

Loading…
Cancel
Save