From 8c1938987ba258fd5605d23bf26ec6348a668dbb Mon Sep 17 00:00:00 2001 From: valere Date: Wed, 31 May 2023 12:18:27 +0200 Subject: [PATCH] Code review --- .../crypto/verification/self/SelfVerificationViewModel.kt | 2 +- .../vector/app/core/device/DefaultGetDeviceInfoUseCaseTest.kt | 4 ++-- .../java/im/vector/app/core/pushers/PushersManagerTest.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/self/SelfVerificationViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/self/SelfVerificationViewModel.kt index ded10467a9..55d84a2446 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/self/SelfVerificationViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/self/SelfVerificationViewModel.kt @@ -147,7 +147,7 @@ class SelfVerificationViewModel @AssistedInject constructor( } setState { copy(hasAnyOtherSession = Loading()) } - viewModelScope.launch(Dispatchers.IO) { + viewModelScope.launch { val hasAnyOtherSession = session.cryptoService() .getCryptoDeviceInfo(session.myUserId) .any { diff --git a/vector/src/test/java/im/vector/app/core/device/DefaultGetDeviceInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/core/device/DefaultGetDeviceInfoUseCaseTest.kt index 5dc0936184..99bb428d51 100644 --- a/vector/src/test/java/im/vector/app/core/device/DefaultGetDeviceInfoUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/core/device/DefaultGetDeviceInfoUseCaseTest.kt @@ -19,7 +19,7 @@ package im.vector.app.core.device import im.vector.app.test.fakes.FakeActiveSessionHolder import im.vector.app.test.fakes.FakeCryptoService import im.vector.app.test.fakes.FakeSession -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo import org.junit.Test @@ -33,7 +33,7 @@ class DefaultGetDeviceInfoUseCaseTest { @Test fun `when execute, then get crypto device info`() { - val result = runBlocking { getDeviceInfoUseCase.execute() } + val result = runTest { getDeviceInfoUseCase.execute() } result shouldBeEqualTo cryptoService.cryptoDeviceInfo } diff --git a/vector/src/test/java/im/vector/app/core/pushers/PushersManagerTest.kt b/vector/src/test/java/im/vector/app/core/pushers/PushersManagerTest.kt index 7aa0647a14..39ba4691f9 100644 --- a/vector/src/test/java/im/vector/app/core/pushers/PushersManagerTest.kt +++ b/vector/src/test/java/im/vector/app/core/pushers/PushersManagerTest.kt @@ -29,7 +29,7 @@ import im.vector.app.test.fixtures.CryptoDeviceInfoFixture.aCryptoDeviceInfo import im.vector.app.test.fixtures.PusherFixture import im.vector.app.test.fixtures.SessionParamsFixture import io.mockk.mockk -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo import org.junit.Test import org.matrix.android.sdk.api.session.crypto.model.UnsignedDeviceInfo @@ -81,7 +81,7 @@ class PushersManagerTest { withEventIdOnly = true, ) - runBlocking { + runTest { pushersManager.enqueueRegisterPusher(pushKey, gateway) }