Skip to content

Commit de673c9

Browse files
authored
Merge pull request #4239 from element-hq/feature/bma/fixNightlyReports2
Fix nightly reports - next step
2 parents 5456f0e + 54af229 commit de673c9

File tree

4 files changed

+149
-7
lines changed

4 files changed

+149
-7
lines changed

features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockStateProvider.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ open class PinUnlockStateProvider : PreviewParameterProvider<PinUnlockState> {
2323
aPinUnlockState(showWrongPinTitle = true),
2424
aPinUnlockState(showSignOutPrompt = true),
2525
aPinUnlockState(showBiometricUnlock = false),
26-
aPinUnlockState(showSignOutPrompt = true, remainingAttempts = 0),
26+
aPinUnlockState(showSignOutPrompt = true, remainingAttempts = AsyncData.Success(0)),
2727
aPinUnlockState(signOutAction = AsyncAction.Loading),
28-
aPinUnlockState(biometricUnlockResult = BiometricAuthenticator.AuthenticationResult.Failure(
29-
BiometricUnlockError(BiometricPrompt.ERROR_LOCKOUT, "Biometric auth disabled")
30-
)),
28+
aPinUnlockState(
29+
biometricUnlockResult = BiometricAuthenticator.AuthenticationResult.Failure(
30+
BiometricUnlockError(BiometricPrompt.ERROR_LOCKOUT, "Biometric auth disabled")
31+
)
32+
),
3133
)
3234
}
3335

