Skip to content

A fully functional Android app built entirely with Kotlin and Jetpack Compose

Update to navigation 2.8.0-beta01

Don Turner8fc2e15e73de
diff --git a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt
index dcb93f29f..1aca52136 100644
--- a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt
+++ b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt
@@ -50,6 +50,7 @@ class AndroidFeatureConventionPlugin : Plugin<Project> {
add("implementation", libs.findLibrary("androidx.tracing.ktx").get())
add("implementation", libs.findLibrary("kotlinx.serialization.json").get())
+ add("testImplementation", libs.findLibrary("androidx.navigation.testing").get())
add("androidTestImplementation", libs.findLibrary("androidx.lifecycle.runtimeTesting").get())
}
}
diff --git a/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt b/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt
index 91e710b32..6ecbc2dda 100644
--- a/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt
+++ b/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt
@@ -17,6 +17,7 @@
package com.google.samples.apps.nowinandroid.interests
import androidx.lifecycle.SavedStateHandle
+import androidx.navigation.testing.invoke
import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic
@@ -25,7 +26,7 @@ import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserData
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState
import com.google.samples.apps.nowinandroid.feature.interests.InterestsViewModel
-import com.google.samples.apps.nowinandroid.feature.interests.navigation.TOPIC_ID_KEY
+import com.google.samples.apps.nowinandroid.feature.interests.navigation.InterestsDestination
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher
@@ -55,9 +56,11 @@ class InterestsViewModelTest {
@Before
fun setup() {
viewModel = InterestsViewModel(
- // TODO: Construct from destination when aosp/3073537 lands (due 14th May 2024)
- // savedStateHandle = SavedStateHandle(InterestsDestination(initialTopicId = testInputTopics[0].topic.id)),
- savedStateHandle = SavedStateHandle(mapOf("initialTopicId" to testInputTopics[0].topic.id)),
+ // TODO: This line causes tests to fail since it introduces an Android dependency
+ // see b/340966212 for more information
+ savedStateHandle = SavedStateHandle(
+ route = InterestsDestination(initialTopicId = testInputTopics[0].topic.id),
+ ),
userDataRepository = userDataRepository,
getFollowableTopics = getFollowableTopicsUseCase,
)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index b52bd4af8..fc1be4ad4 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -20,7 +20,7 @@ androidxHiltNavigationCompose = "1.2.0"
androidxLifecycle = "2.7.0"
androidxMacroBenchmark = "1.2.2"
androidxMetrics = "1.0.0-alpha04"
-androidxNavigation = "2.8.0-alpha08"
+androidxNavigation = "2.8.0-beta01"
androidxProfileinstaller = "1.3.1"
androidxTestCore = "1.5.0"
androidxTestExt = "1.1.5"