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