diff --git a/android/demos/compose/build.gradle b/android/demos/compose/build.gradle index f5cf254a1..b4acd712d 100644 --- a/android/demos/compose/build.gradle +++ b/android/demos/compose/build.gradle @@ -17,7 +17,7 @@ android { compose true } composeOptions { - kotlinCompilerExtensionVersion "${deps.versions.androidx.compose}" + kotlinCompilerExtensionVersion deps.versions.androidx.compose.compiler } compileOptions { sourceCompatibility deps.build.javaVersion @@ -47,6 +47,7 @@ dependencies { implementation deps.androidx.composeUi implementation deps.androidx.composeViewModel implementation deps.androidx.composeUiTooling + implementation deps.androidx.savedState implementation deps.external.rxandroid2 implementation deps.kotlin.coroutines implementation deps.kotlin.coroutinesAndroid diff --git a/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootScope.kt b/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootScope.kt index ca08b5d06..69cb2d7ce 100644 --- a/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootScope.kt +++ b/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootScope.kt @@ -17,7 +17,7 @@ package com.uber.rib.compose.root import android.view.ViewGroup import androidx.lifecycle.ViewTreeLifecycleOwner -import androidx.savedstate.ViewTreeSavedStateRegistryOwner +import androidx.savedstate.setViewTreeSavedStateRegistryOwner import com.uber.rib.compose.root.main.MainScope import com.uber.rib.compose.util.AnalyticsClient import com.uber.rib.compose.util.AnalyticsClientImpl @@ -46,7 +46,7 @@ interface RootScope { fun view(parentViewGroup: ViewGroup, activity: RibActivity): RootView { return RootView(parentViewGroup.context).apply { ViewTreeLifecycleOwner.set(this, activity) - ViewTreeSavedStateRegistryOwner.set(this, activity) + setViewTreeSavedStateRegistryOwner(activity) } } diff --git a/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/MainScope.kt b/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/MainScope.kt index ef70e513e..d6fdf2cde 100644 --- a/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/MainScope.kt +++ b/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/MainScope.kt @@ -20,7 +20,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.ui.platform.ComposeView import androidx.lifecycle.ViewTreeLifecycleOwner -import androidx.savedstate.ViewTreeSavedStateRegistryOwner +import androidx.savedstate.setViewTreeSavedStateRegistryOwner import com.uber.rib.compose.root.main.logged_in.LoggedInScope import com.uber.rib.compose.root.main.logged_out.LoggedOutScope import com.uber.rib.compose.util.AnalyticsClient @@ -65,7 +65,7 @@ interface MainScope { ): ComposeView { return ComposeView(parentViewGroup.context).apply { ViewTreeLifecycleOwner.set(this, activity) - ViewTreeSavedStateRegistryOwner.set(this, activity) + setViewTreeSavedStateRegistryOwner(activity) } } diff --git a/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/logged_in/tic_tac_toe/TicTacToeView.kt b/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/logged_in/tic_tac_toe/TicTacToeView.kt index 1bdce5b1a..1dab93210 100644 --- a/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/logged_in/tic_tac_toe/TicTacToeView.kt +++ b/android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/logged_in/tic_tac_toe/TicTacToeView.kt @@ -25,8 +25,8 @@ import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.GridCells -import androidx.compose.foundation.lazy.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.State @@ -56,7 +56,7 @@ fun TicTacToeView(viewModel: State, eventStream: EventStream .aspectRatio(1f) .fillMaxSize() ) { - LazyVerticalGrid(cells = GridCells.Fixed(3), modifier = Modifier.fillMaxSize()) { + LazyVerticalGrid(columns = GridCells.Fixed(3), modifier = Modifier.fillMaxSize()) { val board = viewModel.value.board items(9) { i -> val row = i / 3 diff --git a/android/gradle/dependencies.gradle b/android/gradle/dependencies.gradle index 192e96390..712e54e95 100755 --- a/android/gradle/dependencies.gradle +++ b/android/gradle/dependencies.gradle @@ -18,20 +18,23 @@ def versions = [ androidx: [ annotations: '1.1.0', appcompat: '1.3.0', - compose: '1.0.2', - percent: '1.0.0' + compose: [ + compiler: "1.3.0", + libraries: "1.2.1" + ], + percent: '1.0.0', + savedState: "1.2.0" ], autodispose: '1.4.0', - coroutines: '1.5.1', - dagger: "2.34", + coroutines: '1.6.4', + dagger: "2.43.2", errorProne: '2.3.3', gjf: '1.7', intellij: "2022.1", - kotlin: "1.5.21", + kotlin: "1.7.10", ktfmt: '0.23', ktlint: '0.41.0', motif: '0.3.4', - rave: "2.0.0", robolectric: "4.4", spotless: '5.11.0' ] @@ -47,13 +50,12 @@ def apt = [ javaxInject: "javax.inject:javax.inject:1", autoValue: "com.google.auto.value:auto-value:1.7", autoValueAnnotations: "com.google.auto.value:auto-value-annotations:1.7", - raveCompiler: "com.uber:rave-compiler:${versions.rave}", errorProneAnnotations: "com.google.errorprone:error_prone_annotations:${versions.errorProne}", ] def build = [ - buildToolsVersion: '30.0.2', - compileSdkVersion: 30, + buildToolsVersion: '33.0.0', + compileSdkVersion: 33, ci: 'true' == System.getenv('CI'), minSdkVersion: 21, targetSdkVersion: 28, @@ -67,7 +69,7 @@ def build = [ errorProneTestHelpers: "com.google.errorprone:error_prone_test_helpers:${versions.errorProne}", nullAway: 'com.uber.nullaway:nullaway:0.9.0', gradlePlugins: [ - android: 'com.android.tools.build:gradle:7.1.0', + android: 'com.android.tools.build:gradle:7.2.2', apt: "net.ltgt.gradle:gradle-apt-plugin:0.21", errorprone: "net.ltgt.gradle:gradle-errorprone-plugin:1.3.0", gradleMavenPublish: "com.vanniktech:gradle-maven-publish-plugin:0.18.0", @@ -85,15 +87,17 @@ def androidx = [ activityKtx: "androidx.activity:activity-ktx:1.3.0-beta02", annotations: "androidx.annotation:annotation:${versions.androidx.annotations}", appcompat: "androidx.appcompat:appcompat:${versions.androidx.appcompat}", - composeAnimation: "androidx.compose.animation:animation:${versions.androidx.compose}", - composeFoundation: "androidx.compose.foundation:foundation:${versions.androidx.compose}", - composeMaterial: "androidx.compose.material:material:${versions.androidx.compose}", + composeAnimation: "androidx.compose.animation:animation:${versions.androidx.compose.libraries}", + composeCompiler: "androidx.compose.compiler:compiler:${versions.androidx.compose.compiler}", + composeFoundation: "androidx.compose.foundation:foundation:${versions.androidx.compose.libraries}", + composeMaterial: "androidx.compose.material:material:${versions.androidx.compose.libraries}", composeNavigation: "androidx.navigation:navigation-compose:2.4.0-alpha03", - composeRuntimeRxJava2: "androidx.compose.runtime:runtime-rxjava2:${versions.androidx.compose}", - composeUi: "androidx.compose.ui:ui:${versions.androidx.compose}", - composeUiTooling: "androidx.compose.ui:ui-tooling:${versions.androidx.compose}", + composeRuntimeRxJava2: "androidx.compose.runtime:runtime-rxjava2:${versions.androidx.compose.libraries}", + composeUi: "androidx.compose.ui:ui:${versions.androidx.compose.libraries}", + composeUiTooling: "androidx.compose.ui:ui-tooling:${versions.androidx.compose.libraries}", composeViewModel: "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05", - percent: "androidx.percentlayout:percentlayout:${versions.androidx.percent}" + percent: "androidx.percentlayout:percentlayout:${versions.androidx.percent}", + savedState: "androidx.savedstate:savedstate:${versions.androidx.savedState}" ] def test = [ @@ -139,7 +143,6 @@ def uber = [ autodisposeErrorProne: "com.uber.autodispose:autodispose-error-prone:${versions.autodispose}", motif: "com.uber.motif:motif:${versions.motif}", motifCompiler: "com.uber.motif:motif-compiler:${versions.motif}", - rave: "com.uber:rave:${versions.rave}", ] ext.deps = [ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e7898ba46..04f755dc3 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip diff --git a/android/libraries/rib-android-compose/build.gradle b/android/libraries/rib-android-compose/build.gradle index d2eb95ff5..4269ca9af 100644 --- a/android/libraries/rib-android-compose/build.gradle +++ b/android/libraries/rib-android-compose/build.gradle @@ -30,7 +30,7 @@ android { compose true } composeOptions { - kotlinCompilerExtensionVersion deps.versions.androidx.compose + kotlinCompilerExtensionVersion deps.versions.androidx.compose.compiler } compileOptions { diff --git a/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/BasicInteractor.kt b/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/BasicInteractor.kt index b2657620d..d214c7cf6 100644 --- a/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/BasicInteractor.kt +++ b/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/BasicInteractor.kt @@ -22,5 +22,5 @@ package com.uber.rib.core * @param the type of [Router]. */ abstract class BasicInteractor

> protected constructor( - @JvmField protected open var presenter: P + protected open var presenter: P ) : Interactor(presenter) 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 690691a32..596da4348 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 @@ -16,7 +16,6 @@ package com.uber.rib.core import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.TestCoroutineScope import org.junit.rules.TestWatcher import org.junit.runner.Description @@ -24,17 +23,13 @@ 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(), - TestCoroutineScope by TestCoroutineScope(ribDispatchers.Default) { +public class RibCoroutinesRule(public val ribDispatchers: TestRibDispatchers = TestRibDispatchers()) : TestWatcher() { override fun starting(description: Description) { ribDispatchers.installTestDispatchers() } override fun finished(description: Description) { - cleanupTestCoroutines() - ribDispatchers.cleanupTestDispatchers() ribDispatchers.resetTestDispatchers() } } 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 aecf883a8..8709e18e4 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,77 +23,77 @@ import io.reactivex.CompletableSource import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel -import kotlinx.coroutines.test.TestCoroutineScope +import kotlinx.coroutines.test.TestScope import kotlin.coroutines.CoroutineContext @ExperimentalCoroutinesApi /** - * returns the [TestCoroutineScope] override currently installed for testing. + * returns the [TestScope] override currently installed for testing. */ -public val ScopeProvider.testCoroutineScopeOverride: TestCoroutineScope? +public val ScopeProvider.testScopeOverride: TestScope? // Due to custom friend path usage, reference to LazyCoroutineScope will stay red in IDE get() = synchronized(LazyCoroutineScope) { val testScope = LazyCoroutineScope[this] - return if (testScope != null && testScope is TestCoroutineScope) testScope else null + return if (testScope != null && testScope is TestScope) testScope else null } /** - * Overrides [ScopeProvider.coroutineScope] with a [TestCoroutineScope] with lifecycle integration for testing. - * Accessible directly as [TestCoroutineScope] via [ScopeProvider.testCoroutineScopeOverride]. + * Overrides [ScopeProvider.coroutineScope] with a [TestScope] with lifecycle integration for testing. + * Accessible directly as [TestScope] via [ScopeProvider.TestScopeOverride]. */ @ExperimentalCoroutinesApi -public fun ScopeProvider.enableTestCoroutineScopeOverride(context: CoroutineContext = SupervisorJob()): Unit = synchronized(LazyCoroutineScope) { - LazyCoroutineScope[this] = asTestCoroutineScope(context) +public fun ScopeProvider.enableTestScopeOverride(context: CoroutineContext = SupervisorJob()): Unit = synchronized(LazyCoroutineScope) { + LazyCoroutineScope[this] = asTestScope(context) } /** - * Disables the [ScopeProvider.coroutineScope] override with [TestCoroutineScope] + * Disables the [ScopeProvider.coroutineScope] override with [TestScope] */ -public fun ScopeProvider.disableTestCoroutineScopeOverride(): Unit = synchronized(LazyCoroutineScope) { +public fun ScopeProvider.disableTestScopeOverride(): Unit = synchronized(LazyCoroutineScope) { LazyCoroutineScope[this] = null } /** - * returns the [TestCoroutineScope] override currently installed for testing. + * returns the [TestScope] override currently installed for testing. */ @ExperimentalCoroutinesApi -public val Application.testCoroutineScopeOverride: TestCoroutineScope? +public val Application.testScopeOverride: TestScope? // Due to custom friend path usage, reference to LazyCoroutineScope will stay red in IDE get() = synchronized(LazyCoroutineScope) { val testScope = LazyCoroutineScope[this] - return if (testScope != null && testScope is TestCoroutineScope) testScope else null + return if (testScope != null && testScope is TestScope) testScope else null } /** - * Overrides [ScopeProvider.coroutineScope] with a [TestCoroutineScope] with lifecycle integration for testing. - * Accessible directly as [TestCoroutineScope] via [ScopeProvider.testCoroutineScopeOverride]. + * Overrides [ScopeProvider.coroutineScope] with a [TestScope] with lifecycle integration for testing. + * Accessible directly as [TestScope] via [ScopeProvider.TestScopeOverride]. */ @ExperimentalCoroutinesApi -public fun Application.enableTestCoroutineScopeOverride(context: CoroutineContext = SupervisorJob()): Unit = synchronized(LazyCoroutineScope) { - LazyCoroutineScope[this] = TestCoroutineScope(context) +public fun Application.enableTestScopeOverride(context: CoroutineContext = SupervisorJob()): Unit = synchronized(LazyCoroutineScope) { + LazyCoroutineScope[this] = TestScope(context) } /** - * Disables the [ScopeProvider.coroutineScope] override with [TestCoroutineScope] + * Disables the [ScopeProvider.coroutineScope] override with [TestScope] */ -public fun Application.disableTestCoroutineScopeOverride(): Unit = synchronized(LazyCoroutineScope) { +public fun Application.disableTestScopeOverride(): Unit = synchronized(LazyCoroutineScope) { LazyCoroutineScope[this] = null } /** - * Returns a new [TestCoroutineScope] from the [ScopeProvider] + * Returns a new [TestScope] from the [ScopeProvider] */ @ExperimentalCoroutinesApi -public fun ScopeProvider.asTestCoroutineScope(context: CoroutineContext = SupervisorJob()): TestCoroutineScope { - return requestScope().asTestCoroutineScope(context) +public fun ScopeProvider.asTestScope(context: CoroutineContext = SupervisorJob()): TestScope { + return requestScope().asTestScope(context) } /** - * Returns a new [TestCoroutineScope] from the [CompletableSource] + * Returns a new [TestScope] from the [CompletableSource] */ @ExperimentalCoroutinesApi -public fun CompletableSource.asTestCoroutineScope(context: CoroutineContext = SupervisorJob()): TestCoroutineScope { - val scope = TestCoroutineScope(context) +public fun CompletableSource.asTestScope(context: CoroutineContext = SupervisorJob()): TestScope { + val scope = TestScope(context) Completable.wrap(this) .autoDispose(scope) .subscribe({ scope.cancel() }) { e -> scope.cancel("OnError", 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 e496e576b..3cf561d61 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 @@ -18,16 +18,18 @@ package com.uber.rib.core import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.MainCoroutineDispatcher -import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.TestDispatcher +import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain @ExperimentalCoroutinesApi public data class TestRibDispatchers( - override val Default: TestCoroutineDispatcher = TestCoroutineDispatcher(), - override val IO: TestCoroutineDispatcher = TestCoroutineDispatcher(), - override val Unconfined: TestCoroutineDispatcher = TestCoroutineDispatcher(), - val MainTestDelegate: TestCoroutineDispatcher = TestCoroutineDispatcher() + override val Default: TestDispatcher = StandardTestDispatcher(), + override val IO: TestDispatcher = StandardTestDispatcher(), + override val Unconfined: TestDispatcher = UnconfinedTestDispatcher(), + val MainTestDelegate: TestDispatcher = StandardTestDispatcher() ) : RibDispatchersProvider { public fun installTestDispatchers() { @@ -36,13 +38,6 @@ public data class TestRibDispatchers( RibCoroutinesConfig.dispatchers = this } - public fun cleanupTestDispatchers() { - Default.cleanupTestCoroutines() - MainTestDelegate.cleanupTestCoroutines() - IO.cleanupTestCoroutines() - Unconfined.cleanupTestCoroutines() - } - public fun resetTestDispatchers() { Dispatchers.resetMain() RibCoroutinesConfig.dispatchers = DefaultRibDispatchers() 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 b864f7ec7..2ad7b0a13 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 @@ -17,17 +17,18 @@ package com.uber.rib.core import android.app.Application import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import kotlinx.coroutines.test.TestCoroutineExceptionHandler -import kotlinx.coroutines.test.TestCoroutineScope -import kotlinx.coroutines.test.runBlockingTest +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.Test import org.mockito.kotlin.mock import java.lang.RuntimeException +import kotlin.coroutines.CoroutineContext @OptIn(ExperimentalCoroutinesApi::class) internal class RibScopesTest { @@ -35,7 +36,7 @@ internal class RibScopesTest { @get:Rule var rule = RibCoroutinesRule() @Test - internal fun testScopeLifecycle() = runBlockingTest { + internal fun testScopeLifecycle() = runTest { val interactor = FakeInteractor>() interactor.attach() val job = interactor.coroutineScope.launch { @@ -49,10 +50,10 @@ internal class RibScopesTest { } @Test - internal fun testScopeLifecycleWithTestScope() = runBlockingTest { + internal fun testScopeLifecycleWithTestScope() = runTest { val interactor = FakeInteractor>() interactor.attach() - interactor.enableTestCoroutineScopeOverride() + interactor.enableTestScopeOverride() val job = interactor.coroutineScope.launch { while (isActive) { @@ -81,8 +82,8 @@ internal class RibScopesTest { } @Test(expected = RuntimeException::class) - internal fun testUncaughtHandler() = runBlockingTest { - val handler = TestCoroutineExceptionHandler() + internal fun testUncaughtHandler() = runTest { + val handler = TestUncaughtExceptionCaptor() RibCoroutinesConfig.exceptionHandler = handler val interactor = FakeInteractor>() @@ -90,19 +91,18 @@ internal class RibScopesTest { interactor.coroutineScope.launch { throw RuntimeException("mainScope failed") } - handler.cleanupTestCoroutines() + throw(handler.exceptions.first()) } @Test(expected = RuntimeException::class) - internal fun testException() = runBlockingTest { + internal fun testException() = runTest { val interactor = FakeInteractor>() - interactor.enableTestCoroutineScopeOverride() + interactor.enableTestScopeOverride() interactor.attach() interactor.coroutineScope.launch { throw RuntimeException("mainScope failed") } - interactor.testCoroutineScopeOverride!!.cleanupTestCoroutines() } @Test() @@ -111,19 +111,19 @@ internal class RibScopesTest { val interactor = FakeInteractor>() interactor.attach() - assertThat(interactor.testCoroutineScopeOverride).isNull() + assertThat(interactor.testScopeOverride).isNull() - interactor.enableTestCoroutineScopeOverride() - val testScope = interactor.testCoroutineScopeOverride + interactor.enableTestScopeOverride() + val testScope = interactor.testScopeOverride val realScope = interactor.coroutineScope - assertThat(testScope).isInstanceOf(TestCoroutineScope::class.java) + assertThat(testScope).isInstanceOf(TestScope::class.java) assertThat(testScope).isEqualTo(realScope) - interactor.disableTestCoroutineScopeOverride() - val testScope2 = interactor.testCoroutineScopeOverride + interactor.disableTestScopeOverride() + val testScope2 = interactor.testScopeOverride val realScope2 = interactor.coroutineScope assertThat(testScope2).isNull() - assertThat(realScope2).isNotInstanceOf(TestCoroutineScope::class.java) + assertThat(realScope2).isNotInstanceOf(TestScope::class.java) } @Test() @@ -132,18 +132,27 @@ internal class RibScopesTest { // Can use mock since all logic is in extension function. val application: Application = mock() - assertThat(application.testCoroutineScopeOverride).isNull() + assertThat(application.testScopeOverride).isNull() - application.enableTestCoroutineScopeOverride() - val testScope = application.testCoroutineScopeOverride + application.enableTestScopeOverride() + val testScope = application.testScopeOverride val realScope = application.coroutineScope - assertThat(testScope).isInstanceOf(TestCoroutineScope::class.java) + assertThat(testScope).isInstanceOf(TestScope::class.java) assertThat(testScope).isEqualTo(realScope) - application.disableTestCoroutineScopeOverride() - val testScope2 = application.testCoroutineScopeOverride + application.disableTestScopeOverride() + val testScope2 = application.testScopeOverride val realScope2 = application.coroutineScope assertThat(testScope2).isNull() - assertThat(realScope2).isNotInstanceOf(TestCoroutineScope::class.java) + assertThat(realScope2).isNotInstanceOf(TestScope::class.java) + } + + private class TestUncaughtExceptionCaptor : CoroutineExceptionHandler { + var exceptions = mutableListOf() + + override val key: CoroutineContext.Key<*> = CoroutineExceptionHandler + override fun handleException(context: CoroutineContext, exception: Throwable) { + exceptions.add(exception) + } } } diff --git a/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibEventPayload.kt b/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibEventPayload.kt index d31f78ccf..56dd84212 100644 --- a/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibEventPayload.kt +++ b/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibEventPayload.kt @@ -79,9 +79,9 @@ internal class RibEventPayload( var context: android.content.Context? = view.getContext() while (context is ContextWrapper) { if (context is Activity) { - return (context as Activity).javaClass.getName() + return context.javaClass.getName() } - context = (context as ContextWrapper).getBaseContext() + context = context.getBaseContext() } } return "" diff --git a/android/tutorials/tutorial4/build.gradle b/android/tutorials/tutorial4/build.gradle index 49b3f8adc..12e887665 100644 --- a/android/tutorials/tutorial4/build.gradle +++ b/android/tutorials/tutorial4/build.gradle @@ -48,7 +48,6 @@ android { dependencies { annotationProcessor deps.apt.autoValue - annotationProcessor deps.apt.raveCompiler annotationProcessor deps.apt.daggerCompiler annotationProcessor project(":libraries:rib-compiler-test") implementation project(":libraries:rib-android") @@ -57,7 +56,6 @@ dependencies { implementation deps.androidx.appcompat implementation deps.external.dagger implementation deps.external.rxbinding - implementation deps.uber.rave implementation deps.androidx.percent implementation deps.external.guavaAndroid compileOnly deps.apt.javax diff --git a/android/tutorials/tutorial4/src/main/java/com/uber/rib/RootActivity.java b/android/tutorials/tutorial4/src/main/java/com/uber/rib/RootActivity.java index 97ee21c85..b696d64be 100644 --- a/android/tutorials/tutorial4/src/main/java/com/uber/rib/RootActivity.java +++ b/android/tutorials/tutorial4/src/main/java/com/uber/rib/RootActivity.java @@ -17,13 +17,10 @@ import android.content.Intent; import android.os.Bundle; -import android.util.Log; import android.view.ViewGroup; import androidx.annotation.Nullable; import com.google.common.base.Optional; import com.uber.autodispose.AutoDispose; -import com.uber.rave.Rave; -import com.uber.rave.RaveException; import com.uber.rib.core.RibActivity; import com.uber.rib.core.ViewRouter; import com.uber.rib.root.RootBuilder; @@ -58,20 +55,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { private void handleDeepLink(Intent intent) { RootWorkflow rootWorkflow = new WorkflowFactory().getWorkflow(intent); if (rootWorkflow != null) { - try { - Rave.getInstance().validate(rootWorkflow.getDeepLinkModel()); - rootWorkflow - .createSingle(rootInteractor) - .as(AutoDispose.>autoDisposable(this)) - .subscribe( - new Consumer>() { - @Override - public void accept(Optional optional) throws Exception {} - }); - } catch (RaveException exception) { - Log.e("RootActivity", "Invalid deep link model received.", exception); - } + rootWorkflow + .createSingle(rootInteractor) + .as(AutoDispose.>autoDisposable(this)) + .subscribe( + new Consumer>() { + @Override + public void accept(Optional optional) throws Exception {} + }); } } diff --git a/android/tutorials/tutorial4/src/main/java/com/uber/rib/root/TrainingSessionsValidationFactory.java b/android/tutorials/tutorial4/src/main/java/com/uber/rib/root/TrainingSessionsValidationFactory.java deleted file mode 100644 index 93361c7d6..000000000 --- a/android/tutorials/tutorial4/src/main/java/com/uber/rib/root/TrainingSessionsValidationFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2017. Uber Technologies - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.uber.rib.root; - -import androidx.annotation.NonNull; -import com.uber.rave.BaseValidator; -import com.uber.rave.ValidatorFactory; -import com.uber.rave.annotation.Validated; - -public class TrainingSessionsValidationFactory implements ValidatorFactory { - - @NonNull - @Override - public BaseValidator generateValidator() { - return new TrainingSessionsValidationFactory_Generated_Validator(); - } - - // Rave won't compiler validation factories unless there is one thing using it... - @Validated(factory = TrainingSessionsValidationFactory.class) - static class EmptyObject {} -}