Skip to content
Snippets Groups Projects
Unverified Commit dc59dac6 authored by Matthias Urhahn's avatar Matthias Urhahn Committed by GitHub
Browse files

Additional statistics testcase (DEV) #2203


This basically prevents unnecessary data refreshes when moving between screens.
After adding #2190, this time based test is now a lot easier :).

Co-authored-by: default avatarRalf Gehrer <ralfgehrer@users.noreply.github.com>
parent 4b356227
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ import org.junit.jupiter.api.AfterEach ...@@ -20,7 +20,7 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import testhelpers.BaseTest import testhelpers.BaseTest
import testhelpers.TestDispatcherProvider import testhelpers.asDispatcherProvider
import testhelpers.coroutines.runBlockingTest2 import testhelpers.coroutines.runBlockingTest2
import testhelpers.coroutines.test import testhelpers.coroutines.test
import java.io.IOException import java.io.IOException
...@@ -66,7 +66,7 @@ class StatisticsProviderTest : BaseTest() { ...@@ -66,7 +66,7 @@ class StatisticsProviderTest : BaseTest() {
localCache = localCache, localCache = localCache,
parser = parser, parser = parser,
foregroundState = foregroundState, foregroundState = foregroundState,
dispatcherProvider = TestDispatcherProvider() dispatcherProvider = scope.asDispatcherProvider()
) )
@Test @Test
...@@ -137,4 +137,28 @@ class StatisticsProviderTest : BaseTest() { ...@@ -137,4 +137,28 @@ class StatisticsProviderTest : BaseTest() {
localCache.save(null) localCache.save(null)
} }
} }
@Test
fun `subscription flow timeout is 5 seconds`() = runBlockingTest2(ignoreActive = true) {
val instance = createInstance(this)
var testCollector1 = instance.current.test(startOnScope = this)
var testCollector2 = instance.current.test(startOnScope = this)
advanceUntilIdle()
coVerify(exactly = 1) { localCache.load() }
testCollector1.cancel()
testCollector2.cancel()
advanceTimeBy(6000)
testCollector1 = instance.current.test(startOnScope = this)
testCollector2 = instance.current.test(startOnScope = this)
advanceUntilIdle()
coVerify(exactly = 2) { localCache.load() }
testCollector1.cancel()
testCollector2.cancel()
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment