Skip to content

Rename classes overriding classes from the FFI layer. #4817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

package io.element.android.libraries.matrix.impl

import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustClientBuilder
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiClientBuilder
import org.matrix.rustcomponents.sdk.ClientBuilder

class FakeClientBuilderProvider : ClientBuilderProvider {
override fun provide(): ClientBuilder {
return FakeRustClientBuilder()
return FakeFfiClientBuilder()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ package io.element.android.libraries.matrix.impl

import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustClient
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustSyncService
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiClient
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiSyncService
import io.element.android.libraries.matrix.impl.room.FakeTimelineEventTypeFilterFactory
import io.element.android.libraries.matrix.test.A_DEVICE_ID
import io.element.android.libraries.matrix.test.A_USER_ID
Expand Down Expand Up @@ -40,7 +40,7 @@ class RustMatrixClientTest {
val clearCachesResult = lambdaRecorder<Unit> { }
val closeResult = lambdaRecorder<Unit> { }
val client = createRustMatrixClient(
client = FakeRustClient(
client = FakeFfiClient(
clearCachesResult = clearCachesResult,
closeResult = closeResult,
)
Expand All @@ -52,7 +52,7 @@ class RustMatrixClientTest {
}

private fun TestScope.createRustMatrixClient(
client: Client = FakeRustClient(),
client: Client = FakeFfiClient(),
sessionStore: SessionStore = InMemorySessionStore(),
) = RustMatrixClient(
innerClient = client,
Expand All @@ -62,7 +62,7 @@ class RustMatrixClientTest {
sessionDelegate = aRustClientSessionDelegate(
sessionStore = sessionStore,
),
innerSyncService = FakeRustSyncService(),
innerSyncService = FakeFfiSyncService(),
dispatchers = testCoroutineDispatchers(),
baseCacheDirectory = File(""),
clock = FakeSystemClock(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ 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.FakeRustHomeserverLoginDetails
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiHomeserverLoginDetails
import org.junit.Test

class HomeserverDetailsKtTest {
@Test
fun `map should be correct`() {
// Given
val homeserverLoginDetails = FakeRustHomeserverLoginDetails(
val homeserverLoginDetails = FakeFfiHomeserverLoginDetails(
url = "https://example.org",
supportsPasswordLogin = true,
supportsOidcLogin = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
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.FakeQrCodeData
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiQrCodeData
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
import org.junit.Test

class SdkQrCodeLoginDataTest {
@Test
fun `getServer reads the value from the Rust side, null case`() {
val sut = SdkQrCodeLoginData(
rustQrCodeData = FakeQrCodeData(
rustQrCodeData = FakeFfiQrCodeData(
serverNameResult = { null },
),
)
Expand All @@ -26,7 +26,7 @@ class SdkQrCodeLoginDataTest {
@Test
fun `getServer reads the value from the Rust side`() {
val sut = SdkQrCodeLoginData(
rustQrCodeData = FakeQrCodeData(
rustQrCodeData = FakeFfiQrCodeData(
serverNameResult = { A_HOMESERVER_URL },
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

package io.element.android.libraries.matrix.impl.fixtures.factories

import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustLazyTimelineItemProvider
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiLazyTimelineItemProvider
import io.element.android.libraries.matrix.test.AN_EVENT_ID
import io.element.android.libraries.matrix.test.A_USER_ID
import org.matrix.rustcomponents.sdk.EventOrTransactionId
Expand Down Expand Up @@ -50,7 +50,7 @@ fun aRustEventTimelineItem(
readReceipts = readReceipts,
origin = origin,
localCreatedAt = localCreatedAt,
lazyProvider = FakeRustLazyTimelineItemProvider(
lazyProvider = FakeFfiLazyTimelineItemProvider(
debugInfo = debugInfo,
shieldsState = shieldsState,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package io.element.android.libraries.matrix.impl.fixtures.factories

import io.element.android.libraries.matrix.api.core.ThreadId
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustTimelineEvent
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeFfiTimelineEvent
import io.element.android.libraries.matrix.test.A_ROOM_NAME
import io.element.android.libraries.matrix.test.A_USER_NAME
import org.matrix.rustcomponents.sdk.JoinRule
Expand Down Expand Up @@ -65,7 +65,7 @@ fun aRustNotificationRoomInfo(
)

fun aRustNotificationEventTimeline(
event: TimelineEvent = FakeRustTimelineEvent(),
event: TimelineEvent = FakeFfiTimelineEvent(),
) = NotificationEvent.Timeline(
event = event,
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import org.matrix.rustcomponents.sdk.TaskHandle
import org.matrix.rustcomponents.sdk.UnableToDecryptDelegate
import org.matrix.rustcomponents.sdk.UserProfile

class FakeRustClient(
class FakeFfiClient(
private val userId: String = A_USER_ID.value,
private val deviceId: String = A_DEVICE_ID.value,
private val notificationClient: NotificationClient = FakeRustNotificationClient(),
private val notificationSettings: NotificationSettings = FakeRustNotificationSettings(),
private val encryption: Encryption = FakeRustEncryption(),
private val notificationClient: NotificationClient = FakeFfiNotificationClient(),
private val notificationSettings: NotificationSettings = FakeFfiNotificationSettings(),
private val encryption: Encryption = FakeFfiEncryption(),
private val session: Session = aRustSession(),
private val clearCachesResult: () -> Unit = { lambdaError() },
private val withUtdHook: (UnableToDecryptDelegate) -> Unit = { lambdaError() },
Expand All @@ -47,11 +47,11 @@ class FakeRustClient(
override suspend fun getNotificationSettings(): NotificationSettings = notificationSettings
override fun encryption(): Encryption = encryption
override fun session(): Session = session
override fun setDelegate(delegate: ClientDelegate?): TaskHandle = FakeRustTaskHandle()
override fun setDelegate(delegate: ClientDelegate?): TaskHandle = FakeFfiTaskHandle()
override suspend fun cachedAvatarUrl(): String? = null
override suspend fun restoreSession(session: Session) = Unit
override fun syncService(): SyncServiceBuilder = FakeRustSyncServiceBuilder()
override fun roomDirectorySearch(): RoomDirectorySearch = FakeRustRoomDirectorySearch()
override fun syncService(): SyncServiceBuilder = FakeFfiSyncServiceBuilder()
override fun roomDirectorySearch(): RoomDirectorySearch = FakeFfiRoomDirectorySearch()
override suspend fun setPusher(
identifiers: PusherIdentifiers,
kind: PusherKind,
Expand All @@ -64,12 +64,12 @@ class FakeRustClient(
override suspend fun deletePusher(identifiers: PusherIdentifiers) = Unit
override suspend fun clearCaches() = simulateLongTask { clearCachesResult() }
override suspend fun setUtdDelegate(utdDelegate: UnableToDecryptDelegate) = withUtdHook(utdDelegate)
override suspend fun getSessionVerificationController(): SessionVerificationController = FakeRustSessionVerificationController()
override suspend fun getSessionVerificationController(): SessionVerificationController = FakeFfiSessionVerificationController()
override suspend fun ignoredUsers(): List<String> {
return emptyList()
}
override fun subscribeToIgnoredUsers(listener: IgnoredUsersListener): TaskHandle {
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}

override suspend fun getProfile(userId: String): UserProfile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import uniffi.matrix_sdk.BackupDownloadStrategy
import uniffi.matrix_sdk_crypto.CollectStrategy
import uniffi.matrix_sdk_crypto.TrustRequirement

class FakeRustClientBuilder : ClientBuilder(NoPointer) {
class FakeFfiClientBuilder : ClientBuilder(NoPointer) {
override fun addRootCertificates(certificates: List<ByteArray>) = this
override fun autoEnableBackups(autoEnableBackups: Boolean) = this
override fun autoEnableCrossSigning(autoEnableCrossSigning: Boolean) = this
Expand All @@ -43,10 +43,10 @@ class FakeRustClientBuilder : ClientBuilder(NoPointer) {
override fun username(username: String) = this

override suspend fun buildWithQrCode(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener): Client {
return FakeRustClient()
return FakeFfiClient()
}

override suspend fun build(): Client {
return FakeRustClient(withUtdHook = {})
return FakeFfiClient(withUtdHook = {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import org.matrix.rustcomponents.sdk.RecoveryStateListener
import org.matrix.rustcomponents.sdk.TaskHandle
import org.matrix.rustcomponents.sdk.VerificationStateListener

class FakeRustEncryption : Encryption(NoPointer) {
class FakeFfiEncryption : Encryption(NoPointer) {
override fun verificationStateListener(listener: VerificationStateListener): TaskHandle {
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}

override fun recoveryStateListener(listener: RecoveryStateListener): TaskHandle {
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}

override suspend fun waitForE2eeInitializationTasks() = simulateLongTask {}
Expand All @@ -41,6 +41,6 @@ class FakeRustEncryption : Encryption(NoPointer) {
}

override fun backupStateListener(listener: BackupStateListener): TaskHandle {
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package io.element.android.libraries.matrix.impl.fixtures.fakes
import org.matrix.rustcomponents.sdk.HomeserverLoginDetails
import org.matrix.rustcomponents.sdk.NoPointer

class FakeRustHomeserverLoginDetails(
class FakeFfiHomeserverLoginDetails(
private val url: String = "https://example.org",
private val supportsPasswordLogin: Boolean = true,
private val supportsOidcLogin: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.SendHandle
import org.matrix.rustcomponents.sdk.ShieldState

class FakeRustLazyTimelineItemProvider(
class FakeFfiLazyTimelineItemProvider(
private val debugInfo: EventTimelineItemDebugInfo = anEventTimelineItemDebugInfo(),
private val shieldsState: ShieldState? = null,
) : LazyTimelineItemProvider(NoPointer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.matrix.rustcomponents.sdk.NotificationClient
import org.matrix.rustcomponents.sdk.NotificationItem
import org.matrix.rustcomponents.sdk.NotificationItemsRequest

class FakeRustNotificationClient(
class FakeFfiNotificationClient(
var notificationItemResult: Map<String, NotificationItem> = emptyMap(),
) : NotificationClient(NoPointer) {
override suspend fun getNotifications(requests: List<NotificationItemsRequest>): Map<String, NotificationItem> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.matrix.rustcomponents.sdk.NotificationSettings
import org.matrix.rustcomponents.sdk.NotificationSettingsDelegate
import org.matrix.rustcomponents.sdk.RoomNotificationSettings

class FakeRustNotificationSettings(
class FakeFfiNotificationSettings(
private val roomNotificationSettings: RoomNotificationSettings = aRustRoomNotificationSettings(),
) : NotificationSettings(NoPointer) {
private var delegate: NotificationSettingsDelegate? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.element.android.tests.testutils.lambda.lambdaError
import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.QrCodeData

class FakeQrCodeData(
class FakeFfiQrCodeData(
private val serverNameResult: () -> String? = { lambdaError() },
) : QrCodeData(NoPointer) {
override fun serverName(): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.matrix.rustcomponents.sdk.Room
import org.matrix.rustcomponents.sdk.RoomInfo
import org.matrix.rustcomponents.sdk.RoomMembersIterator

class FakeRustRoom(
class FakeFfiRoom(
private val roomId: RoomId = A_ROOM_ID,
private val getMembers: () -> RoomMembersIterator = { lambdaError() },
private val getMembersNoSync: () -> RoomMembersIterator = { lambdaError() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.matrix.rustcomponents.sdk.RoomDirectorySearchEntriesListener
import org.matrix.rustcomponents.sdk.RoomDirectorySearchEntryUpdate
import org.matrix.rustcomponents.sdk.TaskHandle

class FakeRustRoomDirectorySearch(
class FakeFfiRoomDirectorySearch(
var isAtLastPage: Boolean = false,
) : RoomDirectorySearch(NoPointer) {
override suspend fun isAtLastPage(): Boolean {
Expand All @@ -28,7 +28,7 @@ class FakeRustRoomDirectorySearch(

override suspend fun results(listener: RoomDirectorySearchEntriesListener): TaskHandle {
this.listener = listener
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}

fun emitResult(roomEntriesUpdate: List<RoomDirectorySearchEntryUpdate>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ package io.element.android.libraries.matrix.impl.fixtures.fakes
import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.RoomList

class FakeRustRoomList : RoomList(NoPointer)
class FakeFfiRoomList : RoomList(NoPointer)
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicator
import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicatorListener
import org.matrix.rustcomponents.sdk.TaskHandle

class FakeRustRoomListService : RoomListService(NoPointer) {
class FakeFfiRoomListService : RoomListService(NoPointer) {
override suspend fun allRooms(): RoomList {
return FakeRustRoomList()
return FakeFfiRoomList()
}

private var listener: RoomListServiceSyncIndicatorListener? = null
Expand All @@ -27,14 +27,14 @@ class FakeRustRoomListService : RoomListService(NoPointer) {
listener: RoomListServiceSyncIndicatorListener,
): TaskHandle {
this.listener = listener
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}

fun emitRoomListServiceSyncIndicator(syncIndicator: RoomListServiceSyncIndicator) {
listener?.onUpdate(syncIndicator)
}

override fun state(listener: RoomListServiceStateListener): TaskHandle {
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.RoomMember
import org.matrix.rustcomponents.sdk.RoomMembersIterator

class FakeRustRoomMembersIterator(
class FakeFfiRoomMembersIterator(
private var members: List<RoomMember>? = null
) : RoomMembersIterator(NoPointer) {
override fun len(): UInt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.SessionVerificationController
import org.matrix.rustcomponents.sdk.SessionVerificationControllerDelegate

class FakeRustSessionVerificationController : SessionVerificationController(NoPointer) {
class FakeFfiSessionVerificationController : SessionVerificationController(NoPointer) {
override fun setDelegate(delegate: SessionVerificationControllerDelegate?) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import org.matrix.rustcomponents.sdk.SyncService
import org.matrix.rustcomponents.sdk.SyncServiceStateObserver
import org.matrix.rustcomponents.sdk.TaskHandle

class FakeRustSyncService(
private val roomListService: RoomListService = FakeRustRoomListService(),
class FakeFfiSyncService(
private val roomListService: RoomListService = FakeFfiRoomListService(),
) : SyncService(NoPointer) {
override fun roomListService(): RoomListService = roomListService
override fun state(listener: SyncServiceStateObserver): TaskHandle {
return FakeRustTaskHandle()
return FakeFfiTaskHandle()
}
override suspend fun stop() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.SyncService
import org.matrix.rustcomponents.sdk.SyncServiceBuilder

class FakeRustSyncServiceBuilder : SyncServiceBuilder(NoPointer) {
class FakeFfiSyncServiceBuilder : SyncServiceBuilder(NoPointer) {
override fun withOfflineMode(): SyncServiceBuilder = this
override suspend fun finish(): SyncService = FakeRustSyncService()
override suspend fun finish(): SyncService = FakeFfiSyncService()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package io.element.android.libraries.matrix.impl.fixtures.fakes
import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.TaskHandle

class FakeRustTaskHandle : TaskHandle(NoPointer) {
class FakeFfiTaskHandle : TaskHandle(NoPointer) {
override fun cancel() = Unit
override fun destroy() = Unit
}
Loading
Loading