From 8a02b50c98b961fddd94d3d94422e8fc22f720b7 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 25 Aug 2026 10:11:07 +0200 Subject: [PATCH] `NotificationSettingsEvents` -> `NotificationSettingsEvent` --- ...Events.kt => NotificationSettingsEvent.kt} | 48 ++++----- .../NotificationSettingsPresenter.kt | 48 ++++----- .../NotificationSettingsState.kt | 4 +- .../NotificationSettingsStatePreviewParam.kt | 4 +- .../notifications/NotificationSettingsView.kt | 50 ++++----- .../NotificationSettingsPresenterTest.kt | 102 +++++++++--------- .../NotificationSettingsViewTest.kt | 72 ++++++------- 7 files changed, 164 insertions(+), 164 deletions(-) rename features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/{NotificationSettingsEvents.kt => NotificationSettingsEvent.kt} (79%) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsEvents.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsEvent.kt similarity index 79% rename from features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsEvents.kt rename to features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsEvent.kt index 5ca7fc9fdf..fc175f4c0b 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsEvents.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsEvent.kt @@ -10,28 +10,28 @@ package io.element.android.features.preferences.impl.notifications import io.element.android.libraries.preferences.api.store.NotificationSound -sealed interface NotificationSettingsEvents { - data object RefreshSystemNotificationsEnabled : NotificationSettingsEvents - data class SetNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents - data class SetAtRoomNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents - data class SetCallNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents - data class SetInviteForMeNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvents - data object FixConfigurationMismatch : NotificationSettingsEvents - data object ClearConfigurationMismatchError : NotificationSettingsEvents - data object ClearNotificationChangeError : NotificationSettingsEvents - data object ChangePushProvider : NotificationSettingsEvents - data object CancelChangePushProvider : NotificationSettingsEvents - data class SetPushProvider(val index: Int) : NotificationSettingsEvents - data class SetMessageSound(val sound: NotificationSound) : NotificationSettingsEvents - data class SetCallRingtone(val sound: NotificationSound) : NotificationSettingsEvents - data object DismissMessageSoundCopyError : NotificationSettingsEvents - data object DismissCallRingtoneCopyError : NotificationSettingsEvents - data object ShowMessageSoundDialog : NotificationSettingsEvents - data object DismissMessageSoundDialog : NotificationSettingsEvents - data class SelectMessageSoundPreset(val sound: NotificationSound) : NotificationSettingsEvents - data object LaunchMessageSoundPicker : NotificationSettingsEvents - data object ShowCallRingtoneDialog : NotificationSettingsEvents - data object DismissCallRingtoneDialog : NotificationSettingsEvents - data class SelectCallRingtonePreset(val sound: NotificationSound) : NotificationSettingsEvents - data object LaunchCallRingtonePicker : NotificationSettingsEvents +sealed interface NotificationSettingsEvent { + data object RefreshSystemNotificationsEnabled : NotificationSettingsEvent + data class SetNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent + data class SetAtRoomNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent + data class SetCallNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent + data class SetInviteForMeNotificationsEnabled(val enabled: Boolean) : NotificationSettingsEvent + data object FixConfigurationMismatch : NotificationSettingsEvent + data object ClearConfigurationMismatchError : NotificationSettingsEvent + data object ClearNotificationChangeError : NotificationSettingsEvent + data object ChangePushProvider : NotificationSettingsEvent + data object CancelChangePushProvider : NotificationSettingsEvent + data class SetPushProvider(val index: Int) : NotificationSettingsEvent + data class SetMessageSound(val sound: NotificationSound) : NotificationSettingsEvent + data class SetCallRingtone(val sound: NotificationSound) : NotificationSettingsEvent + data object DismissMessageSoundCopyError : NotificationSettingsEvent + data object DismissCallRingtoneCopyError : NotificationSettingsEvent + data object ShowMessageSoundDialog : NotificationSettingsEvent + data object DismissMessageSoundDialog : NotificationSettingsEvent + data class SelectMessageSoundPreset(val sound: NotificationSound) : NotificationSettingsEvent + data object LaunchMessageSoundPicker : NotificationSettingsEvent + data object ShowCallRingtoneDialog : NotificationSettingsEvent + data object DismissCallRingtoneDialog : NotificationSettingsEvent + data class SelectCallRingtonePreset(val sound: NotificationSound) : NotificationSettingsEvent + data object LaunchCallRingtonePicker : NotificationSettingsEvent } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenter.kt index 03fe2cf31b..5256f9ec9c 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenter.kt @@ -196,38 +196,38 @@ class NotificationSettingsPresenter( ) } - fun handleEvent(event: NotificationSettingsEvents) { + fun handleEvent(event: NotificationSettingsEvent) { when (event) { - is NotificationSettingsEvents.SetAtRoomNotificationsEnabled -> { + is NotificationSettingsEvent.SetAtRoomNotificationsEnabled -> { localCoroutineScope.setAtRoomNotificationsEnabled(event.enabled, changeNotificationSettingAction) } - is NotificationSettingsEvents.SetCallNotificationsEnabled -> { + is NotificationSettingsEvent.SetCallNotificationsEnabled -> { localCoroutineScope.setCallNotificationsEnabled(event.enabled, changeNotificationSettingAction) } - is NotificationSettingsEvents.SetInviteForMeNotificationsEnabled -> { + is NotificationSettingsEvent.SetInviteForMeNotificationsEnabled -> { localCoroutineScope.setInviteForMeNotificationsEnabled(event.enabled, changeNotificationSettingAction) } - is NotificationSettingsEvents.SetNotificationsEnabled -> sessionCoroutineScope.setNotificationsEnabled(userPushStore, event.enabled) - NotificationSettingsEvents.ClearConfigurationMismatchError -> { + is NotificationSettingsEvent.SetNotificationsEnabled -> sessionCoroutineScope.setNotificationsEnabled(userPushStore, event.enabled) + NotificationSettingsEvent.ClearConfigurationMismatchError -> { matrixSettings.value = NotificationSettingsState.MatrixSettings.Invalid(fixFailed = false) } - NotificationSettingsEvents.FixConfigurationMismatch -> localCoroutineScope.fixConfigurationMismatch(matrixSettings) - NotificationSettingsEvents.RefreshSystemNotificationsEnabled -> { + NotificationSettingsEvent.FixConfigurationMismatch -> localCoroutineScope.fixConfigurationMismatch(matrixSettings) + NotificationSettingsEvent.RefreshSystemNotificationsEnabled -> { systemNotificationsEnabled.value = systemNotificationsEnabledProvider.notificationsEnabled() refreshFullScreenIntentSettings++ } - NotificationSettingsEvents.ClearNotificationChangeError -> changeNotificationSettingAction.value = AsyncAction.Uninitialized - NotificationSettingsEvents.ChangePushProvider -> showChangePushProviderDialog = true - NotificationSettingsEvents.CancelChangePushProvider -> showChangePushProviderDialog = false - is NotificationSettingsEvents.SetPushProvider -> localCoroutineScope.changePushProvider(distributors.getOrNull(event.index)) - is NotificationSettingsEvents.SetMessageSound -> applyMessageSound( + NotificationSettingsEvent.ClearNotificationChangeError -> changeNotificationSettingAction.value = AsyncAction.Uninitialized + NotificationSettingsEvent.ChangePushProvider -> showChangePushProviderDialog = true + NotificationSettingsEvent.CancelChangePushProvider -> showChangePushProviderDialog = false + is NotificationSettingsEvent.SetPushProvider -> localCoroutineScope.changePushProvider(distributors.getOrNull(event.index)) + is NotificationSettingsEvent.SetMessageSound -> applyMessageSound( sound = event.sound, sessionCoroutineScope = sessionCoroutineScope, onCopyError = { messageSoundCopyError = true }, onCopySuccess = { messageSoundCopyError = false }, onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) }, ) - is NotificationSettingsEvents.SelectMessageSoundPreset -> { + is NotificationSettingsEvent.SelectMessageSoundPreset -> { showMessageSoundDialog = false applyMessageSound( sound = event.sound, @@ -237,13 +237,13 @@ class NotificationSettingsPresenter( onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) }, ) } - NotificationSettingsEvents.ShowMessageSoundDialog -> showMessageSoundDialog = true - NotificationSettingsEvents.DismissMessageSoundDialog -> showMessageSoundDialog = false - NotificationSettingsEvents.LaunchMessageSoundPicker -> { + NotificationSettingsEvent.ShowMessageSoundDialog -> showMessageSoundDialog = true + NotificationSettingsEvent.DismissMessageSoundDialog -> showMessageSoundDialog = false + NotificationSettingsEvent.LaunchMessageSoundPicker -> { showMessageSoundDialog = false pendingMessageSoundPickerLaunch++ } - is NotificationSettingsEvents.SetCallRingtone -> { + is NotificationSettingsEvent.SetCallRingtone -> { legacyCallRingtone = null applyCallRingtone( sound = event.sound, @@ -253,7 +253,7 @@ class NotificationSettingsPresenter( onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) }, ) } - is NotificationSettingsEvents.SelectCallRingtonePreset -> { + is NotificationSettingsEvent.SelectCallRingtonePreset -> { showCallRingtoneDialog = false legacyCallRingtone = null applyCallRingtone( @@ -264,16 +264,16 @@ class NotificationSettingsPresenter( onChannelFailure = { failure -> changeNotificationSettingAction.value = AsyncAction.Failure(failure) }, ) } - NotificationSettingsEvents.ShowCallRingtoneDialog -> showCallRingtoneDialog = true - NotificationSettingsEvents.DismissCallRingtoneDialog -> showCallRingtoneDialog = false - NotificationSettingsEvents.LaunchCallRingtonePicker -> { + NotificationSettingsEvent.ShowCallRingtoneDialog -> showCallRingtoneDialog = true + NotificationSettingsEvent.DismissCallRingtoneDialog -> showCallRingtoneDialog = false + NotificationSettingsEvent.LaunchCallRingtonePicker -> { showCallRingtoneDialog = false pendingCallRingtonePickerLaunch++ } - NotificationSettingsEvents.DismissMessageSoundCopyError -> { + NotificationSettingsEvent.DismissMessageSoundCopyError -> { messageSoundCopyError = false } - NotificationSettingsEvents.DismissCallRingtoneCopyError -> { + NotificationSettingsEvent.DismissCallRingtoneCopyError -> { callRingtoneCopyError = false } } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsState.kt index 3c59f6c355..379b8589b7 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsState.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsState.kt @@ -30,7 +30,7 @@ data class NotificationSettingsState( val showCallRingtoneDialog: Boolean, /** * One-shot trigger for launching the system ringtone picker. Each - * [NotificationSettingsEvents.LaunchMessageSoundPicker] increments the value; + * [NotificationSettingsEvent.LaunchMessageSoundPicker] increments the value; * the view watches this in `LaunchedEffect` and calls the launcher whenever it goes above 0. * **Always start at 0** in initial state, providers, and previews — a non-zero seed will * auto-open the picker on screen entry. @@ -42,7 +42,7 @@ data class NotificationSettingsState( * auto-opens on screen entry. */ val pendingCallRingtonePickerLaunch: Int, - val eventSink: (NotificationSettingsEvents) -> Unit, + val eventSink: (NotificationSettingsEvent) -> Unit, ) { sealed interface MatrixSettings { data object Uninitialized : MatrixSettings diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsStatePreviewParam.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsStatePreviewParam.kt index 38c83153ea..33f20cdb6e 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsStatePreviewParam.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsStatePreviewParam.kt @@ -101,7 +101,7 @@ fun aValidNotificationSettingsState( showCallRingtoneDialog: Boolean = false, pendingMessageSoundPickerLaunch: Int = 0, pendingCallRingtonePickerLaunch: Int = 0, - eventSink: (NotificationSettingsEvents) -> Unit = {}, + eventSink: (NotificationSettingsEvent) -> Unit = {}, ) = NotificationSettingsState( matrixSettings = NotificationSettingsState.MatrixSettings.Valid( atRoomNotificationsEnabled = atRoomNotificationsEnabled, @@ -138,7 +138,7 @@ fun aValidNotificationSettingsState( fun aInvalidNotificationSettingsState( fixFailed: Boolean = false, - eventSink: (NotificationSettingsEvents) -> Unit = {}, + eventSink: (NotificationSettingsEvent) -> Unit = {}, ) = NotificationSettingsState( matrixSettings = NotificationSettingsState.MatrixSettings.Invalid( fixFailed = fixFailed, diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt index a15f991f95..6c5b053b35 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt @@ -74,7 +74,7 @@ fun NotificationSettingsView( ) { OnLifecycleEvent { _, event -> when (event) { - Lifecycle.Event.ON_RESUME -> state.eventSink.invoke(NotificationSettingsEvents.RefreshSystemNotificationsEnabled) + Lifecycle.Event.ON_RESUME -> state.eventSink.invoke(NotificationSettingsEvent.RefreshSystemNotificationsEnabled) else -> Unit } } @@ -86,27 +86,27 @@ fun NotificationSettingsView( when (state.matrixSettings) { is NotificationSettingsState.MatrixSettings.Invalid -> InvalidNotificationSettingsView( showError = state.matrixSettings.fixFailed, - onContinueClick = { state.eventSink(NotificationSettingsEvents.FixConfigurationMismatch) }, - onDismissError = { state.eventSink(NotificationSettingsEvents.ClearConfigurationMismatchError) }, + onContinueClick = { state.eventSink(NotificationSettingsEvent.FixConfigurationMismatch) }, + onDismissError = { state.eventSink(NotificationSettingsEvent.ClearConfigurationMismatchError) }, ) NotificationSettingsState.MatrixSettings.Uninitialized -> return@PreferencePage is NotificationSettingsState.MatrixSettings.Valid -> NotificationSettingsContentView( matrixSettings = state.matrixSettings, state = state, - onNotificationsEnabledChange = { state.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(it)) }, + onNotificationsEnabledChange = { state.eventSink(NotificationSettingsEvent.SetNotificationsEnabled(it)) }, onGroupChatsClick = { onOpenEditDefault(false) }, onDirectChatsClick = { onOpenEditDefault(true) }, - onMentionNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(it)) }, + onMentionNotificationsChange = { state.eventSink(NotificationSettingsEvent.SetAtRoomNotificationsEnabled(it)) }, // TODO We are removing the call notification toggle until support for call notifications has been added -// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(it)) }, - onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(it)) }, +// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvent.SetCallNotificationsEnabled(it)) }, + onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvent.SetInviteForMeNotificationsEnabled(it)) }, onTroubleshootNotificationsClick = onTroubleshootNotificationsClick, ) } AsyncActionView( async = state.changeNotificationSettingAction, errorMessage = { stringResource(R.string.screen_notification_settings_edit_failed_updating_default_mode) }, - onErrorDismiss = { state.eventSink(NotificationSettingsEvents.ClearNotificationChangeError) }, + onErrorDismiss = { state.eventSink(NotificationSettingsEvent.ClearNotificationChangeError) }, onSuccess = {}, ) } @@ -249,7 +249,7 @@ private fun NotificationSettingsContentView( }, onClick = { if (state.currentPushDistributor.isReady()) { - state.eventSink(NotificationSettingsEvents.ChangePushProvider) + state.eventSink(NotificationSettingsEvent.ChangePushProvider) } } ) @@ -269,10 +269,10 @@ private fun NotificationSettingsContentView( initialSelection = state.availablePushDistributors.indexOf(state.currentPushDistributor.dataOrNull()), onSelectOption = { index -> state.eventSink( - NotificationSettingsEvents.SetPushProvider(index) + NotificationSettingsEvent.SetPushProvider(index) ) }, - onDismissRequest = { state.eventSink(NotificationSettingsEvents.CancelChangePushProvider) }, + onDismissRequest = { state.eventSink(NotificationSettingsEvent.CancelChangePushProvider) }, ) } } @@ -286,7 +286,7 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) { type = RingtoneManager.TYPE_NOTIFICATION, current = state.messageSound.sound, defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI, - onSoundPick = { sound -> state.eventSink(NotificationSettingsEvents.SetMessageSound(sound)) }, + onSoundPick = { sound -> state.eventSink(NotificationSettingsEvent.SetMessageSound(sound)) }, ) // Skip the initial 0 emission so the picker doesn't auto-open on screen entry; only // increments fired by LaunchMessageSoundPicker should launch it. @@ -298,11 +298,11 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) { ListItem( content = { Text(stringResource(id = R.string.screen_notification_settings_message_sound_label)) }, supportingContent = { Text(state.messageSound.displayName) }, - onClick = { state.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog) }, + onClick = { state.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog) }, ) if (state.messageSound.copyError) { SoundCopyErrorRow( - onDismissClick = { state.eventSink(NotificationSettingsEvents.DismissMessageSoundCopyError) }, + onDismissClick = { state.eventSink(NotificationSettingsEvent.DismissMessageSoundCopyError) }, ) } if (state.showMessageSoundDialog) { @@ -313,7 +313,7 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) { type = RingtoneManager.TYPE_RINGTONE, current = state.callRingtone.sound, defaultUri = Settings.System.DEFAULT_RINGTONE_URI, - onSoundPick = { sound -> state.eventSink(NotificationSettingsEvents.SetCallRingtone(sound)) }, + onSoundPick = { sound -> state.eventSink(NotificationSettingsEvent.SetCallRingtone(sound)) }, ) // Skip the initial 0 emission so the picker doesn't auto-open on screen entry; only // increments fired by LaunchCallRingtonePicker should launch it. @@ -325,11 +325,11 @@ private fun SoundsPreferenceCategory(state: NotificationSettingsState) { ListItem( content = { Text(stringResource(id = R.string.screen_notification_settings_call_ringtone_label)) }, supportingContent = { Text(state.callRingtone.displayName) }, - onClick = { state.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog) }, + onClick = { state.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog) }, ) if (state.callRingtone.copyError) { SoundCopyErrorRow( - onDismissClick = { state.eventSink(NotificationSettingsEvents.DismissCallRingtoneCopyError) }, + onDismissClick = { state.eventSink(NotificationSettingsEvent.DismissCallRingtoneCopyError) }, ) } if (state.showCallRingtoneDialog) { @@ -368,13 +368,13 @@ private fun MessageSoundDialog(state: NotificationSettingsState) { initialSelection = initialSelection, onSelectOption = { index -> when (index) { - 0 -> state.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementDefault)) - 1 -> state.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementFade)) - 2 -> state.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.SystemDefault)) - else -> state.eventSink(NotificationSettingsEvents.LaunchMessageSoundPicker) + 0 -> state.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementDefault)) + 1 -> state.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementFade)) + 2 -> state.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.SystemDefault)) + else -> state.eventSink(NotificationSettingsEvent.LaunchMessageSoundPicker) } }, - onDismissRequest = { state.eventSink(NotificationSettingsEvents.DismissMessageSoundDialog) }, + onDismissRequest = { state.eventSink(NotificationSettingsEvent.DismissMessageSoundDialog) }, ) } @@ -402,11 +402,11 @@ private fun CallRingtoneDialog(state: NotificationSettingsState) { initialSelection = initialSelection, onSelectOption = { index -> when (index) { - 0 -> state.eventSink(NotificationSettingsEvents.SelectCallRingtonePreset(NotificationSound.SystemDefault)) - else -> state.eventSink(NotificationSettingsEvents.LaunchCallRingtonePicker) + 0 -> state.eventSink(NotificationSettingsEvent.SelectCallRingtonePreset(NotificationSound.SystemDefault)) + else -> state.eventSink(NotificationSettingsEvent.LaunchCallRingtonePicker) } }, - onDismissRequest = { state.eventSink(NotificationSettingsEvents.DismissCallRingtoneDialog) }, + onDismissRequest = { state.eventSink(NotificationSettingsEvent.DismissCallRingtoneDialog) }, ) } diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenterTest.kt index 29e4b1c40a..6a201fe3fa 100644 --- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenterTest.kt +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsPresenterTest.kt @@ -120,7 +120,7 @@ class NotificationSettingsPresenterTest { val presenter = createNotificationSettingsPresenter(notificationSettingsService) presenter.test { val initialState = awaitItem() - initialState.eventSink(NotificationSettingsEvents.FixConfigurationMismatch) + initialState.eventSink(NotificationSettingsEvent.FixConfigurationMismatch) val fixedState = consumeItemsUntilPredicate(timeout = 2000.milliseconds) { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() @@ -148,14 +148,14 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() assertThat(loadedState.appSettings.appNotificationsEnabled).isTrue() - loadedState.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(false)) + loadedState.eventSink(NotificationSettingsEvent.SetNotificationsEnabled(false)) val updatedState = consumeItemsUntilPredicate { !it.appSettings.appNotificationsEnabled }.last() assertThat(updatedState.appSettings.appNotificationsEnabled).isFalse() unregisterWithResult.assertions().isCalledOnce() // Enable notification again - loadedState.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(true)) + loadedState.eventSink(NotificationSettingsEvent.SetNotificationsEnabled(true)) val updatedState2 = consumeItemsUntilPredicate { it.appSettings.appNotificationsEnabled }.last() @@ -173,7 +173,7 @@ class NotificationSettingsPresenterTest { }.last() val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid assertThat(validMatrixState?.callNotificationsEnabled).isFalse() - loadedState.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(true)) + loadedState.eventSink(NotificationSettingsEvent.SetCallNotificationsEnabled(true)) val updatedState = consumeItemsUntilPredicate { (it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.callNotificationsEnabled == true }.last() @@ -192,7 +192,7 @@ class NotificationSettingsPresenterTest { }.last() val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid assertThat(validMatrixState?.inviteForMeNotificationsEnabled).isFalse() - loadedState.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(true)) + loadedState.eventSink(NotificationSettingsEvent.SetInviteForMeNotificationsEnabled(true)) val updatedState = consumeItemsUntilPredicate { (it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.inviteForMeNotificationsEnabled == true }.last() @@ -211,7 +211,7 @@ class NotificationSettingsPresenterTest { }.last() val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid assertThat(validMatrixState?.atRoomNotificationsEnabled).isFalse() - loadedState.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(true)) + loadedState.eventSink(NotificationSettingsEvent.SetAtRoomNotificationsEnabled(true)) val updatedState = consumeItemsUntilPredicate { (it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)?.atRoomNotificationsEnabled == true }.last() @@ -232,12 +232,12 @@ class NotificationSettingsPresenterTest { }.last() val validMatrixState = loadedState.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid assertThat(validMatrixState?.atRoomNotificationsEnabled).isFalse() - loadedState.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(true)) + loadedState.eventSink(NotificationSettingsEvent.SetAtRoomNotificationsEnabled(true)) val errorState = consumeItemsUntilPredicate { it.changeNotificationSettingAction.isFailure() }.last() assertThat(errorState.changeNotificationSettingAction.isFailure()).isTrue() - errorState.eventSink(NotificationSettingsEvents.ClearNotificationChangeError) + errorState.eventSink(NotificationSettingsEvent.ClearNotificationChangeError) val clearErrorState = consumeItemsUntilPredicate { it.changeNotificationSettingAction.isUninitialized() }.last() @@ -258,16 +258,16 @@ class NotificationSettingsPresenterTest { Distributor(value = "aDistributorValue0", name = "aDistributorName0"), Distributor(value = "aDistributorValue1", name = "aDistributorName1"), ) - initialState.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider) + initialState.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider) val withDialog = awaitItem() assertThat(withDialog.showChangePushProviderDialog).isTrue() // Cancel - withDialog.eventSink(NotificationSettingsEvents.CancelChangePushProvider) + withDialog.eventSink(NotificationSettingsEvent.CancelChangePushProvider) val withoutDialog = awaitItem() assertThat(withoutDialog.showChangePushProviderDialog).isFalse() - withDialog.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider) + withDialog.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider) assertThat(awaitItem().showChangePushProviderDialog).isTrue() - withDialog.eventSink(NotificationSettingsEvents.SetPushProvider(1)) + withDialog.eventSink(NotificationSettingsEvent.SetPushProvider(1)) val withNewProvider = awaitItem() assertThat(withNewProvider.showChangePushProviderDialog).isFalse() assertThat(withNewProvider.currentPushDistributor).isInstanceOf(AsyncData.Loading::class.java) @@ -290,10 +290,10 @@ class NotificationSettingsPresenterTest { Distributor(value = "aDistributorValue0", name = "aDistributorName0"), Distributor(value = "aDistributorValue1", name = "aDistributorName1"), ) - initialState.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider) + initialState.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider) assertThat(awaitItem().showChangePushProviderDialog).isTrue() // Choose the same value (index 0) - initialState.eventSink(NotificationSettingsEvents.SetPushProvider(0)) + initialState.eventSink(NotificationSettingsEvent.SetPushProvider(0)) val withNewProvider = awaitItem() assertThat(withNewProvider.showChangePushProviderDialog).isFalse() expectNoEvents() @@ -318,7 +318,7 @@ class NotificationSettingsPresenterTest { expectNoEvents() // Refresh - initialState.eventSink.invoke(NotificationSettingsEvents.RefreshSystemNotificationsEnabled) + initialState.eventSink.invoke(NotificationSettingsEvent.RefreshSystemNotificationsEnabled) assertThat(awaitItem().fullScreenIntentPermissionsState.permissionGranted).isTrue() } } @@ -334,10 +334,10 @@ class NotificationSettingsPresenterTest { ) presenter.test { val initialState = awaitLastSequentialItem() - initialState.eventSink.invoke(NotificationSettingsEvents.ChangePushProvider) + initialState.eventSink.invoke(NotificationSettingsEvent.ChangePushProvider) val withDialog = awaitItem() assertThat(withDialog.showChangePushProviderDialog).isTrue() - withDialog.eventSink(NotificationSettingsEvents.SetPushProvider(1)) + withDialog.eventSink(NotificationSettingsEvent.SetPushProvider(1)) val withNewProvider = awaitItem() assertThat(withNewProvider.showChangePushProviderDialog).isFalse() assertThat(withNewProvider.currentPushDistributor).isInstanceOf(AsyncData.Loading::class.java) @@ -384,7 +384,7 @@ class NotificationSettingsPresenterTest { }.last() assertThat(initialState.messageSound.sound).isEqualTo(NotificationSound.SystemDefault) - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(customSound)) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(customSound)) val updatedState = consumeItemsUntilPredicate { it.messageSound.sound == customSound }.last() assertThat(updatedState.messageSound.sound).isEqualTo(customSound) @@ -410,7 +410,7 @@ class NotificationSettingsPresenterTest { }.last() assertThat(initialState.callRingtone.sound).isEqualTo(NotificationSound.SystemDefault) - initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent)) + initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent)) val updatedState = consumeItemsUntilPredicate { it.callRingtone.sound == NotificationSound.Silent }.last() assertThat(updatedState.callRingtone.sound).isEqualTo(NotificationSound.Silent) @@ -435,11 +435,11 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://a"))) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://a"))) consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.Custom("content://a") } - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://b"))) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://b"))) consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.Custom("content://b") } - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault)) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault)) consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.SystemDefault } assertThat(versions).containsExactly(1, 2, 3).inOrder() @@ -461,7 +461,7 @@ class NotificationSettingsPresenterTest { consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid && it.messageSound.sound == NotificationSound.Custom("content://existing") - }.last().eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault)) + }.last().eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault)) consumeItemsUntilPredicate { it.messageSound.sound == NotificationSound.SystemDefault } assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(NotificationSound.SystemDefault) recreateRecorder.assertions().isCalledOnce().with(value(NotificationSound.SystemDefault), value(1)) @@ -483,7 +483,7 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://x"))) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://x"))) val errorState = consumeItemsUntilPredicate { it.changeNotificationSettingAction.isFailure() @@ -670,7 +670,7 @@ class NotificationSettingsPresenterTest { val initialState = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://media/source"))) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://media/source"))) advanceUntilIdle() val expectedSound = NotificationSound.Custom("content://my.app.fileprovider/notification_sounds/message_sound.ogg") @@ -695,7 +695,7 @@ class NotificationSettingsPresenterTest { val initialState = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://broken"))) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://broken"))) val errorState = consumeItemsUntilPredicate { it.messageSound.copyError }.last() assertThat(errorState.messageSound.copyError).isTrue() @@ -703,7 +703,7 @@ class NotificationSettingsPresenterTest { assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(priorChoice) // Dismissing the inline error clears the flag without altering persistence. - errorState.eventSink(NotificationSettingsEvents.DismissMessageSoundCopyError) + errorState.eventSink(NotificationSettingsEvent.DismissMessageSoundCopyError) val cleared = consumeItemsUntilPredicate { !it.messageSound.copyError }.last() assertThat(cleared.messageSound.copyError).isFalse() assertThat(appPreferencesStore.getNotificationSoundChannelConfig().messageSound).isEqualTo(priorChoice) @@ -725,7 +725,7 @@ class NotificationSettingsPresenterTest { val initialState = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Custom("content://broken"))) + initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Custom("content://broken"))) val errorState = consumeItemsUntilPredicate { it.callRingtone.copyError }.last() assertThat(errorState.callRingtone.copyError).isTrue() @@ -733,7 +733,7 @@ class NotificationSettingsPresenterTest { assertThat(appPreferencesStore.getNotificationSoundChannelConfig().callRingtone).isEqualTo(priorChoice) // Dismissing the inline error clears the flag without altering persistence. - errorState.eventSink(NotificationSettingsEvents.DismissCallRingtoneCopyError) + errorState.eventSink(NotificationSettingsEvent.DismissCallRingtoneCopyError) val cleared = consumeItemsUntilPredicate { !it.callRingtone.copyError }.last() assertThat(cleared.callRingtone.copyError).isFalse() assertThat(appPreferencesStore.getNotificationSoundChannelConfig().callRingtone).isEqualTo(priorChoice) @@ -759,8 +759,8 @@ class NotificationSettingsPresenterTest { val initialState = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault)) - initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent)) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault)) + initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent)) advanceUntilIdle() assertThat(copierCalls).isEmpty() cancelAndIgnoreRemainingEvents() @@ -791,8 +791,8 @@ class NotificationSettingsPresenterTest { val initialState = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.SystemDefault)) - initialState.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent)) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.SystemDefault)) + initialState.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent)) advanceUntilIdle() assertThat(deleteCalls).containsExactly( NotificationSoundCopier.SoundSlot.Message, @@ -835,8 +835,8 @@ class NotificationSettingsPresenterTest { // Re-pick the persisted sound for both slots — neither should churn the channel, // bump the version, or hit the copier / delete sweep. - initial.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementDefault)) - initial.eventSink(NotificationSettingsEvents.SetCallRingtone(NotificationSound.Silent)) + initial.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementDefault)) + initial.eventSink(NotificationSettingsEvent.SetCallRingtone(NotificationSound.Silent)) advanceUntilIdle() val config = appPreferencesStore.getNotificationSoundChannelConfig() @@ -873,8 +873,8 @@ class NotificationSettingsPresenterTest { val initial = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initial.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://A"))) - initial.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://B"))) + initial.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://A"))) + initial.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://B"))) advanceUntilIdle() assertThat(copyOrder).containsExactly("content://A", "content://B").inOrder() @@ -908,7 +908,7 @@ class NotificationSettingsPresenterTest { val initialState = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initialState.eventSink(NotificationSettingsEvents.SetMessageSound(NotificationSound.Custom("content://media/source"))) + initialState.eventSink(NotificationSettingsEvent.SetMessageSound(NotificationSound.Custom("content://media/source"))) advanceUntilIdle() assertThat(deleteCalls).isEmpty() cancelAndIgnoreRemainingEvents() @@ -924,11 +924,11 @@ class NotificationSettingsPresenterTest { }.last() assertThat(initial.showMessageSoundDialog).isFalse() - initial.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog) + initial.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog) val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last() assertThat(shown.showMessageSoundDialog).isTrue() - shown.eventSink(NotificationSettingsEvents.DismissMessageSoundDialog) + shown.eventSink(NotificationSettingsEvent.DismissMessageSoundDialog) val hidden = consumeItemsUntilPredicate { !it.showMessageSoundDialog }.last() assertThat(hidden.showMessageSoundDialog).isFalse() cancelAndIgnoreRemainingEvents() @@ -950,10 +950,10 @@ class NotificationSettingsPresenterTest { val initial = consumeItemsUntilPredicate { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() - initial.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog) + initial.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog) val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last() - shown.eventSink(NotificationSettingsEvents.SelectMessageSoundPreset(NotificationSound.ElementDefault)) + shown.eventSink(NotificationSettingsEvent.SelectMessageSoundPreset(NotificationSound.ElementDefault)) advanceUntilIdle() consumeItemsUntilPredicate { !it.showMessageSoundDialog && it.messageSound.sound == NotificationSound.ElementDefault @@ -973,10 +973,10 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() assertThat(initial.pendingMessageSoundPickerLaunch).isEqualTo(0) - initial.eventSink(NotificationSettingsEvents.ShowMessageSoundDialog) + initial.eventSink(NotificationSettingsEvent.ShowMessageSoundDialog) val shown = consumeItemsUntilPredicate { it.showMessageSoundDialog }.last() - shown.eventSink(NotificationSettingsEvents.LaunchMessageSoundPicker) + shown.eventSink(NotificationSettingsEvent.LaunchMessageSoundPicker) val launched = consumeItemsUntilPredicate { it.pendingMessageSoundPickerLaunch == 1 }.last() assertThat(launched.showMessageSoundDialog).isFalse() assertThat(launched.pendingMessageSoundPickerLaunch).isEqualTo(1) @@ -993,11 +993,11 @@ class NotificationSettingsPresenterTest { }.last() assertThat(initial.showCallRingtoneDialog).isFalse() - initial.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog) + initial.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog) val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last() assertThat(shown.showCallRingtoneDialog).isTrue() - shown.eventSink(NotificationSettingsEvents.DismissCallRingtoneDialog) + shown.eventSink(NotificationSettingsEvent.DismissCallRingtoneDialog) val hidden = consumeItemsUntilPredicate { !it.showCallRingtoneDialog }.last() assertThat(hidden.showCallRingtoneDialog).isFalse() cancelAndIgnoreRemainingEvents() @@ -1020,10 +1020,10 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid && it.callRingtone.sound == NotificationSound.Silent }.last() - initial.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog) + initial.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog) val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last() - shown.eventSink(NotificationSettingsEvents.SelectCallRingtonePreset(NotificationSound.SystemDefault)) + shown.eventSink(NotificationSettingsEvent.SelectCallRingtonePreset(NotificationSound.SystemDefault)) advanceUntilIdle() consumeItemsUntilPredicate { !it.showCallRingtoneDialog && it.callRingtone.sound == NotificationSound.SystemDefault @@ -1043,10 +1043,10 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid }.last() assertThat(initial.pendingCallRingtonePickerLaunch).isEqualTo(0) - initial.eventSink(NotificationSettingsEvents.ShowCallRingtoneDialog) + initial.eventSink(NotificationSettingsEvent.ShowCallRingtoneDialog) val shown = consumeItemsUntilPredicate { it.showCallRingtoneDialog }.last() - shown.eventSink(NotificationSettingsEvents.LaunchCallRingtonePicker) + shown.eventSink(NotificationSettingsEvent.LaunchCallRingtonePicker) val launched = consumeItemsUntilPredicate { it.pendingCallRingtonePickerLaunch == 1 }.last() assertThat(launched.showCallRingtoneDialog).isFalse() assertThat(launched.pendingCallRingtonePickerLaunch).isEqualTo(1) @@ -1078,7 +1078,7 @@ class NotificationSettingsPresenterTest { it.matrixSettings is NotificationSettingsState.MatrixSettings.Valid && it.callRingtone.sound == NotificationSound.Silent }.last() - initial.eventSink(NotificationSettingsEvents.SelectCallRingtonePreset(NotificationSound.SystemDefault)) + initial.eventSink(NotificationSettingsEvent.SelectCallRingtonePreset(NotificationSound.SystemDefault)) advanceUntilIdle() val after = consumeItemsUntilPredicate { it.callRingtone.sound == NotificationSound.SystemDefault diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsViewTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsViewTest.kt index 57edf01a1d..a28f43638f 100644 --- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsViewTest.kt +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsViewTest.kt @@ -35,7 +35,7 @@ import org.robolectric.annotation.Config class NotificationSettingsViewTest : RobolectricTest() { @Test fun `clicking on back invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() ensureCalledOnce { setNotificationSettingsView( state = aValidNotificationSettingsState( @@ -45,13 +45,13 @@ class NotificationSettingsViewTest : RobolectricTest() { ) pressBack() } - eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled) + eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled) } @Config(qualifiers = "h1280dp") @Test fun `clicking on troubleshoot notification invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() ensureCalledOnce { setNotificationSettingsView( state = aValidNotificationSettingsState( @@ -61,13 +61,13 @@ class NotificationSettingsViewTest : RobolectricTest() { ) clickOn(R.string.troubleshoot_notifications_entry_point_title) } - eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled) + eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled) } @Config(qualifiers = "h1024dp") @Test fun `clicking on group chats invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() ensureCalledOnceWithParam(false) { setNotificationSettingsView( state = aValidNotificationSettingsState( @@ -77,13 +77,13 @@ class NotificationSettingsViewTest : RobolectricTest() { ) clickOn(R.string.screen_notification_settings_group_chats) } - eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled) + eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled) } @Config(qualifiers = "h1024dp") @Test fun `clicking on direct chats invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() ensureCalledOnceWithParam(true) { setNotificationSettingsView( state = aValidNotificationSettingsState( @@ -93,7 +93,7 @@ class NotificationSettingsViewTest : RobolectricTest() { ) clickOn(R.string.screen_notification_settings_direct_chats) } - eventsRecorder.assertSingle(NotificationSettingsEvents.RefreshSystemNotificationsEnabled) + eventsRecorder.assertSingle(NotificationSettingsEvent.RefreshSystemNotificationsEnabled) } @Config(qualifiers = "h1024dp") @@ -109,7 +109,7 @@ class NotificationSettingsViewTest : RobolectricTest() { } private fun testNotificationToggle(initialState: Boolean) = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( appNotificationEnabled = initialState, @@ -119,8 +119,8 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(R.string.screen_notification_settings_enable_notifications) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.SetNotificationsEnabled(!initialState) + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.SetNotificationsEnabled(!initialState) ) ) } @@ -138,7 +138,7 @@ class NotificationSettingsViewTest : RobolectricTest() { } private fun testAtRoomToggle(initialState: Boolean) = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( atRoomNotificationsEnabled = initialState, @@ -148,8 +148,8 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(R.string.screen_notification_settings_room_mention_label) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.SetAtRoomNotificationsEnabled(!initialState) + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.SetAtRoomNotificationsEnabled(!initialState) ) ) } @@ -167,7 +167,7 @@ class NotificationSettingsViewTest : RobolectricTest() { } private fun testInvitationToggle(initialState: Boolean) = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( inviteForMeNotificationsEnabled = initialState, @@ -177,8 +177,8 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(R.string.screen_notification_settings_invite_for_me_label) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(!initialState) + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.SetInviteForMeNotificationsEnabled(!initialState) ) ) } @@ -186,7 +186,7 @@ class NotificationSettingsViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `with an error configuration, clicking on continue emits the expected events`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( changeNotificationSettingAction = AsyncAction.Failure(AN_EXCEPTION), @@ -196,8 +196,8 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(CommonStrings.action_ok) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.ClearNotificationChangeError + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.ClearNotificationChangeError ) ) } @@ -205,7 +205,7 @@ class NotificationSettingsViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `with invalid configuration, clicking on continue emits the expected events`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aInvalidNotificationSettingsState( fixFailed = false, @@ -215,8 +215,8 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(CommonStrings.action_continue) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.FixConfigurationMismatch + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.FixConfigurationMismatch ) ) } @@ -224,7 +224,7 @@ class NotificationSettingsViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `with invalid configuration and error, clicking on OK emits the expected events`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aInvalidNotificationSettingsState( fixFailed = true, @@ -234,8 +234,8 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(CommonStrings.action_ok) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.ClearConfigurationMismatchError + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.ClearConfigurationMismatchError ) ) } @@ -243,7 +243,7 @@ class NotificationSettingsViewTest : RobolectricTest() { @Config(qualifiers = "h1280dp") @Test fun `clicking on Push notification provider emits the expected event`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( eventSink = eventsRecorder @@ -252,15 +252,15 @@ class NotificationSettingsViewTest : RobolectricTest() { clickOn(R.string.screen_advanced_settings_push_provider_android) eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.ChangePushProvider, + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.ChangePushProvider, ) ) } @Test fun `clicking on a push provider emits the expected event`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( eventSink = eventsRecorder, @@ -271,8 +271,8 @@ class NotificationSettingsViewTest : RobolectricTest() { onNodeWithText("P2").performClick() eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.SetPushProvider(1), + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.SetPushProvider(1), ) ) } @@ -280,7 +280,7 @@ class NotificationSettingsViewTest : RobolectricTest() { @Config(qualifiers = "h1280dp") @Test fun `sounds preference category renders rows with current display names`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState( eventSink = eventsRecorder, @@ -298,7 +298,7 @@ class NotificationSettingsViewTest : RobolectricTest() { @Config(qualifiers = "h1280dp") @Test fun `clicking the message sound row opens the preset dialog`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setNotificationSettingsView( state = aValidNotificationSettingsState(eventSink = eventsRecorder), ) @@ -308,8 +308,8 @@ class NotificationSettingsViewTest : RobolectricTest() { onNodeWithText("Message sound").performClick() eventsRecorder.assertList( listOf( - NotificationSettingsEvents.RefreshSystemNotificationsEnabled, - NotificationSettingsEvents.ShowMessageSoundDialog, + NotificationSettingsEvent.RefreshSystemNotificationsEnabled, + NotificationSettingsEvent.ShowMessageSoundDialog, ) ) }