Skip to content

Commit 9d76104

Browse files
committed
Fix test
1 parent 7a3cc5a commit 9d76104

File tree

8 files changed

+28
-19
lines changed

8 files changed

+28
-19
lines changed

autoconsent/autoconsent-impl/src/main/java/com/duckduckgo/autoconsent/impl/remoteconfig/AutoconsentExceptionsRepository.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,19 @@ class RealAutoconsentExceptionsRepository @Inject constructor(
5353
override val exceptions = CopyOnWriteArrayList<FeatureException>()
5454

5555
init {
56-
coroutineScope.launch(dispatcherProvider.io()) {
57-
loadToMemory()
58-
}
56+
loadToMemory()
5957
}
6058

6159
private fun loadToMemory() {
62-
if (isMainProcess) {
63-
exceptions.clear()
64-
exceptions.addAll(autoconsentFeature.self().getExceptions())
60+
coroutineScope.launch(dispatcherProvider.io()) {
61+
if (isMainProcess) {
62+
exceptions.clear()
63+
exceptions.addAll(autoconsentFeature.self().getExceptions())
64+
}
6565
}
6666
}
6767

6868
override fun onPrivacyConfigDownloaded() {
69-
coroutineScope.launch(dispatcherProvider.io()) {
70-
loadToMemory()
71-
}
69+
loadToMemory()
7270
}
7371
}

autoconsent/autoconsent-impl/src/test/java/com/duckduckgo/autoconsent/impl/remoteconfig/RealAutoconsentExceptionsRepositoryTest.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@
1616

1717
package com.duckduckgo.autoconsent.impl.remoteconfig
1818

19+
import android.annotation.SuppressLint
1920
import com.duckduckgo.common.test.CoroutineTestRule
2021
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
2122
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
2223
import com.duckduckgo.feature.toggles.api.Toggle
2324
import kotlinx.coroutines.test.TestScope
2425
import kotlinx.coroutines.test.runTest
25-
import org.junit.Assert.*
26-
import org.junit.Before
26+
import org.junit.Assert.assertEquals
2727
import org.junit.Rule
2828
import org.junit.Test
2929

30+
@SuppressLint("DenyListedApi") // setRawStoredState
3031
class RealAutoconsentExceptionsRepositoryTest {
3132

3233
@get:Rule
3334
var coroutineRule = CoroutineTestRule()
3435

35-
private val autoconsentFeature = FakeFeatureToggleFactory.create(AutoconsentFeature::class.java)
36-
37-
@Before
38-
fun setup() {
39-
autoconsentFeature.self().setRawStoredState(Toggle.State(exceptions = listOf(exception)))
36+
private val autoconsentFeature: AutoconsentFeature = FakeFeatureToggleFactory.create(AutoconsentFeature::class.java).apply {
37+
self().setRawStoredState(Toggle.State(exceptions = exceptions))
4038
}
4139

4240
@Test
@@ -47,7 +45,8 @@ class RealAutoconsentExceptionsRepositoryTest {
4745
autoconsentFeature,
4846
isMainProcess = true,
4947
)
50-
assertEquals(exception, repository.exceptions.first())
48+
49+
assertEquals(exceptions, repository.exceptions)
5150
}
5251

5352
@Test
@@ -59,13 +58,13 @@ class RealAutoconsentExceptionsRepositoryTest {
5958
isMainProcess = true,
6059
)
6160

62-
assertEquals(listOf(exception), repository.exceptions)
61+
assertEquals(exceptions, repository.exceptions)
6362
autoconsentFeature.self().setRawStoredState(Toggle.State(exceptions = emptyList()))
6463
repository.onPrivacyConfigDownloaded()
6564
assertEquals(emptyList<FeatureException>(), repository.exceptions)
6665
}
6766

6867
companion object {
69-
val exception = FeatureException("example.com", "reason")
68+
val exceptions = listOf(FeatureException("example.com", "reason"))
7069
}
7170
}

autofill/autofill-impl/src/test/java/com/duckduckgo/autofill/impl/email/remoteconfig/RealEmailProtectionInContextFeatureRepositoryTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.duckduckgo.autofill.impl.email.remoteconfig
22

