Add NavArgument helper methods for androidTest
Instead of using the full NavArgument.Builder
syntax, provide a set of high level functions
that simplify the syntax in the instrumentation
tests.
Test: tests still pass
Change-Id: I917b4cd4537254f0978c7143f3668ccdfad5b8e8
diff --git a/navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt b/navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt
index fff7f49..a084bc3 100644
--- a/navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt
+++ b/navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt
@@ -17,6 +17,8 @@
package androidx.navigation
import android.os.Bundle
+import androidx.navigation.test.intArgument
+import androidx.navigation.test.stringArgument
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -24,18 +26,9 @@
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
-private val stringArgument = "stringArg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build()
-private val stringArgumentWithDefault = "stringArg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue("aaa")
- .build()
-private val intArgument = "intArg" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(123)
- .build()
+private val stringArgumentWithoutDefault = "stringArg" to stringArgument(true)
+private val stringArgumentWithDefault = "stringArg" to stringArgument("aaa")
+private val intArgumentWithDefault = "intArg" to intArgument(123)
@SmallTest
@RunWith(Parameterized::class)
@@ -51,11 +44,11 @@
// Test with an empty set of arguments
mapOf(),
// Test with an argument with no default value
- mapOf(stringArgument),
+ mapOf(stringArgumentWithoutDefault),
// Test with arguments where only some have default values
- mapOf(stringArgument, intArgument),
+ mapOf(stringArgumentWithoutDefault, intArgumentWithDefault),
// Test with arguments that have default values
- mapOf(stringArgumentWithDefault, intArgument)
+ mapOf(stringArgumentWithDefault, intArgumentWithDefault)
).forEach { arguments: Map<String, NavArgument> ->
// Run with a null Bundle
add(arrayOf(arguments, Bundle.EMPTY))
diff --git a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
index 1c3302e..b26ce1c 100644
--- a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
+++ b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
@@ -17,6 +17,9 @@
package androidx.navigation
import android.net.Uri
+import androidx.navigation.test.intArgument
+import androidx.navigation.test.nullableStringArgument
+import androidx.navigation.test.stringArgument
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -110,7 +113,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -128,7 +131,7 @@
val id = "invalid"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{id}", id)),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should be null")
.that(matchArgs)
@@ -143,7 +146,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -161,7 +164,7 @@
val id = "invalid"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{id}", id)),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should be null")
.that(matchArgs)
@@ -178,12 +181,8 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument
.replace("{id}", id.toString()).replace("{myarg}", myarg)),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build(),
- "myarg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .build())
+ mapOf("id" to intArgument(),
+ "myarg" to stringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -204,10 +203,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(id)
- .build())
+ mapOf("id" to intArgument(id))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -224,10 +220,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("myarg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("myarg" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -246,10 +239,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(id)
- .build())
+ mapOf("id" to intArgument(id))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -267,10 +257,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument),
- mapOf("myarg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("myarg" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -289,13 +276,8 @@
val optional = "test"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?id={id}".replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build(),
- "optional" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(optional)
- .build())
+ mapOf("id" to intArgument(),
+ "optional" to stringArgument(optional))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -318,13 +300,8 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?optional={optional}&id={id}"
.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build(),
- "optional" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(optional)
- .build())
+ mapOf("id" to intArgument(),
+ "optional" to stringArgument(optional))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -345,13 +322,8 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?id={id}".replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build(),
- "optional" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("id" to intArgument(),
+ "optional" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -374,13 +346,8 @@
deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?id={id}&invalid={invalid}"
.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build(),
- "invalid" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build()))
+ mapOf("id" to intArgument(),
+ "invalid" to nullableStringArgument()))
fail(
"Adding parameter that does not exists in the NavDeepLink should throw " +
"IllegalArgumentException"
@@ -403,9 +370,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?string={id}"
.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -422,10 +387,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("myarg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("myarg" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -443,10 +405,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(id)
- .build())
+ mapOf("id" to intArgument(id))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -464,7 +423,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -481,10 +440,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("myarg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("myarg" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -502,10 +458,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(id)
- .build())
+ mapOf("id" to intArgument(id))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -524,8 +477,8 @@
val last = "Doe"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{first}", first).replace("{last}", last)),
- mapOf("first" to NavArgument.Builder().setType(NavType.StringType).build(),
- "last" to NavArgument.Builder().setType(NavType.StringType).build())
+ mapOf("first" to stringArgument(),
+ "last" to stringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -547,14 +500,8 @@
val last = "Doe"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("first" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(first)
- .build(),
- "last" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(last)
- .build())
+ mapOf("first" to stringArgument(first),
+ "last" to stringArgument(last))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -576,13 +523,8 @@
val last = "Doe"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?name=Jane_"),
- mapOf("first" to NavArgument.Builder()
- .setType(NavType.StringType)
- .build(),
- "last" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(last)
- .build())
+ mapOf("first" to stringArgument(),
+ "last" to stringArgument(last))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -602,14 +544,8 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("first" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build(),
- "last" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("first" to nullableStringArgument(),
+ "last" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -631,9 +567,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?productId=wildCardMatch-{id}"
.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -651,10 +585,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(id)
- .build())
+ mapOf("id" to intArgument(id))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -671,10 +602,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?productId=wildCardMatch-{myarg}"),
- mapOf("myarg" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("myarg" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -693,10 +621,7 @@
val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?productId=.*-"),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(id)
- .build())
+ mapOf("id" to intArgument(id))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -715,9 +640,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?productId=A*B{id}"
.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -736,9 +659,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?productId={id}A*B"
.replace("{id}", id.toString())),
- mapOf("id" to NavArgument.Builder()
- .setType(NavType.IntType)
- .build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -756,9 +677,7 @@
val path = "directions"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?path=go/to/{path}".replace("{path}", path)),
- mapOf("path" to NavArgument.Builder()
- .setType(NavType.StringType)
- .build())
+ mapOf("path" to stringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -776,10 +695,7 @@
val path = "directions"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("path" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(path)
- .build())
+ mapOf("path" to stringArgument(path))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -796,10 +712,7 @@
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users"),
- mapOf("path" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setIsNullable(true)
- .build())
+ mapOf("path" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -818,10 +731,7 @@
val path = "directions"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("$DEEP_LINK_EXACT_HTTPS/users?path=go/to/"),
- mapOf("path" to NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue(path)
- .build())
+ mapOf("path" to stringArgument(path))
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -840,7 +750,7 @@
val name = "John Doe"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument.replace("{name}", Uri.encode(name))),
- mapOf("name" to NavArgument.Builder().setType(NavType.StringType).build())
+ mapOf("name" to stringArgument())
)
assertWithMessage("Args should not be null")
@@ -862,8 +772,8 @@
Uri.parse(deepLinkArgument
.replace("{id}", id.toString())
.replace("{postId}", postId.toString())),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build(),
- "postId" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument(),
+ "postId" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -913,7 +823,7 @@
Uri.parse(deepLinkMultiple
.replace(".*", "test")
.replace("{postId}", postId.toString())),
- mapOf("postId" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("postId" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
@@ -933,7 +843,7 @@
Uri.parse(deepLinkMultiple
.replace("{id}", id.toString())
.replace(".*", "test")),
- mapOf("id" to NavArgument.Builder().setType(NavType.IntType).build())
+ mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
diff --git a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
index 0aab743..41bbc79 100644
--- a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
+++ b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
@@ -18,6 +18,8 @@
import android.net.Uri
import android.os.Bundle
+import androidx.navigation.test.intArgument
+import androidx.navigation.test.stringArgument
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -28,10 +30,7 @@
@Test
fun matchDeepLink() {
val destination = NoOpNavigator().createDestination()
- val idArgument = NavArgument.Builder()
- .setType(NavType.IntType)
- .build()
- destination.addArgument("id", idArgument)
+ destination.addArgument("id", intArgument())
destination.addDeepLink("www.example.com/users/{id}")
val match = destination.matchDeepLink(
@@ -52,10 +51,7 @@
destination.addDeepLink("www.example.com/users/index.html")
- val idArgument = NavArgument.Builder()
- .setType(NavType.StringType)
- .build()
- destination.addArgument("id", idArgument)
+ destination.addArgument("id", stringArgument())
destination.addDeepLink("www.example.com/users/{name}")
val match = destination.matchDeepLink(
@@ -89,16 +85,10 @@
fun matchDeepLinkBestMatch() {
val destination = NoOpNavigator().createDestination()
- val idArgument = NavArgument.Builder()
- .setType(NavType.IntType)
- .build()
- destination.addArgument("id", idArgument)
+ destination.addArgument("id", intArgument())
destination.addDeepLink("www.example.com/users/{id}")
- val postIdArgument = NavArgument.Builder()
- .setType(NavType.IntType)
- .build()
- destination.addArgument("postId", postIdArgument)
+ destination.addArgument("postId", intArgument())
destination.addDeepLink("www.example.com/users/{id}/posts/{postId}")
val match = destination.matchDeepLink(
@@ -131,10 +121,7 @@
@Test
fun testIsValidDeepLinkValidLinkPattern() {
val destination = NoOpNavigator().createDestination()
- val stringArgument = NavArgument.Builder()
- .setType(NavType.StringType)
- .build()
- destination.addArgument("testString", stringArgument)
+ destination.addArgument("testString", stringArgument())
destination.addDeepLink("android-app://androidx.navigation.test/{testString}")
val deepLink = Uri.parse("android-app://androidx.navigation.test/test")
destination.addDeepLink(deepLink.toString())
@@ -156,16 +143,8 @@
@Test
fun addInDefaultArgs() {
val destination = NoOpNavigator().createDestination()
- val stringArgument = NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue("aaa")
- .build()
- val intArgument = NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(123)
- .build()
- destination.addArgument("stringArg", stringArgument)
- destination.addArgument("intArg", intArgument)
+ destination.addArgument("stringArg", stringArgument("aaa"))
+ destination.addArgument("intArg", intArgument(123))
val bundle = destination.addInDefaultArgs(Bundle().apply {
putString("stringArg", "bbb")
@@ -177,16 +156,8 @@
@Test(expected = IllegalArgumentException::class)
fun addInDefaultArgsWrong() {
val destination = NoOpNavigator().createDestination()
- val stringArgument = NavArgument.Builder()
- .setType(NavType.StringType)
- .setDefaultValue("aaa")
- .build()
- val intArgument = NavArgument.Builder()
- .setType(NavType.IntType)
- .setDefaultValue(123)
- .build()
- destination.addArgument("stringArg", stringArgument)
- destination.addArgument("intArg", intArgument)
+ destination.addArgument("stringArg", stringArgument("aaa"))
+ destination.addArgument("intArg", intArgument(123))
destination.addInDefaultArgs(Bundle().apply {
putInt("stringArg", 123)
diff --git a/navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt b/navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
new file mode 100644
index 0000000..1446431
--- /dev/null
+++ b/navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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 androidx.navigation.test
+
+import androidx.navigation.NavArgument
+import androidx.navigation.NavType.IntType
+import androidx.navigation.NavType.StringType
+
+// region IntType
+fun intArgument() = NavArgument.Builder().setType(IntType).build()
+
+fun intArgument(
+ defaultValue: Int
+) = NavArgument.Builder().setType(IntType)
+ .setDefaultValue(defaultValue)
+ .build()
+// endregion
+
+// region StringType
+fun stringArgument(
+ isNullable: Boolean = false
+) = NavArgument.Builder().setType(StringType)
+ .setIsNullable(isNullable)
+ .build()
+
+fun stringArgument(
+ defaultValue: String
+) = NavArgument.Builder().setType(StringType)
+ .setDefaultValue(defaultValue)
+ .build()
+
+fun nullableStringArgument() = NavArgument.Builder().setType(StringType)
+ .setIsNullable(true)
+ .build()
+// endregion