diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 5b19dcca5..db0fa935e 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -13,7 +13,7 @@ compile-testing = "0.17" compose-compiler = "1.4.6" compose-libraries = "1.4.0" compose-navigation = "2.4.0-alpha03" -coroutines = "1.6.4" +coroutines = "1.7.3" dagger = "2.43.2" errorprone = "2.3.3" errorprone-javac = "9+181-r4173-1" @@ -33,7 +33,7 @@ javapoet = "1.11.1" jsr250 = "1.0" junit = "4.12" kotlin = "1.8.20" -kotlinx-coroutines = "1.6.4" +kotlinx-coroutines = "1.7.3" ktfmt = "0.43" ktlint = "0.48.2" leakcanary = "1.5.4" diff --git a/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/LazyBackingPropertyTest.kt b/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/LazyBackingPropertyTest.kt index dde6f6e64..5ce172019 100644 --- a/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/LazyBackingPropertyTest.kt +++ b/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/LazyBackingPropertyTest.kt @@ -17,7 +17,6 @@ package com.uber.rib.core import com.google.common.truth.Truth.assertThat import io.reactivex.Observable -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.produce import kotlinx.coroutines.channels.toList import kotlinx.coroutines.launch @@ -25,7 +24,6 @@ import kotlinx.coroutines.test.runTest import org.junit.Test import org.mockito.kotlin.mock -@OptIn(ExperimentalCoroutinesApi::class) class LazyBackingPropertyTest { @Volatile private var _expensiveObject: ExpensiveObject? = null private val expensiveObject diff --git a/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/RibCoroutineWorkerTest.kt b/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/RibCoroutineWorkerTest.kt index 13a77f6db..3b3e51406 100644 --- a/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/RibCoroutineWorkerTest.kt +++ b/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/RibCoroutineWorkerTest.kt @@ -24,7 +24,6 @@ import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Delay import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.Runnable import kotlinx.coroutines.awaitCancellation @@ -49,7 +48,6 @@ import org.junit.Test private const val ON_START_DELAY_DURATION_MILLIS = 100L -@OptIn(ExperimentalCoroutinesApi::class) class RibCoroutineWorkerTest { @get:Rule val coroutineRule = RibCoroutinesRule() private val worker = TestRibCoroutineWorker() @@ -180,7 +178,7 @@ class RibCoroutineWorkerTest { } } -@OptIn(ExperimentalCoroutinesApi::class, InternalCoroutinesApi::class) +@OptIn(InternalCoroutinesApi::class) private class ImmediateDispatcher( scheduler: TestCoroutineScheduler, private val delegate: TestDispatcher = StandardTestDispatcher(scheduler), diff --git a/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/WorkerBinderTest.kt b/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/WorkerBinderTest.kt index f49f31969..a75f0983c 100644 --- a/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/WorkerBinderTest.kt +++ b/android/libraries/rib-base/src/test/kotlin/com/uber/rib/core/WorkerBinderTest.kt @@ -138,7 +138,7 @@ class WorkerBinderTest(private val adaptFromRibCoroutineWorker: Boolean) { } @Test - fun bind_onStartIsCalledEagerly() { + fun bind_onStartIsCalledEagerly() = runTest { val interactor = object : Interactor>() {} var onStartCalled = false val worker = Worker { onStartCalled = true } @@ -148,7 +148,7 @@ class WorkerBinderTest(private val adaptFromRibCoroutineWorker: Boolean) { } @Test - fun bind_whenSubscribeToLifecycleInWorker_observerIsCalledEagerly() { + fun bind_whenSubscribeToLifecycleInWorker_observerIsCalledEagerly() = runTest { val interactor = object : Interactor>() {} var enteredUnconfined = false val worker = Worker { diff --git a/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/RibCoroutinesRule.kt b/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/RibCoroutinesRule.kt index aa9b6a2e2..af0671684 100644 --- a/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/RibCoroutinesRule.kt +++ b/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/RibCoroutinesRule.kt @@ -15,7 +15,7 @@ */ package com.uber.rib.core -import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.CoroutineDispatcher import org.junit.rules.TestWatcher import org.junit.runner.Description @@ -23,16 +23,19 @@ import org.junit.runner.Description * RibCoroutinesRule is a Junit TestRule to act as a managed TestCoroutineScope in test and to * facilitate install and cleanup of Test Dispatchers */ -@ExperimentalCoroutinesApi public class RibCoroutinesRule( public val ribDispatchers: TestRibDispatchers = TestRibDispatchers(), ) : TestWatcher() { + private var originalDeprecatedWorkerDispatcher: CoroutineDispatcher? = null override fun starting(description: Description) { ribDispatchers.installTestDispatchers() + originalDeprecatedWorkerDispatcher = RibCoroutinesConfig.deprecatedWorkerDispatcher + RibCoroutinesConfig.deprecatedWorkerDispatcher = ribDispatchers.Unconfined } override fun finished(description: Description) { ribDispatchers.resetTestDispatchers() + RibCoroutinesConfig.deprecatedWorkerDispatcher = originalDeprecatedWorkerDispatcher!! } } diff --git a/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibCoroutineScopes.kt b/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibCoroutineScopes.kt index 50215cac1..237be9976 100644 --- a/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibCoroutineScopes.kt +++ b/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibCoroutineScopes.kt @@ -23,12 +23,10 @@ import com.uber.autodispose.coroutinesinterop.autoDispose import io.reactivex.Completable import io.reactivex.CompletableSource import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.test.TestScope -@ExperimentalCoroutinesApi /** returns the [TestScope] override currently installed for testing. */ public val ScopeProvider.testScopeOverride: TestScope? // Due to custom friend path usage, reference to LazyCoroutineScope will stay red in IDE @@ -42,7 +40,6 @@ public val ScopeProvider.testScopeOverride: TestScope? * Overrides [ScopeProvider.coroutineScope] with a [TestScope] with lifecycle integration for * testing. Accessible directly as [TestScope] via [ScopeProvider.TestScopeOverride]. */ -@ExperimentalCoroutinesApi public fun ScopeProvider.enableTestScopeOverride( context: CoroutineContext = SupervisorJob(), ): Unit = synchronized(LazyCoroutineScope) { LazyCoroutineScope[this] = asTestScope(context) } @@ -52,7 +49,6 @@ public fun ScopeProvider.disableTestScopeOverride(): Unit = synchronized(LazyCoroutineScope) { LazyCoroutineScope[this] = null } /** returns the [TestScope] override currently installed for testing. */ -@ExperimentalCoroutinesApi public val Application.testScopeOverride: TestScope? // Due to custom friend path usage, reference to LazyCoroutineScope will stay red in IDE get() = @@ -65,7 +61,6 @@ public val Application.testScopeOverride: TestScope? * Overrides [ScopeProvider.coroutineScope] with a [TestScope] with lifecycle integration for * testing. Accessible directly as [TestScope] via [ScopeProvider.TestScopeOverride]. */ -@ExperimentalCoroutinesApi public fun Application.enableTestScopeOverride(context: CoroutineContext = SupervisorJob()): Unit = synchronized(LazyCoroutineScope) { LazyCoroutineScope[this] = TestScope(context) } @@ -74,13 +69,11 @@ public fun Application.disableTestScopeOverride(): Unit = synchronized(LazyCoroutineScope) { LazyCoroutineScope[this] = null } /** Returns a new [TestScope] from the [ScopeProvider] */ -@ExperimentalCoroutinesApi public fun ScopeProvider.asTestScope(context: CoroutineContext = SupervisorJob()): TestScope { return requestScope().asTestScope(context) } /** Returns a new [TestScope] from the [CompletableSource] */ -@ExperimentalCoroutinesApi public fun CompletableSource.asTestScope(context: CoroutineContext = SupervisorJob()): TestScope { val scope = TestScope(context) Completable.wrap(this).autoDispose(scope).subscribe({ scope.cancel() }) { e -> diff --git a/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibDispatchers.kt b/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibDispatchers.kt index 9a4eef459..4e52f80b8 100644 --- a/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibDispatchers.kt +++ b/android/libraries/rib-coroutines-test/src/main/kotlin/com/uber/rib/core/TestRibDispatchers.kt @@ -16,7 +16,6 @@ package com.uber.rib.core import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.MainCoroutineDispatcher import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestCoroutineScheduler @@ -25,7 +24,6 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain -@ExperimentalCoroutinesApi public data class TestRibDispatchers( /** * [TestCoroutineScheduler] to be used by all other [TestDispatcher] when using the default diff --git a/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibCoroutinesRuleTest.kt b/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibCoroutinesRuleTest.kt index c2c273a7c..b86786c83 100644 --- a/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibCoroutinesRuleTest.kt +++ b/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibCoroutinesRuleTest.kt @@ -16,7 +16,6 @@ package com.uber.rib.core import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.test.advanceTimeBy @@ -25,7 +24,6 @@ import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.Test -@OptIn(ExperimentalCoroutinesApi::class) class RibCoroutinesRuleTest { @get:Rule val ribCoroutinesRule = RibCoroutinesRule() diff --git a/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibDispatchersTest.kt b/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibDispatchersTest.kt index 9641e364f..c19c8d985 100644 --- a/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibDispatchersTest.kt +++ b/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibDispatchersTest.kt @@ -17,11 +17,9 @@ package com.uber.rib.core import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestCoroutineDispatcher import org.junit.Test -@OptIn(ExperimentalCoroutinesApi::class) internal class RibDispatchersTest { @Test diff --git a/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibScopesTest.kt b/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibScopesTest.kt index 7d79ab35e..16917843f 100644 --- a/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibScopesTest.kt +++ b/android/libraries/rib-coroutines-test/src/test/kotlin/com/uber/rib/core/RibScopesTest.kt @@ -19,7 +19,6 @@ import android.app.Application import com.google.common.truth.Truth.assertThat import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineExceptionHandler -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch @@ -29,7 +28,6 @@ import org.junit.Rule import org.junit.Test import org.mockito.kotlin.mock -@OptIn(ExperimentalCoroutinesApi::class) internal class RibScopesTest { @get:Rule var rule = RibCoroutinesRule()