diff --git a/.travis.yml b/.travis.yml index 57ec961..e28179d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: android sudo: required -jdk: oraclejdk8 +jdk: openjdk8 before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock diff --git a/README.md b/README.md index fbe0058..d2df44b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A declarative router for [ReKotlin](https://github.com/GeoThings/ReKotlin). Allows developers to declare routes in a similar manner as URLs are used on the web. -Using ReKotlinRouter you can navigate your app by defining the target location in the form of a URL-like sequence of identifiers: +Using ReKotlinRouter you can navigate your app by defining the target location in the form of a URL-like sequence of identifiers:- ```Kotlin val routes = arrayListOf(loginRoute, repoListRoute, repoDetailRoute) @@ -237,4 +237,4 @@ You can find all the details on how to get started in the [Contributing Guide](/ ## Credits - Many thanks to [Benjamin Encz](https://github.com/Ben-G) and other ReSwift contributors for buidling original [ReSwift](https://github.com/ReSwift/ReSwift) that we really enjoyed working with. -- Also huge thanks to [Dan Abramov](https://github.com/gaearon) for building [Redux](https://github.com/reactjs/redux) - all ideas in here and many implementation details were provided by his library. \ No newline at end of file +- Also huge thanks to [Dan Abramov](https://github.com/gaearon) for building [Redux](https://github.com/reactjs/redux) - all ideas in here and many implementation details were provided by his library. diff --git a/gradle.properties b/gradle.properties index 5465fec..f69e6c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,6 @@ android.enableJetifier=true -android.useAndroidX=true \ No newline at end of file +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3072m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.parallel=true +org.gradle.configureondemand=true +kapt.incremental.apt=true \ No newline at end of file diff --git a/rekotlin-router/src/test/java/org/rekotlinrouter/ReKotlinRouterUnitTests.kt b/rekotlin-router/src/test/java/org/rekotlinrouter/ReKotlinRouterUnitTests.kt index b1a5395..da8e32b 100644 --- a/rekotlin-router/src/test/java/org/rekotlinrouter/ReKotlinRouterUnitTests.kt +++ b/rekotlin-router/src/test/java/org/rekotlinrouter/ReKotlinRouterUnitTests.kt @@ -6,10 +6,10 @@ import org.junit.Test internal class ReKotlinRouterUnitTests { - val mainActivityIdentifier = "MainActivity" - val counterActivityIdentifier = "CounterActivity" - val statsActivityIdentifier = "StatsActivity" - val infoActivityIdentifier = "InfoActivity" + private val mainActivityIdentifier = "MainActivity" + private val counterActivityIdentifier = "CounterActivity" + private val statsActivityIdentifier = "StatsActivity" + private val infoActivityIdentifier = "InfoActivity" @Test //@DisplayName("calculates transitions from an empty route to a multi segment route") @@ -112,6 +112,44 @@ internal class ReKotlinRouterUnitTests { assertThat(routingActions.count()).isEqualTo(2) } + @Test + // @DisplayName("generates a Change action on the last common subroute, also for routes of different length, old route is longer than new route") + fun test_change_action_on_last_common_sub_route_plus_routes_of_different_length_old_route_is_longer_than_new_route() { + + // Given + val oldRoute = arrayListOf(mainActivityIdentifier, statsActivityIdentifier, infoActivityIdentifier) + val newRoute = arrayListOf(mainActivityIdentifier, counterActivityIdentifier) + + // When + val routingActions = Router.routingActionsForTransitionFrom(oldRoute, newRoute) + + // Then + var action1Correct = false + var action2Correct = false + + routingActions.forEach { routingAction -> + when (routingAction) { + is pop -> { + if (routingAction.responsibleRoutableIndex == 2 && routingAction.segmentToBePopped == infoActivityIdentifier) { + action1Correct = true + } + + } + is change -> { + if (routingAction.responsibleRoutableIndex == 1 + && routingAction.segmentToBeReplaced == statsActivityIdentifier + && routingAction.newSegment == counterActivityIdentifier) { + action2Correct = true + } + } + } + } + + assertThat(action1Correct).isTrue() + assertThat(action2Correct).isTrue() + assertThat(routingActions.count()).isEqualTo(2) + } + @Test // @DisplayName("generates a Change action on root when root element changes") fun test_change_action_on_root_when_root_element_changes() {