3436
fun aPinUnlockState(
3537
pinEntry: PinEntry = PinEntry.createEmpty(4),
36-
remainingAttempts: Int = 3,
38+
remainingAttempts: AsyncData<Int> = AsyncData.Success(3),
3739
showWrongPinTitle: Boolean = false,
3840
showSignOutPrompt: Boolean = false,
3941
showBiometricUnlock: Boolean = true,
@@ -43,7 +45,7 @@ fun aPinUnlockState(
4345
) = PinUnlockState(
4446
pinEntry = AsyncData.Success(pinEntry),
4547
showWrongPinTitle = showWrongPinTitle,
46-
remainingAttempts = AsyncData.Success(remainingAttempts),
48+
remainingAttempts = remainingAttempts,
4749
showSignOutPrompt = showSignOutPrompt,
4850
showBiometricUnlock = showBiometricUnlock,
4951
signOutAction = signOutAction,
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright 2025 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
package io.element.android.features.lockscreen.impl.unlock
9+
10+
import androidx.biometric.BiometricPrompt
11+
import com.google.common.truth.Truth.assertThat
12+
import io.element.android.features.lockscreen.impl.biometric.BiometricAuthenticator
13+
import io.element.android.features.lockscreen.impl.biometric.BiometricUnlockError
14+
import io.element.android.libraries.architecture.AsyncData
15+
import org.junit.Test
16+
17+
class PinUnlockStateTest {
18+
@Test
19+
fun `isSignOutPromptCancellable should have expected values`() {
20+
assertThat(aPinUnlockState(remainingAttempts = AsyncData.Uninitialized).isSignOutPromptCancellable).isTrue()
21+
assertThat(aPinUnlockState(remainingAttempts = AsyncData.Success(1)).isSignOutPromptCancellable).isTrue()
22+
assertThat(aPinUnlockState(remainingAttempts = AsyncData.Success(0)).isSignOutPromptCancellable).isFalse()
23+
}
24+
25+
@Test
26+
fun `biometricUnlockErrorMessage and showBiometricUnlockError should have expected values`() {
27+
listOf(
28+
null,
29+
BiometricAuthenticator.AuthenticationResult.Failure(),
30+
BiometricAuthenticator.AuthenticationResult.Success,
31+
).forEach { biometricUnlockResult ->
32+
aPinUnlockState(
33+
biometricUnlockResult = biometricUnlockResult,
34+
).let {
35+
assertThat(it.biometricUnlockErrorMessage).isNull()
36+
assertThat(it.showBiometricUnlockError).isFalse()
37+
}
38+
}
39+
listOf(
40+
BiometricPrompt.ERROR_HW_UNAVAILABLE,
41+
BiometricPrompt.ERROR_UNABLE_TO_PROCESS,
42+
BiometricPrompt.ERROR_TIMEOUT,
43+
BiometricPrompt.ERROR_NO_SPACE,
44+
BiometricPrompt.ERROR_CANCELED,
45+
BiometricPrompt.ERROR_VENDOR,
46+
BiometricPrompt.ERROR_USER_CANCELED,
47+
BiometricPrompt.ERROR_NO_BIOMETRICS,
48+
BiometricPrompt.ERROR_HW_NOT_PRESENT,
49+
BiometricPrompt.ERROR_NEGATIVE_BUTTON,
50+
BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL,
51+
BiometricPrompt.ERROR_SECURITY_UPDATE_REQUIRED,
52+
).forEach { code ->
53+
aPinUnlockState(
54+
biometricUnlockResult = BiometricAuthenticator.AuthenticationResult.Failure(
55+
error = BiometricUnlockError(code, "Error message")
56+
),
57+
).let {
58+
assertThat(it.biometricUnlockErrorMessage).isNull()
59+
assertThat(it.showBiometricUnlockError).isFalse()
60+
}
61+
}
62+
listOf(
63+
BiometricPrompt.ERROR_LOCKOUT,
64+
BiometricPrompt.ERROR_LOCKOUT_PERMANENT,
65+
).forEach { code ->
66+
aPinUnlockState(
67+
biometricUnlockResult = BiometricAuthenticator.AuthenticationResult.Failure(
68+
error = BiometricUnlockError(code, "Error message")
69+
),
70+
).let {
71+
assertThat(it.biometricUnlockErrorMessage).isEqualTo("Error message")
72+
assertThat(it.showBiometricUnlockError).isTrue()
73+
}
74+
}
75+
}
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2025 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
package io.element.android.features.securebackup.impl.root
9+
10+
import com.google.common.truth.Truth.assertThat
11+
import io.element.android.libraries.architecture.AsyncData
12+
import io.element.android.libraries.matrix.api.encryption.BackupState
13+
import io.element.android.libraries.matrix.test.AN_EXCEPTION
14+
import org.junit.Test
15+
16+
class SecureBackupRootStateTest {
17+
@Test
18+
fun `isKeyStorageEnabled should be true for all these backup states`() {
19+
listOf(
20+
BackupState.CREATING,
21+
BackupState.ENABLING,
22+
BackupState.RESUMING,
23+
BackupState.DOWNLOADING,
24+
BackupState.ENABLED,
25+
).forEach { backupState ->
26+
assertThat(aSecureBackupRootState(backupState = backupState).isKeyStorageEnabled).isTrue()
27+
}
28+
}
29+
30+
@Test
31+
fun `isKeyStorageEnabled should be false for all these backup states`() {
32+
listOf(
33+
BackupState.WAITING_FOR_SYNC,
34+
BackupState.DISABLING,
35+
).forEach { backupState ->
36+
assertThat(aSecureBackupRootState(backupState = backupState).isKeyStorageEnabled).isFalse()
37+
}
38+
}
39+
40+
@Test
41+
fun `isKeyStorageEnabled should have value depending on doesBackupExistOnServer when state is UNKNOWN`() {
42+
assertThat(
43+
aSecureBackupRootState(
44+
backupState = BackupState.UNKNOWN,
45+
doesBackupExistOnServer = AsyncData.Success(true),
46+
).isKeyStorageEnabled
47+
).isTrue()
48+
49+
listOf(
50+
AsyncData.Uninitialized,
51+
AsyncData.Loading(),
52+
AsyncData.Failure(AN_EXCEPTION),
53+
AsyncData.Success(false),
54+
).forEach { doesBackupExistOnServer ->
55+
assertThat(
56+
aSecureBackupRootState(
57+
backupState = BackupState.UNKNOWN,
58+
doesBackupExistOnServer = doesBackupExistOnServer,
59+
).isKeyStorageEnabled
60+
).isFalse()
61+
}
62+
}
63+
}

plugins/src/main/kotlin/extension/KoverExtension.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ fun Project.setupKover() {
5454
description = "Verifies the code coverage of all subprojects."
5555
val dependencies = listOf(":app:koverVerifyGplayDebug") + koverVariants.map { ":app:koverVerify${it.replaceFirstChar(Char::titlecase)}" }
5656
dependsOn(dependencies)
57-
5857
}
5958
// https://kotlin.github.io/kotlinx-kover/
6059
// Run `./gradlew :app:koverHtmlReport` to get report at ./app/build/reports/kover
@@ -180,7 +179,9 @@ fun Project.setupKover() {
180179
"io.element.android.libraries.matrix.api.timeline.item.event.OtherState$*",
181180
"io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState*",
182181
"io.element.android.libraries.mediaviewer.impl.local.pdf.PdfViewerState",
182+
"io.element.android.libraries.mediaviewer.impl.local.player.MediaPlayerControllerState",
183183
"io.element.android.libraries.textcomposer.model.TextEditorState",
184+
"io.element.android.libraries.textcomposer.components.FormattingOptionState",
184185
)
185186
includes.classes("*State")
186187
}

0 commit comments

Comments
 (0)