@@ -38,7 +38,8 @@ class UISIDetectorTest {
3838
3939 @Test
4040 fun `trigger detection after grace period` () {
41- val uisiDetector = UISIDetector ()
41+ val gracePeriod = 5_000L
42+ val uisiDetector = UISIDetector (gracePeriod)
4243 var detectedEvent: E2EMessageDetected ? = null
4344
4445 uisiDetector.callback = object : UISIDetector .UISIDetectorCallback {
@@ -60,15 +61,16 @@ class UISIDetectorTest {
6061 uisiDetector.onEventDecryptionError(event, fakeCryptoError())
6162
6263 runBlocking {
63- delay(40_000 )
64+ delay((gracePeriod * 1.2 ).toLong() )
6465 }
6566 Assert .assertEquals(eventId, detectedEvent?.eventId)
6667 }
6768
6869 @Test
6970 fun `If event decrypted during grace period should not trigger detection` () {
7071 val scope = CoroutineScope (SupervisorJob ())
71- val uisiDetector = UISIDetector ()
72+ val gracePeriod = 5_000L
73+ val uisiDetector = UISIDetector (gracePeriod)
7274
7375 uisiDetector.callback = object : UISIDetector .UISIDetectorCallback {
7476 override val enabled = true
@@ -89,12 +91,12 @@ class UISIDetectorTest {
8991
9092 // the grace period is 30s
9193 scope.launch(Dispatchers .Default ) {
92- delay(10_000 )
94+ delay((gracePeriod * 0.5 ).toLong() )
9395 uisiDetector.onEventDecrypted(event, emptyMap())
9496 }
9597
9698 runBlocking {
97- delay(60_000 )
99+ delay((gracePeriod * 1.2 ).toLong() )
98100 }
99101 }
100102
0 commit comments