mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
resist ConnectivityManager$TooManyRequestsException
This commit is contained in:
parent
90a4e71b06
commit
6fd99dc302
2 changed files with 13 additions and 7 deletions
|
@ -56,19 +56,17 @@ class SpaceCreationTest : InstrumentedTest {
|
|||
val roomName = "My Space"
|
||||
val topic = "A public space for test"
|
||||
var spaceId: String = ""
|
||||
commonTestHelper.waitWithLatch {
|
||||
commonTestHelper.runBlockingTest {
|
||||
spaceId = session.spaceService().createSpace(roomName, topic, null, true)
|
||||
// wait a bit to let the summary update it self :/
|
||||
it.countDown()
|
||||
}
|
||||
Thread.sleep(4_000)
|
||||
|
||||
val syncedSpace = session.spaceService().getSpace(spaceId)
|
||||
commonTestHelper.waitWithLatch {
|
||||
commonTestHelper.retryPeriodicallyWithLatch(it) {
|
||||
syncedSpace?.asRoom()?.roomSummary()?.name != null
|
||||
session.spaceService().getSpace(spaceId)?.asRoom()?.roomSummary()?.name != null
|
||||
}
|
||||
}
|
||||
|
||||
val syncedSpace = session.spaceService().getSpace(spaceId)
|
||||
assertEquals("Room name should be set", roomName, syncedSpace?.asRoom()?.roomSummary()?.name)
|
||||
assertEquals("Room topic should be set", topic, syncedSpace?.asRoom()?.roomSummary()?.topic)
|
||||
// assertEquals(topic, syncedSpace.asRoom().roomSummary()?., "Room topic should be set")
|
||||
|
|
|
@ -70,7 +70,15 @@ internal class PreferredNetworkCallbackStrategy @Inject constructor(context: Con
|
|||
|
||||
override fun register(hasChanged: () -> Unit) {
|
||||
hasChangedCallback = hasChanged
|
||||
conn.registerDefaultNetworkCallback(networkCallback)
|
||||
// Add a try catch for safety
|
||||
// TODO: It happens when running all tests in CI, at some points we reach a limit here causing TooManyRequestsException
|
||||
// and crashing the sync thread. We might have problem here, would need some investigation
|
||||
// for now adding a catch to allow CI to continue running
|
||||
try {
|
||||
conn.registerDefaultNetworkCallback(networkCallback)
|
||||
} catch (t: Throwable) {
|
||||
Timber.e(t, "Unable to register default network callback")
|
||||
}
|
||||
}
|
||||
|
||||
override fun unregister() {
|
||||
|
|
Loading…
Reference in a new issue