From 71d56108c254e7b835e1b32bc7814b8c018703b1 Mon Sep 17 00:00:00 2001 From: valere Date: Wed, 14 Dec 2022 10:43:03 +0100 Subject: [PATCH] Fix ui test compilation --- .../src/androidTest/java/im/vector/app/EspressoExt.kt | 7 ++++++- .../java/im/vector/app/SecurityBootstrapTest.kt | 5 ++++- .../java/im/vector/app/VerifySessionPassphraseTest.kt | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/vector-app/src/androidTest/java/im/vector/app/EspressoExt.kt b/vector-app/src/androidTest/java/im/vector/app/EspressoExt.kt index 72137ed8e8..c5171f6d5c 100644 --- a/vector-app/src/androidTest/java/im/vector/app/EspressoExt.kt +++ b/vector-app/src/androidTest/java/im/vector/app/EspressoExt.kt @@ -45,6 +45,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.core.time.DefaultClock import im.vector.app.espresso.tools.waitUntilViewVisible +import kotlinx.coroutines.runBlocking import org.hamcrest.Matcher import org.hamcrest.Matchers import org.hamcrest.StringDescription @@ -229,7 +230,7 @@ fun allSecretsKnownIdling(session: Session): IdlingResource { val res = object : IdlingResource, Observer> { private var callback: IdlingResource.ResourceCallback? = null - var privateKeysInfo: PrivateKeysInfo? = session.cryptoService().crossSigningService().getCrossSigningPrivateKeys() + var privateKeysInfo: PrivateKeysInfo? = null override fun getName() = "AllSecretsKnownIdling_${session.myUserId}" override fun isIdleNow(): Boolean { @@ -251,6 +252,10 @@ fun allSecretsKnownIdling(session: Session): IdlingResource { } } + res.privateKeysInfo = runBlocking { + session.cryptoService().crossSigningService().getCrossSigningPrivateKeys() + } + runOnUiThread { session.cryptoService().crossSigningService().getLiveCrossSigningPrivateKeys().observeForever(res) } diff --git a/vector-app/src/androidTest/java/im/vector/app/SecurityBootstrapTest.kt b/vector-app/src/androidTest/java/im/vector/app/SecurityBootstrapTest.kt index 1243758b2f..e5286e43ea 100644 --- a/vector-app/src/androidTest/java/im/vector/app/SecurityBootstrapTest.kt +++ b/vector-app/src/androidTest/java/im/vector/app/SecurityBootstrapTest.kt @@ -164,7 +164,10 @@ class SecurityBootstrapTest : VerificationTestBase() { onView(withText(R.string._continue)).perform(click()) // Assert that all is configured - assert(uiSession.cryptoService().crossSigningService().isCrossSigningInitialized()) + val crossSigningInitialized = runBlockingTest { + uiSession.cryptoService().crossSigningService().isCrossSigningInitialized() + } + assert(crossSigningInitialized) assert(uiSession.cryptoService().crossSigningService().canCrossSign()) assert(uiSession.cryptoService().crossSigningService().allPrivateKeysKnown()) assert(uiSession.cryptoService().keysBackupService().isEnabled()) diff --git a/vector-app/src/androidTest/java/im/vector/app/VerifySessionPassphraseTest.kt b/vector-app/src/androidTest/java/im/vector/app/VerifySessionPassphraseTest.kt index 53e088118b..fb256fddb2 100644 --- a/vector-app/src/androidTest/java/im/vector/app/VerifySessionPassphraseTest.kt +++ b/vector-app/src/androidTest/java/im/vector/app/VerifySessionPassphraseTest.kt @@ -74,7 +74,7 @@ class VerifySessionPassphraseTest : VerificationTestBase() { val matrix = getMatrixInstance() val userName = "foobar_${Random.nextLong()}" existingSession = createAccountAndSync(matrix, userName, password, true) - doSync { + runBlockingTest { existingSession!!.cryptoService().crossSigningService() .initializeCrossSigning( object : UserInteractiveAuthInterceptor { @@ -87,7 +87,7 @@ class VerifySessionPassphraseTest : VerificationTestBase() { ) ) } - }, it + } ) }