Change state of icon check logic.

Change-Id: I3e5e89fc1c469c3f3c4744d18f697f68d070996b
pull/1309/head
Jaehwa Noh 2 years ago
parent ecf6e9e6fc
commit 5401baae60

@ -18,7 +18,8 @@ package com.google.samples.apps.nowinandroid.ui
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.ui.test.assertCountEquals 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.assertIsSelected
import androidx.compose.ui.test.hasAnyAncestor import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasTestTag 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 forYou by composeTestRule.stringResource(FeatureForyouR.string.feature_foryou_title)
private val interests by composeTestRule.stringResource(FeatureSearchR.string.feature_search_interests) private val interests by composeTestRule.stringResource(FeatureSearchR.string.feature_search_interests)
private val sampleTopic = "Headlines" 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 appName by composeTestRule.stringResource(R.string.app_name)
private val saved by composeTestRule.stringResource(BookmarksR.string.feature_bookmarks_title) 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) 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 // AND the user navigates to the For You destination
onNodeWithText(forYou).performClick() onNodeWithText(forYou).performClick()
// THEN the state of the For You destination is restored // 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 // WHEN the user taps the For You navigation bar item
onNodeWithText(forYou).performClick() onNodeWithText(forYou).performClick()
// THEN the state of the For You destination is restored // THEN the state of the For You destination is restored
onNodeWithContentDescription(sampleTopic).assertIsOn() onNodeWithContentDescription(
sampleTopicCheckIconDescription,
useUnmergedTree = true,
).assertIsDisplayed()
onNodeWithContentDescription(
sampleTopicAddIconDescription,
useUnmergedTree = true,
).assertIsNotDisplayed()
} }
} }

Loading…
Cancel
Save