Test framework cleaning

This commit is contained in:
valere 2023-04-07 11:34:27 +02:00
parent 89267256ef
commit 1b12db9270
6 changed files with 22 additions and 24 deletions

View file

@ -87,15 +87,13 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
internal fun runCryptoTest(context: Context, cryptoConfig: MXCryptoConfig? = null, autoSignoutOnClose: Boolean = true, block: suspend CoroutineScope.(CryptoTestHelper, CommonTestHelper) -> Unit) {
val testHelper = CommonTestHelper(context, cryptoConfig)
val cryptoTestHelper = CryptoTestHelper(testHelper)
return try {
runTest(dispatchTimeoutMs = TestConstants.timeOutMillis * 2) {
withContext(Dispatchers.Main) {
return runTest(dispatchTimeoutMs = TestConstants.timeOutMillis) {
try {
withContext(Dispatchers.Default) {
block(cryptoTestHelper, testHelper)
}
}
} finally {
if (autoSignoutOnClose) {
runBlocking {
} finally {
if (autoSignoutOnClose) {
testHelper.cleanUpOpenedSessions()
}
}

View file

@ -193,8 +193,8 @@ class KeyShareTests : InstrumentedTest {
cryptoTestHelper.ensureCanDecrypt(listOf(receivedEvent.eventId), aliceSession2, roomId, listOf(sentEventText ?: ""))
commonTestHelper.signOutAndClose(aliceSession)
commonTestHelper.signOutAndClose(aliceSession2)
// commonTestHelper.signOutAndClose(aliceSession)
// commonTestHelper.signOutAndClose(aliceSession2)
}
// See E2ESanityTest for a test regarding secret sharing
@ -272,8 +272,8 @@ class KeyShareTests : InstrumentedTest {
ownDeviceReply != null && ownDeviceReply.result is RequestResult.Success
}
commonTestHelper.signOutAndClose(aliceSession)
commonTestHelper.signOutAndClose(aliceNewSession)
// commonTestHelper.signOutAndClose(aliceSession)
// commonTestHelper.signOutAndClose(aliceNewSession)
}
@Test
@ -387,9 +387,9 @@ class KeyShareTests : InstrumentedTest {
result != null && result is RequestResult.Success && result.chainIndex == 3
}
commonTestHelper.signOutAndClose(aliceNewSession)
commonTestHelper.signOutAndClose(aliceSession)
commonTestHelper.signOutAndClose(bobSession)
// commonTestHelper.signOutAndClose(aliceNewSession)
// commonTestHelper.signOutAndClose(aliceSession)
// commonTestHelper.signOutAndClose(bobSession)
}
@Test
@ -479,8 +479,8 @@ class KeyShareTests : InstrumentedTest {
val outgoing = aliceNewSession.cryptoService().getOutgoingRoomKeyRequests().firstOrNull { it.sessionId == sentEventMegolmSession }
assertEquals("The request should be canceled", OutgoingRoomKeyRequestState.SENT_THEN_CANCELED, outgoing!!.state)
commonTestHelper.signOutAndClose(aliceNewSession)
commonTestHelper.signOutAndClose(aliceSession)
commonTestHelper.signOutAndClose(bobSession)
// commonTestHelper.signOutAndClose(aliceNewSession)
// commonTestHelper.signOutAndClose(aliceSession)
// commonTestHelper.signOutAndClose(bobSession)
}
}

View file

@ -88,7 +88,7 @@ class QuadSTests : InstrumentedTest {
assertNotNull(defaultKeyAccountData?.content)
assertEquals("Unexpected default key ${defaultKeyAccountData?.content}", TEST_KEY_ID, defaultKeyAccountData?.content?.get("key"))
testHelper.signOutAndClose(aliceSession)
// testHelper.signOutAndClose(aliceSession)
}
@Test

View file

@ -300,8 +300,8 @@ class VerificationTest : InstrumentedTest {
requests.any { it.cancelConclusion == CancelCode.AcceptedByAnotherDevice }
}
testHelper.signOutAndClose(aliceSessionToVerify)
testHelper.signOutAndClose(aliceSessionThatVerifies)
testHelper.signOutAndClose(aliceSessionThatReceivesCanceledEvent)
// testHelper.signOutAndClose(aliceSessionToVerify)
// testHelper.signOutAndClose(aliceSessionThatVerifies)
// testHelper.signOutAndClose(aliceSessionThatReceivesCanceledEvent)
}
}

View file

@ -124,8 +124,8 @@ class SpaceCreationTest : InstrumentedTest {
assertEquals("Room name should be set", roomName, spaceBobPov?.asRoom()?.roomSummary()?.name)
assertEquals("Room topic should be set", topic, spaceBobPov?.asRoom()?.roomSummary()?.topic)
commonTestHelper.signOutAndClose(aliceSession)
commonTestHelper.signOutAndClose(bobSession)
// commonTestHelper.signOutAndClose(aliceSession)
// commonTestHelper.signOutAndClose(bobSession)
}
@Test

View file

@ -334,7 +334,7 @@ class SpaceHierarchyTest : InstrumentedTest {
}
)
commonTestHelper.signOutAndClose(session)
// commonTestHelper.signOutAndClose(session)
}
data class TestSpaceCreationResult(