From 198f3f2a0b7ec34dbcba6e39bc0d611c844c8abb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 15:19:18 +0000 Subject: [PATCH 1/3] fix(deps): update dependency org.matrix.rustcomponents:sdk-android to v25.12.4 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9c5126345c..71a1a097dc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -177,7 +177,7 @@ test_detekt_test = { module = "io.gitlab.arturbosch.detekt:detekt-test", version # https://github.com/matrix-org/matrix-rust-components-kotlin/commits/main/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt # All new features should not be implemented in the pull request that upgrades the version, developers should # only fix API breaks and may add some TODOs. -matrix_sdk = "org.matrix.rustcomponents:sdk-android:25.12.2" +matrix_sdk = "org.matrix.rustcomponents:sdk-android:25.12.4" # Others coil = { module = "io.coil-kt.coil3:coil", version.ref = "coil" } From e814906ba1bcdc4f0b20a7491ab87ed2aa7513eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 4 Dec 2025 16:55:22 +0100 Subject: [PATCH 2/3] Restore disabled tests with FFI fakes --- .../impl/RustMatrixClientFactoryTest.kt | 2 - .../matrix/impl/RustMatrixClientTest.kt | 2 - .../impl/auth/HomeserverDetailsKtTest.kt | 2 - ...HomeserverLoginCompatibilityCheckerTest.kt | 2 - .../RustMatrixAuthenticationServiceTest.kt | 4 +- .../auth/qrlogin/SdkQrCodeLoginDataTest.kt | 2 - .../RustNotificationServiceTest.kt | 13 ++----- .../RustNotificationSettingsServiceTest.kt | 4 +- .../impl/pushers/RustPushersServiceTest.kt | 2 - .../matrix/impl/room/RoomInfoExtTest.kt | 2 - .../matrix/impl/room/RoomInfoMapperTest.kt | 2 - .../matrix/impl/room/RustBaseRoomTest.kt | 2 - .../impl/room/join/DefaultJoinRoomTest.kt | 2 - .../room/member/RoomMemberListFetcherTest.kt | 2 - .../RustBaseRoomDirectoryListTest.kt | 2 - .../RustBaseRoomDirectoryServiceTest.kt | 4 +- .../impl/roomlist/RoomListFactoryTest.kt | 4 +- .../roomlist/RoomSummaryListProcessorTest.kt | 34 ++++++----------- .../roomlist/RustBaseRoomListServiceTest.kt | 2 - .../spaces/RoomSummaryListProcessorTest.kt | 37 ++++++------------- .../impl/spaces/RustSpaceRoomListTest.kt | 10 ++--- .../MatrixTimelineDiffProcessorTest.kt | 34 ++++++----------- .../matrix/impl/timeline/RustTimelineTest.kt | 2 - .../timeline/TimelineItemsSubscriberTest.kt | 13 ++----- 24 files changed, 49 insertions(+), 136 deletions(-) diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt index 471efa30a8..b81ddd713d 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt @@ -23,11 +23,9 @@ import io.element.android.services.toolbox.test.systemclock.FakeSystemClock import io.element.android.tests.testutils.testCoroutineDispatchers import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import java.io.File -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RustMatrixClientFactoryTest { @Test fun test() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientTest.kt index 06bd91eb24..c81d9f1c15 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientTest.kt @@ -31,13 +31,11 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.Client import org.matrix.rustcomponents.sdk.UserProfile import java.io.File -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RustMatrixClientTest { @Test fun `ensure that sessionId and deviceId can be retrieved from the client`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/HomeserverDetailsKtTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/HomeserverDetailsKtTest.kt index 82fa3dfbc7..a5c7b2dbc8 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/HomeserverDetailsKtTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/HomeserverDetailsKtTest.kt @@ -11,10 +11,8 @@ package io.element.android.libraries.matrix.impl.auth import com.google.common.truth.Truth.assertThat import io.element.android.libraries.matrix.api.auth.MatrixHomeServerDetails import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiHomeserverLoginDetails -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class HomeserverDetailsKtTest { @Test fun `map should be correct`() { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustHomeserverLoginCompatibilityCheckerTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustHomeserverLoginCompatibilityCheckerTest.kt index c0122b2a7c..50d1f3723b 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustHomeserverLoginCompatibilityCheckerTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustHomeserverLoginCompatibilityCheckerTest.kt @@ -14,10 +14,8 @@ import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiClient import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiClientBuilder import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiHomeserverLoginDetails import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RustHomeserverLoginCompatibilityCheckerTest { @Test fun `check - is valid if it supports OIDC login`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt index f620e942a9..f8f792557d 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt @@ -23,13 +23,11 @@ import io.element.android.libraries.sessionstorage.test.InMemorySessionStore import io.element.android.tests.testutils.testCoroutineDispatchers import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import java.io.File class RustMatrixAuthenticationServiceTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `setHomeserver is successful`() = runTest { val sut = createRustMatrixAuthenticationService( clientBuilderProvider = FakeClientBuilderProvider( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/qrlogin/SdkQrCodeLoginDataTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/qrlogin/SdkQrCodeLoginDataTest.kt index d4c71f2a83..a0c8f4598f 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/qrlogin/SdkQrCodeLoginDataTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/qrlogin/SdkQrCodeLoginDataTest.kt @@ -11,10 +11,8 @@ package io.element.android.libraries.matrix.impl.auth.qrlogin import com.google.common.truth.Truth.assertThat import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiQrCodeData import io.element.android.libraries.matrix.test.A_HOMESERVER_URL -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class SdkQrCodeLoginDataTest { @Test fun `getServer reads the value from the Rust side, null case`() { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationServiceTest.kt index e6fc802ed2..a1dffa7c64 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationServiceTest.kt @@ -29,15 +29,13 @@ import io.element.android.tests.testutils.lambda.lambdaRecorder import io.element.android.tests.testutils.testCoroutineDispatchers import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.NotificationClient import org.matrix.rustcomponents.sdk.NotificationStatus import org.matrix.rustcomponents.sdk.TimelineEventType class RustNotificationServiceTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun test() = runTest { val notificationClient = FakeFfiNotificationClient( notificationItemResult = mapOf(AN_EVENT_ID.value to aRustBatchNotificationResult()), @@ -58,8 +56,7 @@ class RustNotificationServiceTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `test mapping invalid item only drops that item`() = runTest { val error = IllegalStateException("This event type is not supported") val faultyEvent = object : FakeFfiTimelineEvent() { @@ -86,8 +83,7 @@ class RustNotificationServiceTest { assertThat(successfulResult?.isSuccess).isTrue() } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `test unable to resolve event`() = runTest { val notificationClient = FakeFfiNotificationClient( notificationItemResult = emptyMap(), @@ -99,8 +95,7 @@ class RustNotificationServiceTest { assertThat(exception).isInstanceOf(NotificationResolverException::class.java) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `close should invoke the close method of the service`() = runTest { val closeResult = lambdaRecorder { } val notificationClient = FakeFfiNotificationClient( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notificationsettings/RustNotificationSettingsServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notificationsettings/RustNotificationSettingsServiceTest.kt index 81d0a3307e..e9a121679b 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notificationsettings/RustNotificationSettingsServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/notificationsettings/RustNotificationSettingsServiceTest.kt @@ -16,13 +16,11 @@ import io.element.android.libraries.matrix.test.A_ROOM_ID import io.element.android.tests.testutils.testCoroutineDispatchers import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.NotificationSettings class RustNotificationSettingsServiceTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun test() = runTest { val sut = createRustNotificationSettingsService() val result = sut.getRoomNotificationSettings( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/pushers/RustPushersServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/pushers/RustPushersServiceTest.kt index 1843bf4dd1..61b2965cdd 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/pushers/RustPushersServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/pushers/RustPushersServiceTest.kt @@ -13,10 +13,8 @@ import io.element.android.libraries.matrix.api.pusher.UnsetHttpPusherData import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiClient import io.element.android.tests.testutils.testCoroutineDispatchers import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RustPushersServiceTest { @Test fun `setPusher should invoke the client method`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoExtTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoExtTest.kt index dc4eba261b..86a50c3926 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoExtTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoExtTest.kt @@ -14,10 +14,8 @@ import io.element.android.libraries.matrix.api.user.MatrixUser import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomHero import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomInfo import io.element.android.libraries.matrix.test.A_USER_ID -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RoomInfoExtTest { @Test fun `get non empty element Heroes`() { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoMapperTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoMapperTest.kt index c964f02950..5c1c4a2aa3 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoMapperTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RoomInfoMapperTest.kt @@ -32,7 +32,6 @@ import io.element.android.libraries.matrix.test.room.defaultRoomPowerLevelValues import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentMapOf import kotlinx.collections.immutable.toImmutableList -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.Membership import uniffi.matrix_sdk_base.EncryptionState @@ -40,7 +39,6 @@ import org.matrix.rustcomponents.sdk.JoinRule as RustJoinRule import org.matrix.rustcomponents.sdk.RoomHistoryVisibility as RustRoomHistoryVisibility import org.matrix.rustcomponents.sdk.RoomNotificationMode as RustRoomNotificationMode -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RoomInfoMapperTest { @Test fun `mapping of RustRoomInfo should map all the fields`() { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RustBaseRoomTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RustBaseRoomTest.kt index a98a222c1e..9c8feef2dc 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RustBaseRoomTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/RustBaseRoomTest.kt @@ -31,11 +31,9 @@ import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.isActive import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import uniffi.matrix_sdk.RoomMemberRole -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RustBaseRoomTest { @Test fun `RustBaseRoom should cancel the room coroutine scope when it is destroyed`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt index e4f0b02e33..52aaa62b97 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt @@ -25,10 +25,8 @@ import io.element.android.services.analytics.test.FakeAnalyticsService import io.element.android.tests.testutils.lambda.lambdaRecorder import io.element.android.tests.testutils.lambda.value import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class DefaultJoinRoomTest { @Test fun `when using roomId and there is no server names, the classic join room API is used`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/member/RoomMemberListFetcherTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/member/RoomMemberListFetcherTest.kt index 266a4eed7c..c1c436c405 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/member/RoomMemberListFetcherTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/member/RoomMemberListFetcherTest.kt @@ -24,10 +24,8 @@ import io.element.android.libraries.matrix.test.A_USER_ID_3 import io.element.android.libraries.matrix.test.A_USER_ID_4 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RoomMemberListFetcherTest { @Test fun `fetchRoomMembers with CACHE source - emits cached members, if any`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryListTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryListTest.kt index cf3260b85c..cf3c746ec0 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryListTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryListTest.kt @@ -19,12 +19,10 @@ import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.RoomDirectorySearch import org.matrix.rustcomponents.sdk.RoomDirectorySearchEntryUpdate -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") @OptIn(ExperimentalCoroutinesApi::class) class RustBaseRoomDirectoryListTest { @Test diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryServiceTest.kt index 04e6a9a3aa..a873298f3e 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomdirectory/RustBaseRoomDirectoryServiceTest.kt @@ -11,12 +11,10 @@ package io.element.android.libraries.matrix.impl.roomdirectory import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiClient import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test class RustBaseRoomDirectoryServiceTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun test() = runTest { val client = FakeFfiClient() val sut = RustRoomDirectoryService( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFactoryTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFactoryTest.kt index ec8053e940..741ed93af8 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFactoryTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFactoryTest.kt @@ -12,13 +12,11 @@ import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiRoomList import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiRoomListService import io.element.android.services.analytics.test.FakeAnalyticsService import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import kotlin.coroutines.EmptyCoroutineContext class RoomListFactoryTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `createRoomList should work`() = runTest { val sut = RoomListFactory( innerRoomListService = FakeFfiRoomListService(), diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt index eaa62abb65..bdc202d4fc 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt @@ -21,15 +21,13 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.RoomListEntriesUpdate class RoomSummaryListProcessorTest { private val summaries = MutableStateFlow>(emptyList()) - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Append adds new entries at the end of the list`() = runTest { summaries.value = listOf(aRoomSummary()) val processor = createProcessor() @@ -41,8 +39,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value.subList(1, 4).all { it.roomId == A_ROOM_ID_2 }).isTrue() } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PushBack adds a new entry at the end of the list`() = runTest { summaries.value = listOf(aRoomSummary()) val processor = createProcessor() @@ -52,8 +49,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value.last().roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PushFront inserts a new entry at the start of the list`() = runTest { summaries.value = listOf(aRoomSummary()) val processor = createProcessor() @@ -63,8 +59,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value.first().roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Set replaces an entry at some index`() = runTest { summaries.value = listOf(aRoomSummary()) val processor = createProcessor() @@ -76,8 +71,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Insert inserts a new entry at the provided index`() = runTest { summaries.value = listOf(aRoomSummary()) val processor = createProcessor() @@ -89,8 +83,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Remove removes an entry at some index`() = runTest { summaries.value = listOf( aRoomSummary(roomId = A_ROOM_ID), @@ -105,8 +98,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PopBack removes an entry at the end of the list`() = runTest { summaries.value = listOf( aRoomSummary(roomId = A_ROOM_ID), @@ -121,8 +113,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PopFront removes an entry at the start of the list`() = runTest { summaries.value = listOf( aRoomSummary(roomId = A_ROOM_ID), @@ -137,8 +128,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Clear removes all the entries`() = runTest { summaries.value = listOf( aRoomSummary(roomId = A_ROOM_ID), @@ -151,8 +141,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value).isEmpty() } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Truncate removes all entries after the provided length`() = runTest { summaries.value = listOf( aRoomSummary(roomId = A_ROOM_ID), @@ -167,8 +156,7 @@ class RoomSummaryListProcessorTest { assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Reset removes all entries and add the provided ones`() = runTest { summaries.value = listOf( aRoomSummary(roomId = A_ROOM_ID), diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RustBaseRoomListServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RustBaseRoomListServiceTest.kt index 9c8c0ddb69..88b57035e8 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RustBaseRoomListServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RustBaseRoomListServiceTest.kt @@ -19,12 +19,10 @@ import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicator import org.matrix.rustcomponents.sdk.RoomListService as RustRoomListService -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") @OptIn(ExperimentalCoroutinesApi::class) class RustBaseRoomListServiceTest { @Test diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RoomSummaryListProcessorTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RoomSummaryListProcessorTest.kt index 116b98aaeb..253fd58dff 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RoomSummaryListProcessorTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RoomSummaryListProcessorTest.kt @@ -18,15 +18,13 @@ import io.element.android.libraries.previewutils.room.aSpaceRoom import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.SpaceListUpdate class RoomSummaryListProcessorTest { private val spaceRoomsFlow = MutableStateFlow>(emptyList()) - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Append adds new entries at the end of the list`() = runTest { spaceRoomsFlow.value = listOf(aSpaceRoom()) val processor = createProcessor() @@ -38,8 +36,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value.subList(1, 4).all { it.roomId == A_ROOM_ID_2 }).isTrue() } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PushBack adds a new entry at the end of the list`() = runTest { spaceRoomsFlow.value = listOf(aSpaceRoom()) val processor = createProcessor() @@ -49,8 +46,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value.last().roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PushFront inserts a new entry at the start of the list`() = runTest { spaceRoomsFlow.value = listOf(aSpaceRoom()) val processor = createProcessor() @@ -60,8 +56,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value.first().roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Set replaces an entry at some index`() = runTest { spaceRoomsFlow.value = listOf(aSpaceRoom()) val processor = createProcessor() @@ -73,8 +68,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Insert inserts a new entry at the provided index`() = runTest { spaceRoomsFlow.value = listOf(aSpaceRoom()) val processor = createProcessor() @@ -86,8 +80,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Remove removes an entry at some index`() = runTest { spaceRoomsFlow.value = listOf( aSpaceRoom(roomId = A_ROOM_ID), @@ -102,8 +95,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PopBack removes an entry at the end of the list`() = runTest { spaceRoomsFlow.value = listOf( aSpaceRoom(roomId = A_ROOM_ID), @@ -118,8 +110,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PopFront removes an entry at the start of the list`() = runTest { spaceRoomsFlow.value = listOf( aSpaceRoom(roomId = A_ROOM_ID), @@ -134,8 +125,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID_2) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Clear removes all the entries`() = runTest { spaceRoomsFlow.value = listOf( aSpaceRoom(roomId = A_ROOM_ID), @@ -148,8 +138,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value).isEmpty() } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Truncate removes all entries after the provided length`() = runTest { spaceRoomsFlow.value = listOf( aSpaceRoom(roomId = A_ROOM_ID), @@ -164,8 +153,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Reset removes all entries and add the provided ones`() = runTest { spaceRoomsFlow.value = listOf( aSpaceRoom(roomId = A_ROOM_ID), @@ -180,8 +168,7 @@ class RoomSummaryListProcessorTest { assertThat(spaceRoomsFlow.value[index].roomId).isEqualTo(A_ROOM_ID_3) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `When there is no replay cache SpaceListUpdateProcessor starts with an empty list`() = runTest { val spaceRoomsSharedFlow = MutableSharedFlow>(replay = 1) val processor = createProcessor( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RustSpaceRoomListTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RustSpaceRoomListTest.kt index 74cc97d66e..a0f8181c48 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RustSpaceRoomListTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/spaces/RustSpaceRoomListTest.kt @@ -23,15 +23,13 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.SpaceListUpdate import uniffi.matrix_sdk_ui.SpaceRoomListPaginationState import org.matrix.rustcomponents.sdk.SpaceRoomList as InnerSpaceRoomList class RustSpaceRoomListTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `paginationStatusFlow emits values`() = runTest { val innerSpaceRoomList = FakeFfiSpaceRoomList( paginationStateResult = { SpaceRoomListPaginationState.Idle(false) } @@ -53,8 +51,7 @@ class RustSpaceRoomListTest { } } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `spaceRoomsFlow emits values`() = runTest { val innerSpaceRoomList = FakeFfiSpaceRoomList( paginationStateResult = { SpaceRoomListPaginationState.Idle(false) } @@ -76,8 +73,7 @@ class RustSpaceRoomListTest { } } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `paginate invokes paginate on the inner class`() = runTest { val paginateResult = lambdaRecorder { } val innerSpaceRoomList = FakeFfiSpaceRoomList( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/MatrixTimelineDiffProcessorTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/MatrixTimelineDiffProcessorTest.kt index ba7f640514..9b5af1ffb4 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/MatrixTimelineDiffProcessorTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/MatrixTimelineDiffProcessorTest.kt @@ -21,7 +21,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.TimelineDiff @@ -31,8 +30,7 @@ class MatrixTimelineDiffProcessorTest { private val anEvent = MatrixTimelineItem.Event(A_UNIQUE_ID, anEventTimelineItem()) private val anEvent2 = MatrixTimelineItem.Event(A_UNIQUE_ID_2, anEventTimelineItem()) - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Append adds new entries at the end of the list`() = runTest { timelineItems.value = listOf(anEvent) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -44,8 +42,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PushBack adds a new entry at the end of the list`() = runTest { timelineItems.value = listOf(anEvent) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -57,8 +54,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PushFront inserts a new entry at the start of the list`() = runTest { timelineItems.value = listOf(anEvent) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -70,8 +66,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Set replaces an entry at some index`() = runTest { timelineItems.value = listOf(anEvent, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -83,8 +78,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Insert inserts a new entry at the provided index`() = runTest { timelineItems.value = listOf(anEvent, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -97,8 +91,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Remove removes an entry at some index`() = runTest { timelineItems.value = listOf(anEvent, MatrixTimelineItem.Other, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -110,8 +103,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PopBack removes an entry at the end of the list`() = runTest { timelineItems.value = listOf(anEvent, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -122,8 +114,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `PopFront removes an entry at the start of the list`() = runTest { timelineItems.value = listOf(anEvent, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -134,8 +125,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Clear removes all the entries`() = runTest { timelineItems.value = listOf(anEvent, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -143,8 +133,7 @@ class MatrixTimelineDiffProcessorTest { assertThat(timelineItems.value).isEmpty() } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Truncate removes all entries after the provided length`() = runTest { timelineItems.value = listOf(anEvent, MatrixTimelineItem.Other, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) @@ -155,8 +144,7 @@ class MatrixTimelineDiffProcessorTest { ) } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `Reset removes all entries and add the provided ones`() = runTest { timelineItems.value = listOf(anEvent, MatrixTimelineItem.Other, anEvent2) val processor = createMatrixTimelineDiffProcessor(timelineItems) diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimelineTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimelineTest.kt index 1dde04575e..ab46e8aa5f 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimelineTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimelineTest.kt @@ -30,13 +30,11 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.TimelineDiff import uniffi.matrix_sdk.RoomPaginationStatus import org.matrix.rustcomponents.sdk.Timeline as InnerTimeline -@Ignore("JNA direct mapping has broken unit tests with FFI fakes") class RustTimelineTest { @Test fun `ensure that the timeline emits new loading item when pagination does not bring new events`() = runTest { diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriberTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriberTest.kt index 4accf26e68..607f575a2d 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriberTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/TimelineItemsSubscriberTest.kt @@ -20,7 +20,6 @@ import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Ignore import org.junit.Test import org.matrix.rustcomponents.sdk.Timeline import org.matrix.rustcomponents.sdk.TimelineDiff @@ -28,8 +27,7 @@ import uniffi.matrix_sdk_ui.EventItemOrigin @OptIn(ExperimentalCoroutinesApi::class) class TimelineItemsSubscriberTest { - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `when timeline emits an empty list of items, the flow must emits an empty list`() = runTest { val timelineItems: MutableSharedFlow> = MutableSharedFlow(replay = 1, extraBufferCapacity = Int.MAX_VALUE) @@ -52,8 +50,7 @@ class TimelineItemsSubscriberTest { } } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `when timeline emits a non empty list of items, the flow must emits a non empty list`() = runTest { val timelineItems: MutableSharedFlow> = MutableSharedFlow(replay = 1, extraBufferCapacity = Int.MAX_VALUE) @@ -76,8 +73,7 @@ class TimelineItemsSubscriberTest { } } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `when timeline emits an item with SYNC origin`() = runTest { val timelineItems: MutableSharedFlow> = MutableSharedFlow(replay = 1, extraBufferCapacity = Int.MAX_VALUE) @@ -108,8 +104,7 @@ class TimelineItemsSubscriberTest { } } - @Ignore("JNA direct mapping has broken unit tests with FFI fakes") - @Test + @Test fun `multiple subscriptions does not have side effect`() = runTest { val timelineItemsSubscriber = createTimelineItemsSubscriber() timelineItemsSubscriber.subscribeIfNeeded() From 5d88a04ab0f5a194a45aa48014cafbb991e450cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 4 Dec 2025 18:02:59 +0100 Subject: [PATCH 3/3] Add missing abstractions and fakes --- .../matrix/impl/RustMatrixClientFactory.kt | 14 ++++---- .../matrix/impl/storage/SqliteStoreBuilder.kt | 35 +++++++++++++++++++ .../storage/SqliteStoreBuilderProvider.kt | 23 ++++++++++++ .../matrix/impl/FakeFfiSqliteStoreBuilder.kt | 19 ++++++++++ .../impl/RustMatrixClientFactoryTest.kt | 2 ++ .../RustMatrixAuthenticationServiceTest.kt | 2 +- .../impl/fixtures/fakes/FakeFfiClient.kt | 3 ++ .../fixtures/fakes/FakeFfiClientBuilder.kt | 1 + .../matrix/impl/fixtures/fakes/FakeFfiRoom.kt | 6 ++++ .../roomlist/RoomSummaryListProcessorTest.kt | 2 ++ .../impl/storage/FakeSqliteStoreBuilder.kt | 18 ++++++++++ .../storage/FakeSqliteStoreBuilderProvider.kt | 16 +++++++++ 12 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilder.kt create mode 100644 libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilderProvider.kt create mode 100644 libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/FakeFfiSqliteStoreBuilder.kt create mode 100644 libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilder.kt create mode 100644 libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilderProvider.kt diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactory.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactory.kt index 4e335ae082..58e3485279 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactory.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactory.kt @@ -22,6 +22,7 @@ import io.element.android.libraries.matrix.impl.paths.SessionPaths import io.element.android.libraries.matrix.impl.paths.getSessionPaths import io.element.android.libraries.matrix.impl.proxy.ProxyProvider import io.element.android.libraries.matrix.impl.room.TimelineEventTypeFilterFactory +import io.element.android.libraries.matrix.impl.storage.SqliteStoreBuilderProvider import io.element.android.libraries.matrix.impl.util.anonymizedTokens import io.element.android.libraries.network.useragent.UserAgentProvider import io.element.android.libraries.sessionstorage.api.SessionData @@ -36,7 +37,6 @@ import org.matrix.rustcomponents.sdk.RequestConfig import org.matrix.rustcomponents.sdk.Session import org.matrix.rustcomponents.sdk.SlidingSyncVersion import org.matrix.rustcomponents.sdk.SlidingSyncVersionBuilder -import org.matrix.rustcomponents.sdk.SqliteStoreBuilder import org.matrix.rustcomponents.sdk.use import timber.log.Timber import uniffi.matrix_sdk_base.MediaRetentionPolicy @@ -62,6 +62,7 @@ class RustMatrixClientFactory( private val featureFlagService: FeatureFlagService, private val timelineEventTypeFilterFactory: TimelineEventTypeFilterFactory, private val clientBuilderProvider: ClientBuilderProvider, + private val sqliteStoreBuilderProvider: SqliteStoreBuilderProvider, ) { private val sessionDelegate = RustClientSessionDelegate(sessionStore, appCoroutineScope, coroutineDispatchers) @@ -126,12 +127,11 @@ class RustMatrixClientFactory( slidingSyncType: ClientBuilderSlidingSync, ): ClientBuilder { return clientBuilderProvider.provide() - .sqliteStore( - SqliteStoreBuilder( - dataPath = sessionPaths.fileDirectory.absolutePath, - cachePath = sessionPaths.cacheDirectory.absolutePath, - ).passphrase(passphrase) - ) + .run { + sqliteStoreBuilderProvider.provide(sessionPaths) + .passphrase(passphrase) + .setupClientBuilder(this) + } .setSessionDelegate(sessionDelegate) .userAgent(userAgentProvider.provide()) .addRootCertificates(userCertificatesProvider.provides()) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilder.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilder.kt new file mode 100644 index 0000000000..7b5d9fb31c --- /dev/null +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilder.kt @@ -0,0 +1,35 @@ +/* + * 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.storage + +import io.element.android.libraries.matrix.impl.paths.SessionPaths +import org.matrix.rustcomponents.sdk.ClientBuilder +import org.matrix.rustcomponents.sdk.SqliteStoreBuilder as SdkSqliteStoreBuilder + +interface SqliteStoreBuilder { + fun passphrase(passphrase: String?): SqliteStoreBuilder + fun setupClientBuilder(clientBuilder: ClientBuilder): ClientBuilder +} + +class RustSqliteStoreBuilder( + private val sessionPaths: SessionPaths, +) : SqliteStoreBuilder { + private var inner = SdkSqliteStoreBuilder( + dataPath = sessionPaths.fileDirectory.absolutePath, + cachePath = sessionPaths.cacheDirectory.absolutePath, + ) + + override fun passphrase(passphrase: String?): SqliteStoreBuilder { + inner = inner.passphrase(passphrase) + return this + } + + override fun setupClientBuilder(clientBuilder: ClientBuilder): ClientBuilder { + return clientBuilder.sqliteStore(this.inner) + } +} diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilderProvider.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilderProvider.kt new file mode 100644 index 0000000000..29a30f3c56 --- /dev/null +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/storage/SqliteStoreBuilderProvider.kt @@ -0,0 +1,23 @@ +/* + * 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.storage + +import dev.zacsweers.metro.AppScope +import dev.zacsweers.metro.ContributesBinding +import io.element.android.libraries.matrix.impl.paths.SessionPaths + +interface SqliteStoreBuilderProvider { + fun provide(sessionPaths: SessionPaths): SqliteStoreBuilder +} + +@ContributesBinding(AppScope::class) +class RustSqliteStoreBuilderProvider : SqliteStoreBuilderProvider { + override fun provide(sessionPaths: SessionPaths): SqliteStoreBuilder { + return RustSqliteStoreBuilder(sessionPaths) + } +} diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/FakeFfiSqliteStoreBuilder.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/FakeFfiSqliteStoreBuilder.kt new file mode 100644 index 0000000000..8e3240f5be --- /dev/null +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/FakeFfiSqliteStoreBuilder.kt @@ -0,0 +1,19 @@ +/* + * 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 + +import org.matrix.rustcomponents.sdk.NoHandle +import org.matrix.rustcomponents.sdk.SqliteStoreBuilder + +class FakeFfiSqliteStoreBuilder : SqliteStoreBuilder(NoHandle) { + override fun cacheSize(cacheSize: UInt?): SqliteStoreBuilder = this + override fun journalSizeLimit(limit: UInt?): SqliteStoreBuilder = this + override fun passphrase(passphrase: String?): SqliteStoreBuilder = this + override fun poolMaxSize(poolMaxSize: UInt?): SqliteStoreBuilder = this + override fun systemIsMemoryConstrained(): SqliteStoreBuilder = this +} diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt index b81ddd713d..a1b52d430a 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClientFactoryTest.kt @@ -14,6 +14,7 @@ import io.element.android.libraries.matrix.api.core.SessionId import io.element.android.libraries.matrix.impl.auth.FakeProxyProvider import io.element.android.libraries.matrix.impl.auth.FakeUserCertificatesProvider import io.element.android.libraries.matrix.impl.room.FakeTimelineEventTypeFilterFactory +import io.element.android.libraries.matrix.impl.storage.FakeSqliteStoreBuilderProvider import io.element.android.libraries.network.useragent.SimpleUserAgentProvider import io.element.android.libraries.sessionstorage.api.SessionStore import io.element.android.libraries.sessionstorage.test.InMemorySessionStore @@ -55,4 +56,5 @@ fun TestScope.createRustMatrixClientFactory( featureFlagService = FakeFeatureFlagService(), timelineEventTypeFilterFactory = FakeTimelineEventTypeFilterFactory(), clientBuilderProvider = clientBuilderProvider, + sqliteStoreBuilderProvider = FakeSqliteStoreBuilderProvider(), ) diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt index f8f792557d..f4ce7b1fdd 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationServiceTest.kt @@ -27,7 +27,7 @@ import org.junit.Test import java.io.File class RustMatrixAuthenticationServiceTest { - @Test + @Test fun `setHomeserver is successful`() = runTest { val sut = createRustMatrixAuthenticationService( clientBuilderProvider = FakeClientBuilderProvider( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClient.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClient.kt index a2227ab63a..3196cd1173 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClient.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClient.kt @@ -33,6 +33,7 @@ import org.matrix.rustcomponents.sdk.SyncServiceBuilder import org.matrix.rustcomponents.sdk.TaskHandle import org.matrix.rustcomponents.sdk.UnableToDecryptDelegate import org.matrix.rustcomponents.sdk.UserProfile +import uniffi.matrix_sdk_base.MediaRetentionPolicy class FakeFfiClient( private val userId: String = A_USER_ID.value, @@ -88,5 +89,7 @@ class FakeFfiClient( return homeserverLoginDetailsResult() } + override suspend fun setMediaRetentionPolicy(policy: MediaRetentionPolicy) {} + override fun close() = closeResult() } diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClientBuilder.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClientBuilder.kt index 3ac1fefd7e..fa10a63e42 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClientBuilder.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiClientBuilder.kt @@ -44,5 +44,6 @@ class FakeFfiClientBuilder( override fun enableShareHistoryOnInvite(enableShareHistoryOnInvite: Boolean): ClientBuilder = this override fun threadsEnabled(enabled: Boolean, threadSubscriptions: Boolean): ClientBuilder = this override fun sqliteStore(config: SqliteStoreBuilder): ClientBuilder = this + override fun inMemoryStore(): ClientBuilder = this override suspend fun build() = buildResult() } diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiRoom.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiRoom.kt index 86625c9737..7b60a9f4c2 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiRoom.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeFfiRoom.kt @@ -13,6 +13,7 @@ import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomInfo import io.element.android.libraries.matrix.test.A_ROOM_ID import io.element.android.tests.testutils.lambda.lambdaError import org.matrix.rustcomponents.sdk.EventTimelineItem +import org.matrix.rustcomponents.sdk.LatestEventValue import org.matrix.rustcomponents.sdk.NoHandle import org.matrix.rustcomponents.sdk.Room import org.matrix.rustcomponents.sdk.RoomInfo @@ -25,6 +26,7 @@ class FakeFfiRoom( private val getMembersNoSync: () -> RoomMembersIterator = { lambdaError() }, private val leaveLambda: () -> Unit = { lambdaError() }, private val latestEventLambda: () -> EventTimelineItem? = { lambdaError() }, + private val newLatestEventLambda: () -> LatestEventValue = { lambdaError() }, private val suggestedRoleForUserLambda: (String) -> RoomMemberRole = { lambdaError() }, private val roomInfo: RoomInfo = aRustRoomInfo(id = roomId.value), ) : Room(NoHandle) { @@ -56,6 +58,10 @@ class FakeFfiRoom( return suggestedRoleForUserLambda(userId) } + override suspend fun newLatestEvent(): LatestEventValue { + return newLatestEventLambda() + } + override fun close() { // No-op } diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt index bdc202d4fc..36d5b81f42 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryListProcessorTest.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest import org.junit.Test +import org.matrix.rustcomponents.sdk.LatestEventValue import org.matrix.rustcomponents.sdk.RoomListEntriesUpdate class RoomSummaryListProcessorTest { @@ -174,6 +175,7 @@ class RoomSummaryListProcessorTest { private fun aRustRoom(roomId: RoomId = A_ROOM_ID) = FakeFfiRoom( roomId = roomId, latestEventLambda = { null }, + newLatestEventLambda = { LatestEventValue.None } ) private fun TestScope.createProcessor() = RoomSummaryListProcessor( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilder.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilder.kt new file mode 100644 index 0000000000..2f12587f5a --- /dev/null +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilder.kt @@ -0,0 +1,18 @@ +/* + * 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.storage + +import org.matrix.rustcomponents.sdk.ClientBuilder + +class FakeSqliteStoreBuilder : SqliteStoreBuilder { + override fun passphrase(passphrase: String?): SqliteStoreBuilder = this + + override fun setupClientBuilder(clientBuilder: ClientBuilder): ClientBuilder { + return clientBuilder + } +} diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilderProvider.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilderProvider.kt new file mode 100644 index 0000000000..b196604ca4 --- /dev/null +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/storage/FakeSqliteStoreBuilderProvider.kt @@ -0,0 +1,16 @@ +/* + * 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.storage + +import io.element.android.libraries.matrix.impl.paths.SessionPaths + +class FakeSqliteStoreBuilderProvider : SqliteStoreBuilderProvider { + override fun provide(sessionPaths: SessionPaths): SqliteStoreBuilder { + return FakeSqliteStoreBuilder() + } +}