3+
import android.annotation.SuppressLint
34
import com.duckduckgo.autofill.impl.email.incontext.EmailProtectionInContextSignupFeature
45
import com.duckduckgo.common.test.CoroutineTestRule
56
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
@@ -11,6 +12,7 @@ import org.junit.Before
1112
import org.junit.Rule
1213
import org.junit.Test
1314

15+
@SuppressLint("DenyListedApi") // setRawStoredState
1416
class RealEmailProtectionInContextFeatureRepositoryTest {
1517
@get:Rule
1618
var coroutineRule = CoroutineTestRule()

autofill/autofill-impl/src/test/java/com/duckduckgo/autofill/impl/feature/plugin/RealAutofillFeatureRepositoryTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.duckduckgo.autofill.impl.feature.plugin
22

3+
import android.annotation.SuppressLint
34
import com.duckduckgo.autofill.api.AutofillFeature
45
import com.duckduckgo.common.test.CoroutineTestRule
56
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
@@ -11,6 +12,7 @@ import org.junit.Before
1112
import org.junit.Rule
1213
import org.junit.Test
1314

15+
@SuppressLint("DenyListedApi") // setRawStoredState
1416
class RealAutofillFeatureRepositoryTest {
1517
@get:Rule
1618
var coroutineRule = CoroutineTestRule()

autofill/autofill-impl/src/test/java/com/duckduckgo/autofill/impl/reporting/remoteconfig/AutofillSiteBreakageReportingFeatureRepositoryImplTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.duckduckgo.autofill.impl.reporting.remoteconfig
22

3+
import android.annotation.SuppressLint
34
import com.duckduckgo.common.test.CoroutineTestRule
45
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
56
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
@@ -10,6 +11,7 @@ import org.junit.Before
1011
import org.junit.Rule
1112
import org.junit.Test
1213

14+
@SuppressLint("DenyListedApi") // setRawStoredState
1315
class AutofillSiteBreakageReportingFeatureRepositoryImplTest {
1416
@get:Rule
1517
var coroutineRule = CoroutineTestRule()

autofill/autofill-impl/src/test/java/com/duckduckgo/autofill/impl/store/RealAutofillServiceFeatureRepositoryTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.duckduckgo.autofill.impl.store
1818

19+
import android.annotation.SuppressLint
1920
import com.duckduckgo.autofill.impl.service.AutofillServiceFeature
2021
import com.duckduckgo.autofill.impl.service.store.RealAutofillServiceFeatureRepository
2122
import com.duckduckgo.common.test.CoroutineTestRule
@@ -28,6 +29,7 @@ import org.junit.Before
2829
import org.junit.Rule
2930
import org.junit.Test
3031

32+
@SuppressLint("DenyListedApi") // setRawStoredState
3133
class RealAutofillServiceFeatureRepositoryTest {
3234
@get:Rule
3335
var coroutineRule = CoroutineTestRule()

malicious-site-protection/malicious-site-protection-impl/src/test/kotlin/com/duckduckgo/malicioussiteprotection/impl/remoteconfig/RealMaliciousSiteProtectionRCRepositoryTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.duckduckgo.malicioussiteprotection.impl.remoteconfig
22

3+
import android.annotation.SuppressLint
34
import com.duckduckgo.common.test.CoroutineTestRule
45
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
56
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
@@ -11,6 +12,7 @@ import org.junit.Before
1112
import org.junit.Rule
1213
import org.junit.Test
1314

15+
@SuppressLint("DenyListedApi") // setRawStoredState
1416
class RealMaliciousSiteProtectionRCRepositoryTest {
1517
@get:Rule
1618
var coroutineRule = CoroutineTestRule()

site-permissions/site-permissions-impl/src/test/java/com/duckduckgo/site/permissions/impl/drmblock/RealDrmBlockRepositoryTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.duckduckgo.site.permissions.impl.drmblock
22

3+
import android.annotation.SuppressLint
34
import com.duckduckgo.common.test.CoroutineTestRule
45
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
56
import com.duckduckgo.feature.toggles.api.FeatureExceptions.FeatureException
@@ -10,6 +11,7 @@ import org.junit.Before
1011
import org.junit.Rule
1112
import org.junit.Test
1213

14+
@SuppressLint("DenyListedApi") // setRawStoredState
1315
class RealDrmBlockRepositoryTest {
1416
@get:Rule
1517
var coroutineRule = CoroutineTestRule()

0 commit comments

Comments
 (0)