From 5401baae60ff93c631d32eb6991731a749ddbd1e Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Thu, 21 Mar 2024 14:40:01 +0900 Subject: [PATCH] Change state of icon check logic. Change-Id: I3e5e89fc1c469c3f3c4744d18f697f68d070996b --- .../apps/nowinandroid/ui/NavigationTest.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt index c9cc64120..f0efeffdc 100644 --- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt +++ b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt @@ -18,7 +18,8 @@ package com.google.samples.apps.nowinandroid.ui import androidx.annotation.StringRes import androidx.compose.ui.test.assertCountEquals -import androidx.compose.ui.test.assertIsOn +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.hasAnyAncestor import androidx.compose.ui.test.hasTestTag @@ -97,6 +98,8 @@ class NavigationTest { private val forYou by composeTestRule.stringResource(FeatureForyouR.string.feature_foryou_title) private val interests by composeTestRule.stringResource(FeatureSearchR.string.feature_search_interests) private val sampleTopic = "Headlines" + private val sampleTopicCheckIconDescription = "Headlines checked" + private val sampleTopicAddIconDescription = "Headlines add" private val appName by composeTestRule.stringResource(R.string.app_name) private val saved by composeTestRule.stringResource(BookmarksR.string.feature_bookmarks_title) private val settings by composeTestRule.stringResource(SettingsR.string.feature_settings_top_app_bar_action_icon_description) @@ -131,7 +134,14 @@ class NavigationTest { // AND the user navigates to the For You destination onNodeWithText(forYou).performClick() // THEN the state of the For You destination is restored - onNodeWithContentDescription(sampleTopic).assertIsOn() + onNodeWithContentDescription( + sampleTopicCheckIconDescription, + useUnmergedTree = true, + ).assertIsDisplayed() + onNodeWithContentDescription( + sampleTopicAddIconDescription, + useUnmergedTree = true, + ).assertIsNotDisplayed() } } @@ -146,7 +156,14 @@ class NavigationTest { // WHEN the user taps the For You navigation bar item onNodeWithText(forYou).performClick() // THEN the state of the For You destination is restored - onNodeWithContentDescription(sampleTopic).assertIsOn() + onNodeWithContentDescription( + sampleTopicCheckIconDescription, + useUnmergedTree = true, + ).assertIsDisplayed() + onNodeWithContentDescription( + sampleTopicAddIconDescription, + useUnmergedTree = true, + ).assertIsNotDisplayed() } }