Revert "Improve accessibility to ForYou topics (#1309)" (#1732)

This reverts commit 48544194f4.
pull/1733/head
Ben Weiss 2 weeks ago committed by GitHub
parent b9105c61f7
commit d8b735f80e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -18,8 +18,7 @@ package com.google.samples.apps.nowinandroid.ui
import androidx.compose.ui.semantics.SemanticsActions.ScrollBy import androidx.compose.ui.semantics.SemanticsActions.ScrollBy
import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText import androidx.compose.ui.test.hasText
@ -88,8 +87,6 @@ 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)
@ -118,20 +115,13 @@ class NavigationTest {
fun navigationBar_navigateToPreviouslySelectedTab_restoresContent() { fun navigationBar_navigateToPreviouslySelectedTab_restoresContent() {
composeTestRule.apply { composeTestRule.apply {
// GIVEN the user follows a topic // GIVEN the user follows a topic
onNodeWithContentDescription(sampleTopic).performClick() onNodeWithText(sampleTopic).performClick()
// WHEN the user navigates to the Interests destination // WHEN the user navigates to the Interests destination
onNodeWithText(interests).performClick() onNodeWithText(interests).performClick()
// 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( onNodeWithContentDescription(sampleTopic).assertIsOn()
sampleTopicCheckIconDescription,
useUnmergedTree = true,
).assertIsDisplayed()
onNodeWithContentDescription(
sampleTopicAddIconDescription,
useUnmergedTree = true,
).assertIsNotDisplayed()
} }
} }
@ -142,18 +132,11 @@ class NavigationTest {
fun navigationBar_reselectTab_keepsState() { fun navigationBar_reselectTab_keepsState() {
composeTestRule.apply { composeTestRule.apply {
// GIVEN the user follows a topic // GIVEN the user follows a topic
onNodeWithContentDescription(sampleTopic).performClick() onNodeWithText(sampleTopic).performClick()
// 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( onNodeWithContentDescription(sampleTopic).assertIsOn()
sampleTopicCheckIconDescription,
useUnmergedTree = true,
).assertIsDisplayed()
onNodeWithContentDescription(
sampleTopicAddIconDescription,
useUnmergedTree = true,
).assertIsNotDisplayed()
} }
} }

@ -128,7 +128,7 @@ class ForYouScreenTest {
testData.forEach { testTopic -> testData.forEach { testTopic ->
composeTestRule composeTestRule
.onNodeWithContentDescription(testTopic.topic.name) .onNodeWithText(testTopic.topic.name)
.assertExists() .assertExists()
.assertHasClickAction() .assertHasClickAction()
} }
@ -175,7 +175,7 @@ class ForYouScreenTest {
followableTopicTestData.forEach { testTopic -> followableTopicTestData.forEach { testTopic ->
composeTestRule composeTestRule
.onNodeWithContentDescription(testTopic.topic.name) .onNodeWithText(testTopic.topic.name)
.assertExists() .assertExists()
.assertHasClickAction() .assertHasClickAction()
} }

@ -75,13 +75,6 @@ import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState.Off
import androidx.compose.ui.state.ToggleableState.On
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -275,30 +268,23 @@ private fun LazyStaggeredGridScope.onboarding(
is OnboardingUiState.Shown -> { is OnboardingUiState.Shown -> {
item(span = StaggeredGridItemSpan.FullLine, contentType = "onboarding") { item(span = StaggeredGridItemSpan.FullLine, contentType = "onboarding") {
Column( Column(modifier = interestsItemModifier) {
modifier = interestsItemModifier, Text(
) { text = stringResource(R.string.feature_foryou_onboarding_guidance_title),
Column( textAlign = TextAlign.Center,
modifier = Modifier modifier = Modifier
.semantics(mergeDescendants = true) { }, .fillMaxWidth()
) { .padding(top = 24.dp),
Text( style = MaterialTheme.typography.titleMedium,
text = stringResource(R.string.feature_foryou_onboarding_guidance_title), )
textAlign = TextAlign.Center, Text(
modifier = Modifier text = stringResource(R.string.feature_foryou_onboarding_guidance_subtitle),
.fillMaxWidth() modifier = Modifier
.padding(top = 24.dp), .fillMaxWidth()
style = MaterialTheme.typography.titleMedium, .padding(top = 8.dp, start = 24.dp, end = 24.dp),
) textAlign = TextAlign.Center,
Text( style = MaterialTheme.typography.bodyMedium,
text = stringResource(R.string.feature_foryou_onboarding_guidance_subtitle), )
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp, start = 24.dp, end = 24.dp),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyMedium,
)
}
TopicSelection( TopicSelection(
onboardingUiState, onboardingUiState,
onTopicCheckedChanged, onTopicCheckedChanged,
@ -398,21 +384,7 @@ private fun SingleTopicButton(
Surface( Surface(
modifier = Modifier modifier = Modifier
.width(312.dp) .width(312.dp)
.heightIn(min = 56.dp) .heightIn(min = 56.dp),
.semantics(mergeDescendants = true) {
toggleableState = if (isSelected) {
On
} else {
Off
}
stateDescription = if (isSelected) {
"Following"
} else {
"Not Following"
}
contentDescription = name
},
shape = RoundedCornerShape(corner = CornerSize(8.dp)), shape = RoundedCornerShape(corner = CornerSize(8.dp)),
color = MaterialTheme.colorScheme.surface, color = MaterialTheme.colorScheme.surface,
selected = isSelected, selected = isSelected,
@ -422,9 +394,7 @@ private fun SingleTopicButton(
) { ) {
Row( Row(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
modifier = Modifier modifier = Modifier.padding(start = 12.dp, end = 8.dp),
.padding(start = 12.dp, end = 8.dp)
.clearAndSetSemantics { },
) { ) {
TopicIcon( TopicIcon(
imageUrl = imageUrl, imageUrl = imageUrl,
@ -443,19 +413,13 @@ private fun SingleTopicButton(
icon = { icon = {
Icon( Icon(
imageVector = NiaIcons.Add, imageVector = NiaIcons.Add,
contentDescription = stringResource( contentDescription = name,
id = R.string.feature_foryou_topic_icon_add,
name,
),
) )
}, },
checkedIcon = { checkedIcon = {
Icon( Icon(
imageVector = NiaIcons.Check, imageVector = NiaIcons.Check,
contentDescription = stringResource( contentDescription = name,
id = R.string.feature_foryou_topic_icon_checked,
name,
),
) )
}, },
) )

@ -21,7 +21,5 @@
<string name="feature_foryou_navigate_up">Navigate up</string> <string name="feature_foryou_navigate_up">Navigate up</string>
<string name="feature_foryou_onboarding_guidance_title">What are you interested in?</string> <string name="feature_foryou_onboarding_guidance_title">What are you interested in?</string>
<string name="feature_foryou_onboarding_guidance_subtitle">Updates from topics you follow will appear here. Follow some things to get started.</string> <string name="feature_foryou_onboarding_guidance_subtitle">Updates from topics you follow will appear here. Follow some things to get started.</string>
<string name="feature_foryou_topic_icon_checked">%s checked</string>
<string name="feature_foryou_topic_icon_add">%s add</string>
</resources> </resources>

Loading…
Cancel
Save