@@ -24,7 +24,6 @@ import io.element.android.services.analyticsproviders.api.AnalyticsProvider
2424import io.element.android.services.analyticsproviders.test.FakeAnalyticsProvider
2525import io.element.android.tests.testutils.lambda.lambdaRecorder
2626import io.element.android.tests.testutils.lambda.value
27- import io.element.android.tests.testutils.runCancellableScopeTest
2827import kotlinx.coroutines.CompletableDeferred
2928import kotlinx.coroutines.CoroutineScope
3029import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -37,31 +36,31 @@ import org.junit.Test
3736
3837class DefaultAnalyticsServiceTest {
3938 @Test
40- fun `getAvailableAnalyticsProviders return the set of provider` () = runCancellableScopeTest {
39+ fun `getAvailableAnalyticsProviders return the set of provider` () = runTest {
4140 val providers = setOf (
4241 FakeAnalyticsProvider (name = " provider1" , stopLambda = { }),
4342 FakeAnalyticsProvider (name = " provider2" , stopLambda = { }),
4443 )
4544 val sut = createDefaultAnalyticsService(
46- coroutineScope = it ,
45+ coroutineScope = backgroundScope ,
4746 analyticsProviders = providers
4847 )
4948 val result = sut.getAvailableAnalyticsProviders()
5049 assertThat(result).isEqualTo(providers)
5150 }
5251
5352 @Test
54- fun `when consent is not provided, capture is no op` () = runCancellableScopeTest {
55- val sut = createDefaultAnalyticsService(it )
53+ fun `when consent is not provided, capture is no op` () = runTest {
54+ val sut = createDefaultAnalyticsService(backgroundScope )
5655 sut.capture(anEvent)
5756 }
5857
5958 @Test
60- fun `when consent is provided, capture is sent to the AnalyticsProvider` () = runCancellableScopeTest {
59+ fun `when consent is provided, capture is sent to the AnalyticsProvider` () = runTest {
6160 val initLambda = lambdaRecorder<Unit > { }
6261 val captureLambda = lambdaRecorder<VectorAnalyticsEvent , Unit > { _ -> }
6362 val sut = createDefaultAnalyticsService(
64- coroutineScope = it ,
63+ coroutineScope = backgroundScope ,
6564 analyticsStore = FakeAnalyticsStore (defaultUserConsent = true ),
6665 analyticsProviders = setOf (
6766 FakeAnalyticsProvider (
@@ -76,17 +75,17 @@ class DefaultAnalyticsServiceTest {
7675 }
7776
7877 @Test
79- fun `when consent is not provided, screen is no op` () = runCancellableScopeTest {
80- val sut = createDefaultAnalyticsService(it )
78+ fun `when consent is not provided, screen is no op` () = runTest {
79+ val sut = createDefaultAnalyticsService(backgroundScope )
8180 sut.screen(aScreen)
8281 }
8382
8483 @Test
85- fun `when consent is provided, screen is sent to the AnalyticsProvider` () = runCancellableScopeTest {
84+ fun `when consent is provided, screen is sent to the AnalyticsProvider` () = runTest {
8685 val initLambda = lambdaRecorder<Unit > { }
8786 val screenLambda = lambdaRecorder<VectorAnalyticsScreen , Unit > { _ -> }
8887 val sut = createDefaultAnalyticsService(
89- coroutineScope = it ,
88+ coroutineScope = backgroundScope ,
9089 analyticsStore = FakeAnalyticsStore (defaultUserConsent = true ),
9190 analyticsProviders = setOf (
9291 FakeAnalyticsProvider (
@@ -101,17 +100,17 @@ class DefaultAnalyticsServiceTest {
101100 }
102101
103102 @Test
104- fun `when consent is not provided, trackError is no op` () = runCancellableScopeTest {
105- val sut = createDefaultAnalyticsService(it )
103+ fun `when consent is not provided, trackError is no op` () = runTest {
104+ val sut = createDefaultAnalyticsService(backgroundScope )
106105 sut.trackError(anError)
107106 }
108107
109108 @Test
110- fun `when consent is provided, trackError is sent to the AnalyticsProvider` () = runCancellableScopeTest {
109+ fun `when consent is provided, trackError is sent to the AnalyticsProvider` () = runTest {
111110 val initLambda = lambdaRecorder<Unit > { }
112111 val trackErrorLambda = lambdaRecorder<Throwable , Unit > { _ -> }
113112 val sut = createDefaultAnalyticsService(
114- coroutineScope = it ,
113+ coroutineScope = backgroundScope ,
115114 analyticsStore = FakeAnalyticsStore (defaultUserConsent = true ),
116115 analyticsProviders = setOf (
117116 FakeAnalyticsProvider (
@@ -126,10 +125,10 @@ class DefaultAnalyticsServiceTest {
126125 }
127126
128127 @Test
129- fun `setUserConsent is sent to the store` () = runCancellableScopeTest {
128+ fun `setUserConsent is sent to the store` () = runTest {
130129 val store = FakeAnalyticsStore ()
131130 val sut = createDefaultAnalyticsService(
132- coroutineScope = it ,
131+ coroutineScope = backgroundScope ,
133132 analyticsStore = store,
134133 )
135134 assertThat(store.userConsentFlow.first()).isFalse()
@@ -140,10 +139,10 @@ class DefaultAnalyticsServiceTest {
140139 }
141140
142141 @Test
143- fun `setAnalyticsId is sent to the store` () = runCancellableScopeTest {
142+ fun `setAnalyticsId is sent to the store` () = runTest {
144143 val store = FakeAnalyticsStore ()
145144 val sut = createDefaultAnalyticsService(
146- coroutineScope = it ,
145+ coroutineScope = backgroundScope ,
147146 analyticsStore = store,
148147 )
149148 assertThat(store.analyticsIdFlow.first()).isEqualTo(" " )
@@ -154,10 +153,10 @@ class DefaultAnalyticsServiceTest {
154153 }
155154
156155 @Test
157- fun `setDidAskUserConsent is sent to the store` () = runCancellableScopeTest {
156+ fun `setDidAskUserConsent is sent to the store` () = runTest {
158157 val store = FakeAnalyticsStore ()
159158 val sut = createDefaultAnalyticsService(
160- coroutineScope = it ,
159+ coroutineScope = backgroundScope ,
161160 analyticsStore = store,
162161 )
163162 assertThat(store.didAskUserConsentFlow.first()).isFalse()
@@ -168,26 +167,26 @@ class DefaultAnalyticsServiceTest {
168167 }
169168
170169 @Test
171- fun `when a session is deleted, the store is reset` () = runCancellableScopeTest {
170+ fun `when a session is deleted, the store is reset` () = runTest {
172171 val resetLambda = lambdaRecorder<Unit > { }
173172 val store = FakeAnalyticsStore (
174173 resetLambda = resetLambda,
175174 )
176175 val sut = createDefaultAnalyticsService(
177- coroutineScope = it ,
176+ coroutineScope = backgroundScope ,
178177 analyticsStore = store,
179178 )
180179 sut.onSessionDeleted(" userId" )
181180 resetLambda.assertions().isCalledOnce()
182181 }
183182
184183 @Test
185- fun `when reset is invoked, the user consent is reset` () = runCancellableScopeTest {
184+ fun `when reset is invoked, the user consent is reset` () = runTest {
186185 val store = FakeAnalyticsStore (
187186 defaultDidAskUserConsent = true ,
188187 )
189188 val sut = createDefaultAnalyticsService(
190- coroutineScope = it ,
189+ coroutineScope = backgroundScope ,
191190 analyticsStore = store,
192191 )
193192 assertThat(store.didAskUserConsentFlow.first()).isTrue()
@@ -196,9 +195,9 @@ class DefaultAnalyticsServiceTest {
196195 }
197196
198197 @Test
199- fun `when a session is added, nothing happen` () = runCancellableScopeTest {
198+ fun `when a session is added, nothing happen` () = runTest {
200199 val sut = createDefaultAnalyticsService(
201- coroutineScope = it ,
200+ coroutineScope = backgroundScope ,
202201 )
203202 sut.onSessionCreated(" userId" )
204203 }
@@ -231,10 +230,10 @@ class DefaultAnalyticsServiceTest {
231230 }
232231
233232 @Test
234- fun `when consent is provided, updateUserProperties is sent to the provider` () = runCancellableScopeTest {
233+ fun `when consent is provided, updateUserProperties is sent to the provider` () = runTest {
235234 val updateUserPropertiesLambda = lambdaRecorder<UserProperties , Unit > { _ -> }
236235 val sut = createDefaultAnalyticsService(
237- coroutineScope = it ,
236+ coroutineScope = backgroundScope ,
238237 analyticsProviders = setOf (
239238 FakeAnalyticsProvider (
240239 initLambda = { },
@@ -248,10 +247,10 @@ class DefaultAnalyticsServiceTest {
248247 }
249248
250249 @Test
251- fun `when super properties are updated, updateSuperProperties is sent to the provider` () = runCancellableScopeTest {
250+ fun `when super properties are updated, updateSuperProperties is sent to the provider` () = runTest {
252251 val updateSuperPropertiesLambda = lambdaRecorder<SuperProperties , Unit > { _ -> }
253252 val sut = createDefaultAnalyticsService(
254- coroutineScope = it ,
253+ coroutineScope = backgroundScope ,
255254 analyticsProviders = setOf (
256255 FakeAnalyticsProvider (
257256 initLambda = { },
0 commit comments