diff --git a/features/linknewdevice/impl/src/main/res/values/localazy.xml b/features/linknewdevice/impl/src/main/res/values/localazy.xml index 9bf7ac2132..321b168751 100644 --- a/features/linknewdevice/impl/src/main/res/values/localazy.xml +++ b/features/linknewdevice/impl/src/main/res/values/localazy.xml @@ -38,6 +38,8 @@ "Sign in request cancelled" "The sign in was declined on the other device." "Sign in declined" + "You don’t need to do anything else." + "Your other device is already signed in" "Sign in expired. Please try again." "The sign in was not completed in time" "Your other device does not support signing in to %s with a QR code. diff --git a/features/login/impl/src/main/res/values/localazy.xml b/features/login/impl/src/main/res/values/localazy.xml index 9b235558c8..832c3b7f71 100644 --- a/features/login/impl/src/main/res/values/localazy.xml +++ b/features/login/impl/src/main/res/values/localazy.xml @@ -60,6 +60,8 @@ "Sign in request cancelled" "The sign in was declined on the other device." "Sign in declined" + "You don’t need to do anything else." + "Your other device is already signed in" "Sign in expired. Please try again." "The sign in was not completed in time" "Your other device does not support signing in to %s with a QR code. diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiCheckCodeSender.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiCheckCodeSender.kt index 4bc6c212d2..a19c4e3766 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiCheckCodeSender.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiCheckCodeSender.kt @@ -7,7 +7,14 @@ package io.element.android.libraries.matrix.impl.fixtures.fakes +import io.element.android.tests.testutils.lambda.lambdaError import org.matrix.rustcomponents.sdk.CheckCodeSender import org.matrix.rustcomponents.sdk.NoHandle -class FakeFfiCheckCodeSender : CheckCodeSender(NoHandle) +class FakeFfiCheckCodeSender( + private val sendResult: (UByte) -> Unit = { _ -> lambdaError() } +) : CheckCodeSender(NoHandle) { + override suspend fun send(code: UByte) { + sendResult(code) + } +} diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/RustCheckCodeSenderTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/RustCheckCodeSenderTest.kt new file mode 100644 index 0000000000..5fb4698976 --- /dev/null +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/RustCheckCodeSenderTest.kt @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Element Creations Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. + * Please see LICENSE files in the repository root for full details. + */ + +package io.element.android.libraries.matrix.impl.linknewdevice + +import com.google.common.truth.Truth.assertThat +import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiCheckCodeSender +import io.element.android.tests.testutils.lambda.lambdaRecorder +import io.element.android.tests.testutils.lambda.value +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.runTest +import org.junit.Test + +class RustCheckCodeSenderTest { + @Test + fun `send invokes the Ffi object`() = runTest { + val sendResult = lambdaRecorder { } + val sut = RustCheckCodeSender( + inner = FakeFfiCheckCodeSender( + sendResult = sendResult, + ), + sessionDispatcher = StandardTestDispatcher(testScheduler), + ) + sut.send(1.toUByte()) + sendResult.assertions().isCalledOnce().with(value(1.toUByte())) + } + + @Test + fun `validate always returns true for now`() = runTest { + val sut = RustCheckCodeSender( + inner = FakeFfiCheckCodeSender(), + sessionDispatcher = StandardTestDispatcher(testScheduler), + ) + val result = sut.validate(1.toUByte()) + assertThat(result).isTrue() + } +}