mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 09:56:00 +03:00
Fix some tests
This commit is contained in:
parent
b3c8b5526d
commit
b680e24938
5 changed files with 26 additions and 15 deletions
|
@ -130,12 +130,14 @@ class CommonTestHelper(context: Context) {
|
|||
}
|
||||
}
|
||||
val timeline = room.createTimeline(null, TimelineSettings(10))
|
||||
timeline.start()
|
||||
timeline.addListener(onEventSentListener)
|
||||
for (i in 0 until nbOfMessages) {
|
||||
room.sendTextMessage(message + " #" + (i + 1))
|
||||
}
|
||||
await(latch)
|
||||
timeline.removeListener(onEventSentListener)
|
||||
timeline.dispose()
|
||||
|
||||
// Check that all events has been created
|
||||
assertEquals(nbOfMessages.toLong(), sentEvents.size.toLong())
|
||||
|
|
|
@ -236,7 +236,7 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) {
|
|||
}
|
||||
}
|
||||
|
||||
val bobTimeline = roomFromBobPOV.createTimeline(null, TimelineSettings(10))
|
||||
val bobTimeline = roomFromBobPOV.createTimeline(null, TimelineSettings(20))
|
||||
bobTimeline.start()
|
||||
bobTimeline.addListener(bobEventsListener)
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ object TestConstants {
|
|||
|
||||
const val TESTS_HOME_SERVER_URL = "http://10.0.2.2:8080"
|
||||
|
||||
// Time out to use when waiting for server response. 60s
|
||||
private const val AWAIT_TIME_OUT_MILLIS = 60000
|
||||
// Time out to use when waiting for server response. 10s
|
||||
private const val AWAIT_TIME_OUT_MILLIS = 10_000
|
||||
|
||||
// Time out to use when waiting for server response, when the debugger is connected. 10 minutes
|
||||
private const val AWAIT_TIME_OUT_WITH_DEBUGGER_MILLIS = 10 * 60000
|
||||
private const val AWAIT_TIME_OUT_WITH_DEBUGGER_MILLIS = 10 * 60_000
|
||||
|
||||
const val USER_ALICE = "Alice"
|
||||
const val USER_BOB = "Bob"
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.junit.Assert.assertFalse
|
|||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
@ -101,6 +102,8 @@ class KeysBackupTest : InstrumentedTest {
|
|||
assertEquals(sessionsCount, sessions3.size)
|
||||
assertEquals(sessionsCount, cryptoTestData.firstSession.cryptoService().inboundGroupSessionsCount(false))
|
||||
assertEquals(0, cryptoTestData.firstSession.cryptoService().inboundGroupSessionsCount(true))
|
||||
|
||||
cryptoTestData.cleanUp(mTestHelper)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,6 +328,8 @@ class KeysBackupTest : InstrumentedTest {
|
|||
*/
|
||||
@Test
|
||||
fun restoreKeysBackupAndKeyShareRequestTest() {
|
||||
fail("Check with Valere for this test. I think we do not send key share request")
|
||||
|
||||
val testData = createKeysBackupScenarioWithPassword(null)
|
||||
|
||||
// - Check the SDK sent key share requests
|
||||
|
@ -885,12 +890,12 @@ class KeysBackupTest : InstrumentedTest {
|
|||
keysBackup2.addListener(object : KeysBackupStateListener {
|
||||
override fun onStateChange(newState: KeysBackupState) {
|
||||
// Check the backup completes
|
||||
if (keysBackup.state == KeysBackupState.ReadyToBackUp) {
|
||||
if (newState == KeysBackupState.ReadyToBackUp) {
|
||||
count++
|
||||
|
||||
if (count == 2) {
|
||||
// Remove itself from the list of listeners
|
||||
keysBackup.removeListener(this)
|
||||
keysBackup2.removeListener(this)
|
||||
|
||||
latch.countDown()
|
||||
}
|
||||
|
@ -1026,15 +1031,14 @@ class KeysBackupTest : InstrumentedTest {
|
|||
|
||||
var isSuccessful = false
|
||||
val latch2 = CountDownLatch(1)
|
||||
keysBackup2.backupAllGroupSessions(object : ProgressListener {
|
||||
override fun onProgress(progress: Int, total: Int) {
|
||||
}
|
||||
}, object : TestMatrixCallback<Unit>(latch2, false) {
|
||||
override fun onSuccess(data: Unit) {
|
||||
isSuccessful = true
|
||||
super.onSuccess(data)
|
||||
}
|
||||
})
|
||||
keysBackup2.backupAllGroupSessions(
|
||||
null,
|
||||
object : TestMatrixCallback<Unit>(latch2, false) {
|
||||
override fun onSuccess(data: Unit) {
|
||||
isSuccessful = true
|
||||
super.onSuccess(data)
|
||||
}
|
||||
})
|
||||
mTestHelper.await(latch2)
|
||||
|
||||
assertFalse(isSuccessful)
|
||||
|
|
|
@ -217,4 +217,9 @@ internal class DefaultSession @Inject constructor(
|
|||
override fun removeListener(listener: Session.Listener) {
|
||||
sessionListeners.removeListener(listener)
|
||||
}
|
||||
|
||||
// For easy debugging
|
||||
override fun toString(): String {
|
||||
return "$myUserId - ${sessionParams.credentials.deviceId}"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue