Skip to content

Commit afa68d0

Browse files
osipxdcopybara-github
authored andcommitted
[GH] [Navigation] Fix tests in NavDeepLinkTest
There were tests that actually did not what was declared in assert. ## Testing Test: ./gradlew connectedCheck This is an imported pull request from androidx#210. Resolves androidx#210 Github-Pr-Head-Sha: 642e2a2 GitOrigin-RevId: d3e202a Change-Id: I5d5ce1a5a5e61f984bfb6022ca6c5dd261d3020e
1 parent 597c5c5 commit afa68d0

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ class NavDeepLinkTest {
337337
assertWithMessage("Args should not be null")
338338
.that(matchArgs)
339339
.isNotNull()
340-
assertWithMessage("Args should contain the argument and it should be null")
341-
.that(matchArgs?.getString("myarg"))
342-
.isNull()
340+
assertWithMessage("Args should not contain the argument")
341+
.that(matchArgs?.containsKey("myarg"))
342+
.isFalse()
343343
}
344344

345345
// Ensure case when matching the exact argument query (i.e. param names in braces) is handled
@@ -374,9 +374,9 @@ class NavDeepLinkTest {
374374
assertWithMessage("Args should not be null")
375375
.that(matchArgs)
376376
.isNotNull()
377-
assertWithMessage("Args should contain the argument and it should be null")
378-
.that(matchArgs?.getString("myarg"))
379-
.isNull()
377+
assertWithMessage("Args should not contain the argument")
378+
.that(matchArgs?.containsKey("myarg"))
379+
.isFalse()
380380
}
381381

382382
@Test
@@ -451,9 +451,9 @@ class NavDeepLinkTest {
451451
assertWithMessage("Args should contain the id")
452452
.that(matchArgs?.getInt("id"))
453453
.isEqualTo(id)
454-
assertWithMessage("Args should contain optional")
455-
.that(matchArgs?.getString("optional"))
456-
.isNull()
454+
assertWithMessage("Args should not contain optional")
455+
.that(matchArgs?.containsKey("optional"))
456+
.isFalse()
457457
}
458458

459459
// Make sure we allow extra params that may not been part of the given deep link
@@ -541,9 +541,9 @@ class NavDeepLinkTest {
541541
assertWithMessage("Args should not be null")
542542
.that(matchArgs)
543543
.isNotNull()
544-
assertWithMessage("Args should contain the argument and it should be null")
545-
.that(matchArgs?.getString("myarg"))
546-
.isNull()
544+
assertWithMessage("Args should not contain the argument")
545+
.that(matchArgs?.containsKey("myarg"))
546+
.isFalse()
547547
}
548548

549549
@Test
@@ -579,9 +579,9 @@ class NavDeepLinkTest {
579579
assertWithMessage("Args should not be null")
580580
.that(matchArgs)
581581
.isNotNull()
582-
assertWithMessage("Args should contain the argument and it should be null")
583-
.that(matchArgs?.getString("myarg"))
584-
.isNull()
582+
assertWithMessage("Args should not contain the argument")
583+
.that(matchArgs?.containsKey("myarg"))
584+
.isFalse()
585585
}
586586

587587
@Test
@@ -632,9 +632,9 @@ class NavDeepLinkTest {
632632
assertWithMessage("Args should not be null")
633633
.that(matchArgs)
634634
.isNotNull()
635-
assertWithMessage("Args should contain the argument and it should be null")
636-
.that(matchArgs?.getString("myarg"))
637-
.isNull()
635+
assertWithMessage("Args should not contain the argument")
636+
.that(matchArgs?.containsKey("myarg"))
637+
.isFalse()
638638
}
639639

640640
@Test
@@ -745,12 +745,12 @@ class NavDeepLinkTest {
745745
assertWithMessage("Args should not be null")
746746
.that(matchArgs)
747747
.isNotNull()
748-
assertWithMessage("Args should contain the first name")
749-
.that(matchArgs?.getString("first"))
750-
.isNull()
751-
assertWithMessage("Args should contain the last name")
752-
.that(matchArgs?.getString("last"))
753-
.isNull()
748+
assertWithMessage("Args should not contain the first name")
749+
.that(matchArgs?.containsKey("first"))
750+
.isFalse()
751+
assertWithMessage("Args should not contain the last name")
752+
.that(matchArgs?.containsKey("last"))
753+
.isFalse()
754754
}
755755

756756
@Test
@@ -804,9 +804,9 @@ class NavDeepLinkTest {
804804
assertWithMessage("Args should not be null")
805805
.that(matchArgs)
806806
.isNotNull()
807-
assertWithMessage("Args should contain arg as null")
808-
.that(matchArgs?.getString("myarg"))
809-
.isNull()
807+
assertWithMessage("Args should not contain the argument")
808+
.that(matchArgs?.containsKey("myarg"))
809+
.isFalse()
810810
}
811811

812812
// Handle the case were the input is wild card and separator with no argument
@@ -918,9 +918,9 @@ class NavDeepLinkTest {
918918
assertWithMessage("Args should not be null")
919919
.that(matchArgs)
920920
.isNotNull()
921-
assertWithMessage("Args should contain the path as null")
922-
.that(matchArgs?.getString("path"))
923-
.isNull()
921+
assertWithMessage("Args should not contain the path")
922+
.that(matchArgs?.containsKey("path"))
923+
.isFalse()
924924
}
925925

926926
// Handle the case were the input could be entire path except for the argument

0 commit comments

Comments
 (0)