From 12ca8a21869a960dfa411d6f484bdadb17d9fe60 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 3 Dec 2025 16:13:12 +0100 Subject: [PATCH] SecurityAndPrivacyEvents -> SecurityAndPrivacyEvent --- ...cyEvents.kt => SecurityAndPrivacyEvent.kt} | 24 +++++----- .../impl/root/SecurityAndPrivacyPresenter.kt | 24 +++++----- .../impl/root/SecurityAndPrivacyState.kt | 2 +- .../root/SecurityAndPrivacyStateProvider.kt | 2 +- .../impl/root/SecurityAndPrivacyView.kt | 30 ++++++------ .../impl/SecurityAndPrivacyPresenterTest.kt | 48 +++++++++---------- .../impl/SecurityAndPrivacyViewTest.kt | 44 ++++++++--------- 7 files changed, 87 insertions(+), 87 deletions(-) rename features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/{SecurityAndPrivacyEvents.kt => SecurityAndPrivacyEvent.kt} (55%) diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyEvents.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyEvent.kt similarity index 55% rename from features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyEvents.kt rename to features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyEvent.kt index b1d739c45b..39abedab8c 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyEvents.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyEvent.kt @@ -8,16 +8,16 @@ package io.element.android.features.securityandprivacy.impl.root -sealed interface SecurityAndPrivacyEvents { - data object EditRoomAddress : SecurityAndPrivacyEvents - data object Save : SecurityAndPrivacyEvents - data object Exit : SecurityAndPrivacyEvents - data object DismissExitConfirmation : SecurityAndPrivacyEvents - data class ChangeRoomAccess(val roomAccess: SecurityAndPrivacyRoomAccess) : SecurityAndPrivacyEvents - data object ToggleEncryptionState : SecurityAndPrivacyEvents - data object CancelEnableEncryption : SecurityAndPrivacyEvents - data object ConfirmEnableEncryption : SecurityAndPrivacyEvents - data class ChangeHistoryVisibility(val historyVisibility: SecurityAndPrivacyHistoryVisibility) : SecurityAndPrivacyEvents - data object ToggleRoomVisibility : SecurityAndPrivacyEvents - data object DismissSaveError : SecurityAndPrivacyEvents +sealed interface SecurityAndPrivacyEvent { + data object EditRoomAddress : SecurityAndPrivacyEvent + data object Save : SecurityAndPrivacyEvent + data object Exit : SecurityAndPrivacyEvent + data object DismissExitConfirmation : SecurityAndPrivacyEvent + data class ChangeRoomAccess(val roomAccess: SecurityAndPrivacyRoomAccess) : SecurityAndPrivacyEvent + data object ToggleEncryptionState : SecurityAndPrivacyEvent + data object CancelEnableEncryption : SecurityAndPrivacyEvent + data object ConfirmEnableEncryption : SecurityAndPrivacyEvent + data class ChangeHistoryVisibility(val historyVisibility: SecurityAndPrivacyHistoryVisibility) : SecurityAndPrivacyEvent + data object ToggleRoomVisibility : SecurityAndPrivacyEvent + data object DismissSaveError : SecurityAndPrivacyEvent } diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt index cdd70259c4..b77ad0e7d6 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt @@ -108,9 +108,9 @@ class SecurityAndPrivacyPresenter( var showEnableEncryptionConfirmation by remember(savedSettings.isEncrypted) { mutableStateOf(false) } val permissions by room.securityAndPrivacyPermissionsAsState(syncUpdateFlow.value) - fun handleEvent(event: SecurityAndPrivacyEvents) { + fun handleEvent(event: SecurityAndPrivacyEvent) { when (event) { - SecurityAndPrivacyEvents.Save -> { + SecurityAndPrivacyEvent.Save -> { coroutineScope.save( saveAction = saveAction, isVisibleInRoomDirectory = savedIsVisibleInRoomDirectory, @@ -118,44 +118,44 @@ class SecurityAndPrivacyPresenter( editedSettings = editedSettings ) } - is SecurityAndPrivacyEvents.ChangeRoomAccess -> { + is SecurityAndPrivacyEvent.ChangeRoomAccess -> { editedRoomAccess = event.roomAccess } - is SecurityAndPrivacyEvents.ToggleEncryptionState -> { + is SecurityAndPrivacyEvent.ToggleEncryptionState -> { if (editedIsEncrypted) { editedIsEncrypted = false } else { showEnableEncryptionConfirmation = true } } - is SecurityAndPrivacyEvents.ChangeHistoryVisibility -> { + is SecurityAndPrivacyEvent.ChangeHistoryVisibility -> { editedHistoryVisibility = event.historyVisibility } - SecurityAndPrivacyEvents.ToggleRoomVisibility -> { + SecurityAndPrivacyEvent.ToggleRoomVisibility -> { editedVisibleInRoomDirectory = when (val edited = editedVisibleInRoomDirectory) { is AsyncData.Success -> AsyncData.Success(!edited.data) else -> edited } } - SecurityAndPrivacyEvents.EditRoomAddress -> navigator.openEditRoomAddress() - SecurityAndPrivacyEvents.CancelEnableEncryption -> { + SecurityAndPrivacyEvent.EditRoomAddress -> navigator.openEditRoomAddress() + SecurityAndPrivacyEvent.CancelEnableEncryption -> { showEnableEncryptionConfirmation = false } - SecurityAndPrivacyEvents.ConfirmEnableEncryption -> { + SecurityAndPrivacyEvent.ConfirmEnableEncryption -> { showEnableEncryptionConfirmation = false editedIsEncrypted = true } - SecurityAndPrivacyEvents.DismissSaveError -> { + SecurityAndPrivacyEvent.DismissSaveError -> { saveAction.value = AsyncAction.Uninitialized } - SecurityAndPrivacyEvents.Exit -> { + SecurityAndPrivacyEvent.Exit -> { saveAction.value = if (savedSettings == editedSettings || saveAction.value == AsyncAction.ConfirmingCancellation) { AsyncAction.Success(Unit) } else { AsyncAction.ConfirmingCancellation } } - SecurityAndPrivacyEvents.DismissExitConfirmation -> { + SecurityAndPrivacyEvent.DismissExitConfirmation -> { saveAction.value = AsyncAction.Uninitialized } } diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt index 61e8ffd17c..2c6bd59e12 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt @@ -24,7 +24,7 @@ data class SecurityAndPrivacyState( val saveAction: AsyncAction, val isSpace: Boolean, private val permissions: SecurityAndPrivacyPermissions, - val eventSink: (SecurityAndPrivacyEvents) -> Unit + val eventSink: (SecurityAndPrivacyEvent) -> Unit ) { val canBeSaved = savedSettings != editedSettings diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt index db696b18e8..b5347a753f 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt @@ -117,7 +117,7 @@ fun aSecurityAndPrivacyState( ), isKnockEnabled: Boolean = true, isSpace: Boolean = false, - eventSink: (SecurityAndPrivacyEvents) -> Unit = {} + eventSink: (SecurityAndPrivacyEvent) -> Unit = {} ) = SecurityAndPrivacyState( editedSettings = editedSettings, savedSettings = savedSettings, diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyView.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyView.kt index d526f381be..add719153a 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyView.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyView.kt @@ -60,7 +60,7 @@ fun SecurityAndPrivacyView( modifier: Modifier = Modifier, ) { BackHandler { - state.eventSink(SecurityAndPrivacyEvents.Exit) + state.eventSink(SecurityAndPrivacyEvent.Exit) } Scaffold( modifier = modifier, @@ -68,10 +68,10 @@ fun SecurityAndPrivacyView( SecurityAndPrivacyToolbar( isSaveActionEnabled = state.canBeSaved, onBackClick = { - state.eventSink(SecurityAndPrivacyEvents.Exit) + state.eventSink(SecurityAndPrivacyEvent.Exit) }, onSaveClick = { - state.eventSink(SecurityAndPrivacyEvents.Save) + state.eventSink(SecurityAndPrivacyEvent.Save) }, ) } @@ -90,7 +90,7 @@ fun SecurityAndPrivacyView( edited = state.editedSettings.roomAccess, saved = state.savedSettings.roomAccess, isKnockEnabled = state.isKnockEnabled, - onSelectOption = { state.eventSink(SecurityAndPrivacyEvents.ChangeRoomAccess(it)) }, + onSelectOption = { state.eventSink(SecurityAndPrivacyEvent.ChangeRoomAccess(it)) }, ) } if (state.showRoomVisibilitySections) { @@ -98,10 +98,10 @@ fun SecurityAndPrivacyView( RoomAddressSection( roomAddress = state.editedSettings.address, homeserverName = state.homeserverName, - onRoomAddressClick = { state.eventSink(SecurityAndPrivacyEvents.EditRoomAddress) }, + onRoomAddressClick = { state.eventSink(SecurityAndPrivacyEvent.EditRoomAddress) }, isVisibleInRoomDirectory = state.editedSettings.isVisibleInRoomDirectory, onVisibilityChange = { - state.eventSink(SecurityAndPrivacyEvents.ToggleRoomVisibility) + state.eventSink(SecurityAndPrivacyEvent.ToggleRoomVisibility) }, ) } @@ -110,10 +110,10 @@ fun SecurityAndPrivacyView( isRoomEncrypted = state.editedSettings.isEncrypted, // encryption can't be disabled once enabled canToggleEncryption = !state.savedSettings.isEncrypted, - onToggleEncryption = { state.eventSink(SecurityAndPrivacyEvents.ToggleEncryptionState) }, + onToggleEncryption = { state.eventSink(SecurityAndPrivacyEvent.ToggleEncryptionState) }, showConfirmation = state.showEnableEncryptionConfirmation, - onDismissConfirmation = { state.eventSink(SecurityAndPrivacyEvents.CancelEnableEncryption) }, - onConfirmEncryption = { state.eventSink(SecurityAndPrivacyEvents.ConfirmEnableEncryption) }, + onDismissConfirmation = { state.eventSink(SecurityAndPrivacyEvent.CancelEnableEncryption) }, + onConfirmEncryption = { state.eventSink(SecurityAndPrivacyEvent.ConfirmEnableEncryption) }, ) } if (state.showHistoryVisibilitySection) { @@ -121,7 +121,7 @@ fun SecurityAndPrivacyView( editedOption = state.editedSettings.historyVisibility, savedOptions = state.savedSettings.historyVisibility, availableOptions = state.availableHistoryVisibilities, - onSelectOption = { state.eventSink(SecurityAndPrivacyEvents.ChangeHistoryVisibility(it)) }, + onSelectOption = { state.eventSink(SecurityAndPrivacyEvent.ChangeHistoryVisibility(it)) }, ) } } @@ -129,14 +129,14 @@ fun SecurityAndPrivacyView( AsyncActionView( async = state.saveAction, onSuccess = { }, - onErrorDismiss = { state.eventSink(SecurityAndPrivacyEvents.DismissSaveError) }, + onErrorDismiss = { state.eventSink(SecurityAndPrivacyEvent.DismissSaveError) }, confirmationDialog = { confirming -> when (confirming) { is AsyncAction.ConfirmingCancellation -> SaveChangesDialog( - onSaveClick = { state.eventSink(SecurityAndPrivacyEvents.Save) }, - onDiscardClick = { state.eventSink(SecurityAndPrivacyEvents.Exit) }, - onDismiss = { state.eventSink(SecurityAndPrivacyEvents.DismissExitConfirmation) } + onSaveClick = { state.eventSink(SecurityAndPrivacyEvent.Save) }, + onDiscardClick = { state.eventSink(SecurityAndPrivacyEvent.Exit) }, + onDismiss = { state.eventSink(SecurityAndPrivacyEvent.DismissExitConfirmation) } ) } }, @@ -146,7 +146,7 @@ fun SecurityAndPrivacyView( progressText = stringResource(CommonStrings.common_saving), ) }, - onRetry = { state.eventSink(SecurityAndPrivacyEvents.Save) }, + onRetry = { state.eventSink(SecurityAndPrivacyEvent.Save) }, ) } diff --git a/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyPresenterTest.kt b/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyPresenterTest.kt index 203447c911..7d88706996 100644 --- a/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyPresenterTest.kt +++ b/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyPresenterTest.kt @@ -9,7 +9,7 @@ package io.element.android.features.securityandprivacy.impl import com.google.common.truth.Truth.assertThat -import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyEvents +import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyEvent import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyHistoryVisibility import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyPresenter import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyRoomAccess @@ -96,13 +96,13 @@ class SecurityAndPrivacyPresenterTest { with(awaitItem()) { assertThat(editedSettings.roomAccess).isEqualTo(SecurityAndPrivacyRoomAccess.InviteOnly) assertThat(showRoomVisibilitySections).isFalse() - eventSink(SecurityAndPrivacyEvents.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.Anyone)) + eventSink(SecurityAndPrivacyEvent.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.Anyone)) } with(awaitItem()) { assertThat(editedSettings.roomAccess).isEqualTo(SecurityAndPrivacyRoomAccess.Anyone) assertThat(showRoomVisibilitySections).isTrue() assertThat(canBeSaved).isTrue() - eventSink(SecurityAndPrivacyEvents.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.InviteOnly)) + eventSink(SecurityAndPrivacyEvent.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.InviteOnly)) } with(awaitItem()) { assertThat(editedSettings.roomAccess).isEqualTo(SecurityAndPrivacyRoomAccess.InviteOnly) @@ -119,12 +119,12 @@ class SecurityAndPrivacyPresenterTest { skipItems(1) with(awaitItem()) { assertThat(editedSettings.historyVisibility).isEqualTo(SecurityAndPrivacyHistoryVisibility.SinceSelection) - eventSink(SecurityAndPrivacyEvents.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.SinceInvite)) + eventSink(SecurityAndPrivacyEvent.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.SinceInvite)) } with(awaitItem()) { assertThat(editedSettings.historyVisibility).isEqualTo(SecurityAndPrivacyHistoryVisibility.SinceInvite) assertThat(canBeSaved).isTrue() - eventSink(SecurityAndPrivacyEvents.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.SinceSelection)) + eventSink(SecurityAndPrivacyEvent.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.SinceSelection)) } with(awaitItem()) { assertThat(editedSettings.historyVisibility).isEqualTo(SecurityAndPrivacyHistoryVisibility.SinceSelection) @@ -140,26 +140,26 @@ class SecurityAndPrivacyPresenterTest { skipItems(1) with(awaitItem()) { assertThat(editedSettings.isEncrypted).isFalse() - eventSink(SecurityAndPrivacyEvents.ToggleEncryptionState) + eventSink(SecurityAndPrivacyEvent.ToggleEncryptionState) } with(awaitItem()) { assertThat(showEnableEncryptionConfirmation).isTrue() - eventSink(SecurityAndPrivacyEvents.CancelEnableEncryption) + eventSink(SecurityAndPrivacyEvent.CancelEnableEncryption) } with(awaitItem()) { assertThat(showEnableEncryptionConfirmation).isFalse() - eventSink(SecurityAndPrivacyEvents.ToggleEncryptionState) + eventSink(SecurityAndPrivacyEvent.ToggleEncryptionState) } with(awaitItem()) { assertThat(showEnableEncryptionConfirmation).isTrue() - eventSink(SecurityAndPrivacyEvents.ConfirmEnableEncryption) + eventSink(SecurityAndPrivacyEvent.ConfirmEnableEncryption) } skipItems(1) with(awaitItem()) { assertThat(editedSettings.isEncrypted).isTrue() assertThat(showEnableEncryptionConfirmation).isFalse() assertThat(canBeSaved).isTrue() - eventSink(SecurityAndPrivacyEvents.ToggleEncryptionState) + eventSink(SecurityAndPrivacyEvent.ToggleEncryptionState) } skipItems(1) with(awaitItem()) { @@ -186,12 +186,12 @@ class SecurityAndPrivacyPresenterTest { } with(awaitItem()) { assertThat(editedSettings.isVisibleInRoomDirectory).isEqualTo(AsyncData.Success(false)) - eventSink(SecurityAndPrivacyEvents.ToggleRoomVisibility) + eventSink(SecurityAndPrivacyEvent.ToggleRoomVisibility) } with(awaitItem()) { assertThat(editedSettings.isVisibleInRoomDirectory).isEqualTo(AsyncData.Success(true)) assertThat(canBeSaved).isTrue() - eventSink(SecurityAndPrivacyEvents.ToggleRoomVisibility) + eventSink(SecurityAndPrivacyEvent.ToggleRoomVisibility) } with(awaitItem()) { assertThat(editedSettings.isVisibleInRoomDirectory).isEqualTo(AsyncData.Success(false)) @@ -208,7 +208,7 @@ class SecurityAndPrivacyPresenterTest { presenter.test { skipItems(1) with(awaitItem()) { - eventSink(SecurityAndPrivacyEvents.EditRoomAddress) + eventSink(SecurityAndPrivacyEvent.EditRoomAddress) } assert(openEditRoomAddressLambda).isCalledOnce() } @@ -243,23 +243,23 @@ class SecurityAndPrivacyPresenterTest { skipItems(2) with(awaitItem()) { assertThat(editedSettings.roomAccess).isEqualTo(SecurityAndPrivacyRoomAccess.InviteOnly) - eventSink(SecurityAndPrivacyEvents.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.Anyone)) + eventSink(SecurityAndPrivacyEvent.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.Anyone)) } with(awaitItem()) { - eventSink(SecurityAndPrivacyEvents.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.Anyone)) + eventSink(SecurityAndPrivacyEvent.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.Anyone)) } with(awaitItem()) { assertThat(editedSettings.historyVisibility).isEqualTo(SecurityAndPrivacyHistoryVisibility.Anyone) - eventSink(SecurityAndPrivacyEvents.ConfirmEnableEncryption) + eventSink(SecurityAndPrivacyEvent.ConfirmEnableEncryption) } skipItems(1) with(awaitItem()) { assertThat(editedSettings.isEncrypted).isTrue() - eventSink(SecurityAndPrivacyEvents.ToggleRoomVisibility) + eventSink(SecurityAndPrivacyEvent.ToggleRoomVisibility) } with(awaitItem()) { assertThat(editedSettings.isVisibleInRoomDirectory).isEqualTo(AsyncData.Success(true)) - eventSink(SecurityAndPrivacyEvents.Save) + eventSink(SecurityAndPrivacyEvent.Save) } with(awaitItem()) { assertThat(saveAction).isEqualTo(AsyncAction.Loading) @@ -311,23 +311,23 @@ class SecurityAndPrivacyPresenterTest { skipItems(2) with(awaitItem()) { assertThat(editedSettings.roomAccess).isEqualTo(SecurityAndPrivacyRoomAccess.InviteOnly) - eventSink(SecurityAndPrivacyEvents.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.Anyone)) + eventSink(SecurityAndPrivacyEvent.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.Anyone)) } with(awaitItem()) { - eventSink(SecurityAndPrivacyEvents.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.Anyone)) + eventSink(SecurityAndPrivacyEvent.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.Anyone)) } with(awaitItem()) { assertThat(editedSettings.historyVisibility).isEqualTo(SecurityAndPrivacyHistoryVisibility.Anyone) - eventSink(SecurityAndPrivacyEvents.ConfirmEnableEncryption) + eventSink(SecurityAndPrivacyEvent.ConfirmEnableEncryption) } skipItems(1) with(awaitItem()) { assertThat(editedSettings.isEncrypted).isTrue() - eventSink(SecurityAndPrivacyEvents.ToggleRoomVisibility) + eventSink(SecurityAndPrivacyEvent.ToggleRoomVisibility) } with(awaitItem()) { assertThat(editedSettings.isVisibleInRoomDirectory).isEqualTo(AsyncData.Success(true)) - eventSink(SecurityAndPrivacyEvents.Save) + eventSink(SecurityAndPrivacyEvent.Save) } with(awaitItem()) { assertThat(saveAction).isEqualTo(AsyncAction.Loading) @@ -352,7 +352,7 @@ class SecurityAndPrivacyPresenterTest { assert(updateRoomVisibilityLambda).isCalledOnce() assert(updateRoomHistoryVisibilityLambda).isCalledOnce() // Clear error - state.eventSink(SecurityAndPrivacyEvents.DismissSaveError) + state.eventSink(SecurityAndPrivacyEvent.DismissSaveError) with(awaitItem()) { assertThat(saveAction).isEqualTo(AsyncAction.Uninitialized) } diff --git a/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyViewTest.kt b/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyViewTest.kt index d1096c19af..6b429c04ea 100644 --- a/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyViewTest.kt +++ b/features/securityandprivacy/impl/src/test/kotlin/io/element/android/features/securityandprivacy/impl/SecurityAndPrivacyViewTest.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.test.ext.junit.runners.AndroidJUnit4 -import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyEvents +import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyEvent import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyHistoryVisibility import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyRoomAccess import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyState @@ -39,53 +39,53 @@ class SecurityAndPrivacyViewTest { @Test fun `click on back invokes emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, ) rule.setSecurityAndPrivacyView(state) rule.pressBack() - recorder.assertSingle(SecurityAndPrivacyEvents.Exit) + recorder.assertSingle(SecurityAndPrivacyEvent.Exit) } @Test fun `discard cancellation emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( saveAction = AsyncAction.ConfirmingCancellation, eventSink = recorder, ) rule.setSecurityAndPrivacyView(state) rule.clickOn(CommonStrings.action_discard) - recorder.assertSingle(SecurityAndPrivacyEvents.Exit) + recorder.assertSingle(SecurityAndPrivacyEvent.Exit) } @Test fun `save cancellation confirmation emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( saveAction = AsyncAction.ConfirmingCancellation, eventSink = recorder, ) rule.setSecurityAndPrivacyView(state) rule.clickOn(CommonStrings.action_save, inDialog = true) - recorder.assertSingle(SecurityAndPrivacyEvents.Save) + recorder.assertSingle(SecurityAndPrivacyEvent.Save) } @Test fun `click on room access item emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, ) rule.setSecurityAndPrivacyView(state) rule.clickOn(R.string.screen_security_and_privacy_room_access_invite_only_option_title) - recorder.assertSingle(SecurityAndPrivacyEvents.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.InviteOnly)) + recorder.assertSingle(SecurityAndPrivacyEvent.ChangeRoomAccess(SecurityAndPrivacyRoomAccess.InviteOnly)) } @Test fun `click on disabled save doesn't emit event`() { - val recorder = EventsRecorder(expectEvents = false) + val recorder = EventsRecorder(expectEvents = false) val state = aSecurityAndPrivacyState(eventSink = recorder) rule.setSecurityAndPrivacyView(state) rule.clickOn(CommonStrings.action_save) @@ -94,7 +94,7 @@ class SecurityAndPrivacyViewTest { @Test fun `click on enabled save emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, editedSettings = aSecurityAndPrivacySettings( @@ -103,14 +103,14 @@ class SecurityAndPrivacyViewTest { ) rule.setSecurityAndPrivacyView(state) rule.clickOn(CommonStrings.action_save) - recorder.assertSingle(SecurityAndPrivacyEvents.Save) + recorder.assertSingle(SecurityAndPrivacyEvent.Save) } @Test @Config(qualifiers = "h640dp") fun `click on room address item emits the expected event`() { val address = "@alias:matrix.org" - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, editedSettings = aSecurityAndPrivacySettings( @@ -120,13 +120,13 @@ class SecurityAndPrivacyViewTest { ) rule.setSecurityAndPrivacyView(state) rule.onNodeWithText(address).performClick() - recorder.assertSingle(SecurityAndPrivacyEvents.EditRoomAddress) + recorder.assertSingle(SecurityAndPrivacyEvent.EditRoomAddress) } @Test @Config(qualifiers = "h1024dp") fun `click on room visibility item emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, editedSettings = aSecurityAndPrivacySettings( @@ -136,13 +136,13 @@ class SecurityAndPrivacyViewTest { ) rule.setSecurityAndPrivacyView(state) rule.clickOn(R.string.screen_security_and_privacy_room_directory_visibility_toggle_title) - recorder.assertSingle(SecurityAndPrivacyEvents.ToggleRoomVisibility) + recorder.assertSingle(SecurityAndPrivacyEvent.ToggleRoomVisibility) } @Test @Config(qualifiers = "h640dp") fun `click on history visibility item emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, editedSettings = aSecurityAndPrivacySettings( @@ -151,32 +151,32 @@ class SecurityAndPrivacyViewTest { ) rule.setSecurityAndPrivacyView(state) rule.clickOn(R.string.screen_security_and_privacy_room_history_since_selecting_option_title) - recorder.assertSingle(SecurityAndPrivacyEvents.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.SinceSelection)) + recorder.assertSingle(SecurityAndPrivacyEvent.ChangeHistoryVisibility(SecurityAndPrivacyHistoryVisibility.SinceSelection)) } @Test @Config(qualifiers = "h640dp") fun `click on encryption item emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, savedSettings = aSecurityAndPrivacySettings(isEncrypted = false), ) rule.setSecurityAndPrivacyView(state) rule.clickOn(R.string.screen_security_and_privacy_encryption_toggle_title) - recorder.assertSingle(SecurityAndPrivacyEvents.ToggleEncryptionState) + recorder.assertSingle(SecurityAndPrivacyEvent.ToggleEncryptionState) } @Test fun `click on encryption confirm emits the expected event`() { - val recorder = EventsRecorder() + val recorder = EventsRecorder() val state = aSecurityAndPrivacyState( eventSink = recorder, showEncryptionConfirmation = true, ) rule.setSecurityAndPrivacyView(state) rule.clickOn(R.string.screen_security_and_privacy_enable_encryption_alert_confirm_button_title) - recorder.assertSingle(SecurityAndPrivacyEvents.ConfirmEnableEncryption) + recorder.assertSingle(SecurityAndPrivacyEvent.ConfirmEnableEncryption) } }