Merge pull request #2900 from element-hq/feature/bma/fakeClassesQuality
Fake classes name quality
This commit is contained in:
commit
e632168c34
34 changed files with 173 additions and 154 deletions
|
|
@ -40,7 +40,7 @@ import io.element.android.libraries.matrix.api.user.MatrixSearchUserResults
|
|||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
||||
import io.element.android.libraries.matrix.test.encryption.FakeEncryptionService
|
||||
import io.element.android.libraries.matrix.test.media.FakeMediaLoader
|
||||
import io.element.android.libraries.matrix.test.media.FakeMatrixMediaLoader
|
||||
import io.element.android.libraries.matrix.test.notification.FakeNotificationService
|
||||
import io.element.android.libraries.matrix.test.notificationsettings.FakeNotificationSettingsService
|
||||
import io.element.android.libraries.matrix.test.pushers.FakePushersService
|
||||
|
|
@ -66,7 +66,7 @@ class FakeMatrixClient(
|
|||
private val userDisplayName: String? = A_USER_NAME,
|
||||
private val userAvatarUrl: String? = AN_AVATAR_URL,
|
||||
override val roomListService: RoomListService = FakeRoomListService(),
|
||||
override val mediaLoader: MatrixMediaLoader = FakeMediaLoader(),
|
||||
override val mediaLoader: MatrixMediaLoader = FakeMatrixMediaLoader(),
|
||||
private val sessionVerificationService: FakeSessionVerificationService = FakeSessionVerificationService(),
|
||||
private val pushersService: FakePushersService = FakePushersService(),
|
||||
private val notificationService: FakeNotificationService = FakeNotificationService(),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import kotlinx.coroutines.flow.flowOf
|
|||
|
||||
val A_OIDC_DATA = OidcDetails(url = "a-url")
|
||||
|
||||
class FakeAuthenticationService(
|
||||
class FakeMatrixAuthenticationService(
|
||||
private val matrixClientResult: ((SessionId) -> Result<MatrixClient>)? = null
|
||||
) : MatrixAuthenticationService {
|
||||
private val homeserver = MutableStateFlow<MatrixHomeServerDetails?>(null)
|
||||
|
|
@ -21,7 +21,7 @@ import io.element.android.libraries.matrix.api.media.MediaFile
|
|||
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
|
||||
class FakeMediaLoader : MatrixMediaLoader {
|
||||
class FakeMatrixMediaLoader : MatrixMediaLoader {
|
||||
var shouldFail = false
|
||||
var path: String = ""
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ import io.element.android.libraries.matrix.test.A_SESSION_ID
|
|||
import io.element.android.libraries.matrix.test.media.FakeMediaUploadHandler
|
||||
import io.element.android.libraries.matrix.test.notificationsettings.FakeNotificationSettingsService
|
||||
import io.element.android.libraries.matrix.test.timeline.FakeTimeline
|
||||
import io.element.android.libraries.matrix.test.widget.FakeWidgetDriver
|
||||
import io.element.android.libraries.matrix.test.widget.FakeMatrixWidgetDriver
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
import kotlinx.collections.immutable.ImmutableMap
|
||||
import kotlinx.collections.immutable.persistentMapOf
|
||||
|
|
@ -125,7 +125,7 @@ class FakeMatrixRoom(
|
|||
private var endPollResult = Result.success(Unit)
|
||||
private var progressCallbackValues = emptyList<Pair<Long, Long>>()
|
||||
private var generateWidgetWebViewUrlResult = Result.success("https://call.element.io")
|
||||
private var getWidgetDriverResult: Result<MatrixWidgetDriver> = Result.success(FakeWidgetDriver())
|
||||
private var getWidgetDriverResult: Result<MatrixWidgetDriver> = Result.success(FakeMatrixWidgetDriver())
|
||||
private var canUserTriggerRoomNotificationResult: Result<Boolean> = Result.success(true)
|
||||
private var canUserJoinCallResult: Result<Boolean> = Result.success(true)
|
||||
private var setIsFavoriteResult = Result.success(Unit)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver
|
|||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import java.util.UUID
|
||||
|
||||
class FakeWidgetDriver(
|
||||
class FakeMatrixWidgetDriver(
|
||||
override val id: String = UUID.randomUUID().toString(),
|
||||
) : MatrixWidgetDriver {
|
||||
private val _sentMessages = mutableListOf<String>()
|
||||
|
|
@ -25,7 +25,7 @@ import app.cash.turbine.test
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.designsystem.utils.snackbar.SnackbarDispatcher
|
||||
import io.element.android.libraries.matrix.test.media.FakeMediaLoader
|
||||
import io.element.android.libraries.matrix.test.media.FakeMatrixMediaLoader
|
||||
import io.element.android.libraries.matrix.test.media.aMediaSource
|
||||
import io.element.android.libraries.mediaviewer.api.local.anApkMediaInfo
|
||||
import io.element.android.libraries.mediaviewer.api.viewer.MediaViewerEvents
|
||||
|
|
@ -51,9 +51,9 @@ class MediaViewerPresenterTest {
|
|||
|
||||
@Test
|
||||
fun `present - download media success scenario`() = runTest {
|
||||
val mediaLoader = FakeMediaLoader()
|
||||
val matrixMediaLoader = FakeMatrixMediaLoader()
|
||||
val mediaActions = FakeLocalMediaActions()
|
||||
val presenter = createMediaViewerPresenter(mediaLoader, mediaActions)
|
||||
val presenter = createMediaViewerPresenter(matrixMediaLoader, mediaActions)
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
}.test {
|
||||
|
|
@ -71,10 +71,10 @@ class MediaViewerPresenterTest {
|
|||
|
||||
@Test
|
||||
fun `present - check all actions `() = runTest {
|
||||
val mediaLoader = FakeMediaLoader()
|
||||
val matrixMediaLoader = FakeMatrixMediaLoader()
|
||||
val mediaActions = FakeLocalMediaActions()
|
||||
val snackbarDispatcher = SnackbarDispatcher()
|
||||
val presenter = createMediaViewerPresenter(mediaLoader, mediaActions, snackbarDispatcher)
|
||||
val presenter = createMediaViewerPresenter(matrixMediaLoader, mediaActions, snackbarDispatcher)
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
}.test {
|
||||
|
|
@ -118,13 +118,13 @@ class MediaViewerPresenterTest {
|
|||
|
||||
@Test
|
||||
fun `present - download media failure then retry with success scenario`() = runTest {
|
||||
val mediaLoader = FakeMediaLoader()
|
||||
val matrixMediaLoader = FakeMatrixMediaLoader()
|
||||
val mediaActions = FakeLocalMediaActions()
|
||||
val presenter = createMediaViewerPresenter(mediaLoader, mediaActions)
|
||||
val presenter = createMediaViewerPresenter(matrixMediaLoader, mediaActions)
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
}.test {
|
||||
mediaLoader.shouldFail = true
|
||||
matrixMediaLoader.shouldFail = true
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.downloadedMedia).isEqualTo(AsyncData.Uninitialized)
|
||||
assertThat(initialState.mediaInfo).isEqualTo(TESTED_MEDIA_INFO)
|
||||
|
|
@ -132,7 +132,7 @@ class MediaViewerPresenterTest {
|
|||
assertThat(loadingState.downloadedMedia).isInstanceOf(AsyncData.Loading::class.java)
|
||||
val failureState = awaitItem()
|
||||
assertThat(failureState.downloadedMedia).isInstanceOf(AsyncData.Failure::class.java)
|
||||
mediaLoader.shouldFail = false
|
||||
matrixMediaLoader.shouldFail = false
|
||||
failureState.eventSink(MediaViewerEvents.RetryLoading)
|
||||
// There is one recomposition because of the retry mechanism
|
||||
skipItems(1)
|
||||
|
|
@ -146,7 +146,7 @@ class MediaViewerPresenterTest {
|
|||
}
|
||||
|
||||
private fun createMediaViewerPresenter(
|
||||
mediaLoader: FakeMediaLoader,
|
||||
matrixMediaLoader: FakeMatrixMediaLoader,
|
||||
localMediaActions: FakeLocalMediaActions,
|
||||
snackbarDispatcher: SnackbarDispatcher = SnackbarDispatcher(),
|
||||
canShare: Boolean = true,
|
||||
|
|
@ -161,7 +161,7 @@ class MediaViewerPresenterTest {
|
|||
canDownload = canDownload,
|
||||
),
|
||||
localMediaFactory = localMediaFactory,
|
||||
mediaLoader = mediaLoader,
|
||||
mediaLoader = matrixMediaLoader,
|
||||
localMediaActions = localMediaActions,
|
||||
snackbarDispatcher = snackbarDispatcher,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import io.element.android.tests.testutils.lambda.LambdaTwoParamsRecorder
|
|||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
class FakeSessionPreferenceStoreFactory(
|
||||
class FakeSessionPreferencesStoreFactory(
|
||||
var getLambda: LambdaTwoParamsRecorder<SessionId, CoroutineScope, SessionPreferencesStore> = lambdaRecorder { _, _ -> throw NotImplementedError() },
|
||||
var removeLambda: LambdaOneParamRecorder<SessionId, Unit> = lambdaRecorder { _ -> },
|
||||
) : SessionPreferencesStoreFactory {
|
||||
|
|
@ -28,7 +28,7 @@ import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
|||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.libraries.matrix.test.A_SECRET
|
||||
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
|
||||
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
|
||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import io.element.android.libraries.push.impl.notifications.FakeNotifiableEventResolver
|
||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||
|
|
@ -135,7 +135,7 @@ class DefaultPushHandlerTest {
|
|||
pushClientSecret = FakePushClientSecret(
|
||||
getUserIdFromSecretResult = { null }
|
||||
),
|
||||
matrixAuthenticationService = FakeAuthenticationService().apply {
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService().apply {
|
||||
getLatestSessionIdLambda = { A_USER_ID }
|
||||
},
|
||||
incrementPushCounterResult = incrementPushCounterResult
|
||||
|
|
@ -171,7 +171,7 @@ class DefaultPushHandlerTest {
|
|||
pushClientSecret = FakePushClientSecret(
|
||||
getUserIdFromSecretResult = { null }
|
||||
),
|
||||
matrixAuthenticationService = FakeAuthenticationService().apply {
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService().apply {
|
||||
getLatestSessionIdLambda = { null }
|
||||
},
|
||||
incrementPushCounterResult = incrementPushCounterResult
|
||||
|
|
@ -247,7 +247,7 @@ class DefaultPushHandlerTest {
|
|||
userPushStore: UserPushStore = FakeUserPushStore(),
|
||||
pushClientSecret: PushClientSecret = FakePushClientSecret(),
|
||||
buildMeta: BuildMeta = aBuildMeta(),
|
||||
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService(),
|
||||
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
||||
diagnosticPushHandler: DiagnosticPushHandler = DiagnosticPushHandler(),
|
||||
): DefaultPushHandler {
|
||||
return DefaultPushHandler(
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import io.element.android.libraries.matrix.test.A_USER_ID
|
|||
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
||||
import io.element.android.libraries.matrix.test.A_USER_ID_3
|
||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
|
||||
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
|
||||
import io.element.android.libraries.push.test.FakePusherSubscriber
|
||||
import io.element.android.libraries.pushproviders.api.PusherSubscriber
|
||||
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
|
||||
|
|
@ -66,7 +66,7 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
storeData(aSessionData(A_USER_ID_2))
|
||||
storeData(aSessionData(A_USER_ID_3))
|
||||
},
|
||||
matrixAuthenticationService = FakeAuthenticationService(
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService(
|
||||
matrixClientResult = { sessionId ->
|
||||
when (sessionId) {
|
||||
A_USER_ID -> Result.success(aMatrixClient1)
|
||||
|
|
@ -105,7 +105,7 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
sessionStore = InMemoryMultiSessionsStore().apply {
|
||||
storeData(aSessionData(A_USER_ID))
|
||||
},
|
||||
matrixAuthenticationService = FakeAuthenticationService(
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService(
|
||||
matrixClientResult = { _ ->
|
||||
Result.failure(IllegalStateException())
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
sessionStore = InMemoryMultiSessionsStore().apply {
|
||||
storeData(aSessionData(A_USER_ID))
|
||||
},
|
||||
matrixAuthenticationService = FakeAuthenticationService(
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService(
|
||||
matrixClientResult = { _ ->
|
||||
Result.success(aMatrixClient1)
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ class DefaultFirebaseNewTokenHandlerTest {
|
|||
pusherSubscriber: PusherSubscriber = FakePusherSubscriber(),
|
||||
sessionStore: SessionStore = InMemorySessionStore(),
|
||||
userPushStoreFactory: UserPushStoreFactory = FakeUserPushStoreFactory(),
|
||||
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService(),
|
||||
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
||||
firebaseStore: FirebaseStore = InMemoryFirebaseStore(),
|
||||
): FirebaseNewTokenHandler {
|
||||
return DefaultFirebaseNewTokenHandler(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
|||
import io.element.android.libraries.matrix.test.A_SECRET
|
||||
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
|
||||
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
|
||||
import io.element.android.libraries.push.test.FakePusherSubscriber
|
||||
import io.element.android.libraries.pushproviders.api.PusherSubscriber
|
||||
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
|
||||
|
|
@ -86,7 +86,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest {
|
|||
pusherSubscriber = FakePusherSubscriber(
|
||||
registerPusherResult = { _, _, _ -> Result.failure(IllegalStateException("an error")) }
|
||||
),
|
||||
matrixAuthenticationService = FakeAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
|
||||
)
|
||||
val result = defaultUnifiedPushNewGatewayHandler.handle(
|
||||
endpoint = "aEndpoint",
|
||||
|
|
@ -114,7 +114,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest {
|
|||
pusherSubscriber = FakePusherSubscriber(
|
||||
registerPusherResult = lambda
|
||||
),
|
||||
matrixAuthenticationService = FakeAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
|
||||
matrixAuthenticationService = FakeMatrixAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
|
||||
)
|
||||
val result = defaultUnifiedPushNewGatewayHandler.handle(
|
||||
endpoint = "aEndpoint",
|
||||
|
|
@ -131,7 +131,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest {
|
|||
pusherSubscriber: PusherSubscriber = FakePusherSubscriber(),
|
||||
userPushStoreFactory: UserPushStoreFactory = FakeUserPushStoreFactory(),
|
||||
pushClientSecret: PushClientSecret = FakePushClientSecret(),
|
||||
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService()
|
||||
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService()
|
||||
): DefaultUnifiedPushNewGatewayHandler {
|
||||
return DefaultUnifiedPushNewGatewayHandler(
|
||||
pusherSubscriber = pusherSubscriber,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import io.element.android.libraries.voicerecorder.impl.audio.AudioConfig
|
|||
import io.element.android.libraries.voicerecorder.impl.audio.SampleRate
|
||||
import io.element.android.libraries.voicerecorder.impl.di.VoiceRecorderModule
|
||||
import io.element.android.libraries.voicerecorder.test.FakeAudioLevelCalculator
|
||||
import io.element.android.libraries.voicerecorder.test.FakeAudioRecorderFactory
|
||||
import io.element.android.libraries.voicerecorder.test.FakeAudioReaderFactory
|
||||
import io.element.android.libraries.voicerecorder.test.FakeEncoder
|
||||
import io.element.android.libraries.voicerecorder.test.FakeFileSystem
|
||||
import io.element.android.libraries.voicerecorder.test.FakeVoiceFileManager
|
||||
|
|
@ -136,7 +136,7 @@ class VoiceRecorderImplTest {
|
|||
return VoiceRecorderImpl(
|
||||
dispatchers = testCoroutineDispatchers(),
|
||||
timeSource = timeSource,
|
||||
audioReaderFactory = FakeAudioRecorderFactory(
|
||||
audioReaderFactory = FakeAudioReaderFactory(
|
||||
audio = AUDIO,
|
||||
),
|
||||
encoder = FakeEncoder(fakeFileSystem),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import io.element.android.libraries.voicerecorder.impl.audio.Audio
|
|||
import io.element.android.libraries.voicerecorder.impl.audio.AudioConfig
|
||||
import io.element.android.libraries.voicerecorder.impl.audio.AudioReader
|
||||
|
||||
class FakeAudioRecorderFactory(
|
||||
class FakeAudioReaderFactory(
|
||||
private val audio: List<Audio>
|
||||
) : AudioReader.Factory {
|
||||
override fun create(config: AudioConfig, dispatchers: CoroutineDispatchers): AudioReader {
|
||||
Loading…
Add table
Add a link
Reference in a new issue