quality: fix formatting and test
This commit is contained in:
parent
40bd16b1eb
commit
3ba79a6e10
5 changed files with 39 additions and 14 deletions
|
|
@ -11,7 +11,7 @@ package io.element.android.features.securityandprivacy.impl.root
|
||||||
sealed interface SecurityAndPrivacyEvents {
|
sealed interface SecurityAndPrivacyEvents {
|
||||||
data object EditRoomAddress : SecurityAndPrivacyEvents
|
data object EditRoomAddress : SecurityAndPrivacyEvents
|
||||||
data object Save : SecurityAndPrivacyEvents
|
data object Save : SecurityAndPrivacyEvents
|
||||||
data object Exit: SecurityAndPrivacyEvents
|
data object Exit : SecurityAndPrivacyEvents
|
||||||
data object DismissExitConfirmation : SecurityAndPrivacyEvents
|
data object DismissExitConfirmation : SecurityAndPrivacyEvents
|
||||||
data class ChangeRoomAccess(val roomAccess: SecurityAndPrivacyRoomAccess) : SecurityAndPrivacyEvents
|
data class ChangeRoomAccess(val roomAccess: SecurityAndPrivacyRoomAccess) : SecurityAndPrivacyEvents
|
||||||
data object ToggleEncryptionState : SecurityAndPrivacyEvents
|
data object ToggleEncryptionState : SecurityAndPrivacyEvents
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ import androidx.compose.runtime.setValue
|
||||||
import dev.zacsweers.metro.Assisted
|
import dev.zacsweers.metro.Assisted
|
||||||
import dev.zacsweers.metro.AssistedFactory
|
import dev.zacsweers.metro.AssistedFactory
|
||||||
import dev.zacsweers.metro.AssistedInject
|
import dev.zacsweers.metro.AssistedInject
|
||||||
|
import io.element.android.features.securityandprivacy.api.securityAndPrivacyPermissionsAsState
|
||||||
import io.element.android.features.securityandprivacy.impl.SecurityAndPrivacyNavigator
|
import io.element.android.features.securityandprivacy.impl.SecurityAndPrivacyNavigator
|
||||||
import io.element.android.features.securityandprivacy.impl.editroomaddress.matchesServer
|
import io.element.android.features.securityandprivacy.impl.editroomaddress.matchesServer
|
||||||
import io.element.android.features.securityandprivacy.api.securityAndPrivacyPermissionsAsState
|
|
||||||
import io.element.android.libraries.architecture.AsyncAction
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.architecture.AsyncData
|
import io.element.android.libraries.architecture.AsyncData
|
||||||
import io.element.android.libraries.architecture.AsyncData.*
|
import io.element.android.libraries.architecture.AsyncData.*
|
||||||
|
|
@ -65,7 +65,7 @@ class SecurityAndPrivacyPresenter(
|
||||||
featureFlagService.isFeatureEnabledFlow(FeatureFlags.Knock)
|
featureFlagService.isFeatureEnabledFlow(FeatureFlags.Knock)
|
||||||
}.collectAsState(false)
|
}.collectAsState(false)
|
||||||
val saveAction = remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized) }
|
val saveAction = remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized) }
|
||||||
var confirmExitAction by remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized)}
|
var confirmExitAction by remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized) }
|
||||||
val homeserverName = remember { matrixClient.userIdServerName() }
|
val homeserverName = remember { matrixClient.userIdServerName() }
|
||||||
val syncUpdateFlow = room.syncUpdateFlow.collectAsState()
|
val syncUpdateFlow = room.syncUpdateFlow.collectAsState()
|
||||||
val roomInfo by room.roomInfoFlow.collectAsState()
|
val roomInfo by room.roomInfoFlow.collectAsState()
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ fun aSecurityAndPrivacyState(
|
||||||
canChangeRoomVisibility = true
|
canChangeRoomVisibility = true
|
||||||
),
|
),
|
||||||
isKnockEnabled: Boolean = true,
|
isKnockEnabled: Boolean = true,
|
||||||
isSpace: Boolean,
|
isSpace: Boolean = false,
|
||||||
eventSink: (SecurityAndPrivacyEvents) -> Unit = {}
|
eventSink: (SecurityAndPrivacyEvents) -> Unit = {}
|
||||||
) = SecurityAndPrivacyState(
|
) = SecurityAndPrivacyState(
|
||||||
editedSettings = editedSettings,
|
editedSettings = editedSettings,
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ private fun RoomAccessSection(
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(text = stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_title)) },
|
headlineContent = { Text(text = stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_title)) },
|
||||||
supportingContent = { Text(text = stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_description)) },
|
supportingContent = { Text(text = stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_description)) },
|
||||||
trailingContent = ListItemContent.RadioButton(selected = edited == SecurityAndPrivacyRoomAccess.SpaceMember, enabled = false),
|
trailingContent = ListItemContent.RadioButton(selected = edited == SecurityAndPrivacyRoomAccess.SpaceMember, enabled = false),
|
||||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Workspace())),
|
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Workspace())),
|
||||||
enabled = false,
|
enabled = false,
|
||||||
)
|
)
|
||||||
|
|
@ -243,7 +243,6 @@ private fun RoomAccessSection(
|
||||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Lock())),
|
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Lock())),
|
||||||
onClick = { onSelectOption(SecurityAndPrivacyRoomAccess.InviteOnly) },
|
onClick = { onSelectOption(SecurityAndPrivacyRoomAccess.InviteOnly) },
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ import io.element.android.features.securityandprivacy.impl.root.SecurityAndPriva
|
||||||
import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyView
|
import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyView
|
||||||
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacySettings
|
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacySettings
|
||||||
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacyState
|
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacyState
|
||||||
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.architecture.AsyncData
|
import io.element.android.libraries.architecture.AsyncData
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
import io.element.android.tests.testutils.EnsureNeverCalled
|
import io.element.android.tests.testutils.EnsureNeverCalled
|
||||||
import io.element.android.tests.testutils.EventsRecorder
|
import io.element.android.tests.testutils.EventsRecorder
|
||||||
import io.element.android.tests.testutils.clickOn
|
import io.element.android.tests.testutils.clickOn
|
||||||
import io.element.android.tests.testutils.ensureCalledOnce
|
|
||||||
import io.element.android.tests.testutils.pressBack
|
import io.element.android.tests.testutils.pressBack
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -39,15 +39,41 @@ class SecurityAndPrivacyViewTest {
|
||||||
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `click on back invokes expected callback`() {
|
fun `click on back invokes emits the expected event`() {
|
||||||
ensureCalledOnce { callback ->
|
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||||
rule.setSecurityAndPrivacyView(
|
val state = aSecurityAndPrivacyState(
|
||||||
onBackClick = callback,
|
eventSink = recorder,
|
||||||
)
|
)
|
||||||
rule.pressBack()
|
rule.setSecurityAndPrivacyView(state)
|
||||||
}
|
rule.pressBack()
|
||||||
|
recorder.assertSingle(SecurityAndPrivacyEvents.Exit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `confirm cancellation emits the expected event`() {
|
||||||
|
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||||
|
val state = aSecurityAndPrivacyState(
|
||||||
|
confirmExitAction = AsyncAction.ConfirmingCancellation,
|
||||||
|
eventSink = recorder,
|
||||||
|
)
|
||||||
|
rule.setSecurityAndPrivacyView(state)
|
||||||
|
rule.clickOn(CommonStrings.action_ok)
|
||||||
|
recorder.assertSingle(SecurityAndPrivacyEvents.Exit)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `dismiss cancellation confirmation emits the expected event`() {
|
||||||
|
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||||
|
val state = aSecurityAndPrivacyState(
|
||||||
|
confirmExitAction = AsyncAction.ConfirmingCancellation,
|
||||||
|
eventSink = recorder,
|
||||||
|
)
|
||||||
|
rule.setSecurityAndPrivacyView(state)
|
||||||
|
rule.clickOn(CommonStrings.action_cancel)
|
||||||
|
recorder.assertSingle(SecurityAndPrivacyEvents.DismissExitConfirmation)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `click on room access item emits the expected event`() {
|
fun `click on room access item emits the expected event`() {
|
||||||
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue