Commit 811d82fe authored by Jenny Zhang's avatar Jenny Zhang Committed by Commit Bot

[a11y fix] Make app a11y announcement nice for RTL.

Bug: 916422
Change-Id: I668519db2facd9048b87eaa4b129ef32a159e513
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931654Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Jenny Zhang <jennyz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718935}
parent 0e60ff7d
...@@ -282,9 +282,9 @@ TEST_P(SearchResultTileItemListViewTest, Basic) { ...@@ -282,9 +282,9 @@ TEST_P(SearchResultTileItemListViewTest, Basic) {
view()->children()[first_child + i * child_step]->GetAccessibleNodeData( view()->children()[first_child + i * child_step]->GetAccessibleNodeData(
&node_data); &node_data);
EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role); EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role);
EXPECT_EQ("InstalledApp " + base::NumberToString(i) + ", " + EXPECT_EQ(l10n_util::GetStringFUTF8(
l10n_util::GetStringUTF8( IDS_APP_ACCESSIBILITY_INSTALLED_APP_ANNOUNCEMENT,
IDS_APP_ACCESSIBILITY_INSTALLED_APP_ANNOUNCEMENT), base::UTF8ToUTF16("InstalledApp " + base::NumberToString(i))),
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); node_data.GetStringAttribute(ax::mojom::StringAttribute::kName));
} }
...@@ -298,12 +298,13 @@ TEST_P(SearchResultTileItemListViewTest, Basic) { ...@@ -298,12 +298,13 @@ TEST_P(SearchResultTileItemListViewTest, Basic) {
->children()[first_child + (i + kInstalledApps) * child_step] ->children()[first_child + (i + kInstalledApps) * child_step]
->GetAccessibleNodeData(&node_data); ->GetAccessibleNodeData(&node_data);
EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role); EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role);
EXPECT_EQ("PlayStoreApp " + base::NumberToString(i) + ", " + EXPECT_EQ(
l10n_util::GetStringUTF8( l10n_util::GetStringFUTF8(
IDS_APP_ACCESSIBILITY_ARC_APP_ANNOUNCEMENT) + IDS_APP_ACCESSIBILITY_ARC_APP_ANNOUNCEMENT,
", Star rating " + base::NumberToString(i + 1) + base::UTF8ToUTF16("PlayStoreApp " + base::NumberToString(i))) +
".0, Price " + base::NumberToString(i), ", Star rating " + base::NumberToString(i + 1) + ".0, Price " +
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); base::NumberToString(i),
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName));
} }
// Recommendations. // Recommendations.
...@@ -314,9 +315,12 @@ TEST_P(SearchResultTileItemListViewTest, Basic) { ...@@ -314,9 +315,12 @@ TEST_P(SearchResultTileItemListViewTest, Basic) {
->children()[first_child + (i + start_index) * child_step] ->children()[first_child + (i + start_index) * child_step]
->GetAccessibleNodeData(&node_data); ->GetAccessibleNodeData(&node_data);
EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role); EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role);
EXPECT_EQ("RecommendedApp " + base::NumberToString(i) + ", Star rating " + EXPECT_EQ(
base::NumberToString(i + 1) + ".0, App recommendation", l10n_util::GetStringFUTF8(
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); IDS_APP_ACCESSIBILITY_APP_RECOMMENDATION_ARC,
base::UTF8ToUTF16("RecommendedApp " + base::NumberToString(i))) +
", Star rating " + base::NumberToString(i + 1) + ".0",
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName));
} }
ResetOpenResultCount(); ResetOpenResultCount();
...@@ -355,13 +359,16 @@ TEST_P(SearchResultTileItemListViewTest, TestRecommendations) { ...@@ -355,13 +359,16 @@ TEST_P(SearchResultTileItemListViewTest, TestRecommendations) {
view()->children()[first_index + i * child_step]->GetAccessibleNodeData( view()->children()[first_index + i * child_step]->GetAccessibleNodeData(
&node_data); &node_data);
EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role); EXPECT_EQ(ax::mojom::Role::kListBoxOption, node_data.role);
EXPECT_EQ("RecommendedApp " + base::NumberToString(i) + ", Star rating " + EXPECT_EQ(
base::NumberToString(i + 1) + ".0, App recommendation", l10n_util::GetStringFUTF8(
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); IDS_APP_ACCESSIBILITY_APP_RECOMMENDATION_ARC,
base::UTF8ToUTF16("RecommendedApp " + base::NumberToString(i))) +
", Star rating " + base::NumberToString(i + 1) + ".0",
node_data.GetStringAttribute(ax::mojom::StringAttribute::kName));
} }
} }
INSTANTIATE_TEST_SUITE_P(All, INSTANTIATE_TEST_SUITE_P(,
SearchResultTileItemListViewTest, SearchResultTileItemListViewTest,
testing::ValuesIn({std::make_pair(false, false), testing::ValuesIn({std::make_pair(false, false),
std::make_pair(false, true), std::make_pair(false, true),
......
...@@ -221,40 +221,36 @@ void SearchResultTileItemView::OnResultChanged() { ...@@ -221,40 +221,36 @@ void SearchResultTileItemView::OnResultChanged() {
base::string16 SearchResultTileItemView::ComputeAccessibleName() const { base::string16 SearchResultTileItemView::ComputeAccessibleName() const {
base::string16 accessible_name; base::string16 accessible_name;
if (!result()->accessible_name().empty()) if (!result()->accessible_name().empty())
accessible_name = result()->accessible_name(); return result()->accessible_name();
else
accessible_name = title_->GetText();
if (result()->result_type() == AppListSearchResultType::kPlayStoreApp || if (result()->result_type() == AppListSearchResultType::kPlayStoreApp ||
result()->result_type() == AppListSearchResultType::kInstantApp) { result()->result_type() == AppListSearchResultType::kInstantApp) {
accessible_name += accessible_name = l10n_util::GetStringFUTF16(
base::UTF8ToUTF16(", ") + IDS_APP_ACCESSIBILITY_ARC_APP_ANNOUNCEMENT, title_->GetText());
l10n_util::GetStringUTF16(IDS_APP_ACCESSIBILITY_ARC_APP_ANNOUNCEMENT); } else if (result()->result_type() ==
AppListSearchResultType::kPlayStoreReinstallApp) {
accessible_name = l10n_util::GetStringFUTF16(
IDS_APP_ACCESSIBILITY_APP_RECOMMENDATION_ARC, title_->GetText());
} else if (result()->result_type() == } else if (result()->result_type() ==
AppListSearchResultType::kInstalledApp) { AppListSearchResultType::kInstalledApp) {
accessible_name += base::UTF8ToUTF16(", ") + accessible_name = l10n_util::GetStringFUTF16(
l10n_util::GetStringUTF16( IDS_APP_ACCESSIBILITY_INSTALLED_APP_ANNOUNCEMENT, title_->GetText());
IDS_APP_ACCESSIBILITY_INSTALLED_APP_ANNOUNCEMENT);
} else if (result()->result_type() == AppListSearchResultType::kInternalApp) { } else if (result()->result_type() == AppListSearchResultType::kInternalApp) {
accessible_name += base::UTF8ToUTF16(", ") + accessible_name = l10n_util::GetStringFUTF16(
l10n_util::GetStringUTF16( IDS_APP_ACCESSIBILITY_INTERNAL_APP_ANNOUNCEMENT, title_->GetText());
IDS_APP_ACCESSIBILITY_INTERNAL_APP_ANNOUNCEMENT); } else {
accessible_name = title_->GetText();
} }
if (rating_ && rating_->GetVisible()) { if (rating_ && rating_->GetVisible()) {
accessible_name += accessible_name = l10n_util::GetStringFUTF16(
base::UTF8ToUTF16(", ") + IDS_APP_ACCESSIBILITY_APP_WITH_STAR_RATING_ARC, accessible_name,
l10n_util::GetStringFUTF16(IDS_APP_ACCESSIBILITY_STAR_RATING_ARC, rating_->GetText());
rating_->GetText());
} }
if (price_ && price_->GetVisible()) if (price_ && price_->GetVisible()) {
accessible_name += base::UTF8ToUTF16(", ") + price_->GetText(); accessible_name =
l10n_util::GetStringFUTF16(IDS_APP_ACCESSIBILITY_APP_WITH_PRICE_ARC,
if (result()->result_type() == accessible_name, price_->GetText());
AppListSearchResultType::kPlayStoreReinstallApp) {
accessible_name +=
base::UTF8ToUTF16(", ") +
l10n_util::GetStringUTF16(IDS_APP_ACCESSIBILITY_APP_RECOMMENDATION_ARC);
} }
return accessible_name; return accessible_name;
} }
......
...@@ -950,20 +950,23 @@ need to be translated for each locale.--> ...@@ -950,20 +950,23 @@ need to be translated for each locale.-->
</message> </message>
<message name="IDS_APP_ACCESSIBILITY_STAR_RATING_ARC" desc="Accessibility text for the star rating of a Play Store app."> <message name="IDS_APP_ACCESSIBILITY_APP_WITH_STAR_RATING_ARC" desc="Accessibility text for a Play Store app with star rating.">
Star rating <ph name="RATING_SCORE">$1<ex>5.0</ex></ph> <ph name="APP_NAME_TYPE">$1<ex>Snapchat, Playstore App</ex></ph>, Star rating <ph name="RATING_SCORE">$2<ex>5.0</ex></ph>
</message>
<message name="IDS_APP_ACCESSIBILITY_APP_WITH_PRICE_ARC" desc="Accessibility text for a Play Store app with price.">
<ph name="APP_NAME_INFO">$1<ex>Snapchat, Playstore App, Star rating 4.1</ex></ph>, <ph name="PRICE">$2<ex>Free</ex></ph>
</message> </message>
<message name="IDS_APP_ACCESSIBILITY_ARC_APP_ANNOUNCEMENT" desc="Accessibility text to specify a search result is a play store app."> <message name="IDS_APP_ACCESSIBILITY_ARC_APP_ANNOUNCEMENT" desc="Accessibility text to specify a search result is a play store app.">
Play Store App <ph name="APP_NAME">$1<ex>Snapchat</ex></ph>, Play Store App
</message> </message>
<message name="IDS_APP_ACCESSIBILITY_INSTALLED_APP_ANNOUNCEMENT" desc="Accessibility text to specify a search result is an installed app."> <message name="IDS_APP_ACCESSIBILITY_INSTALLED_APP_ANNOUNCEMENT" desc="Accessibility text to specify a search result is an installed app.">
Installed App <ph name="APP_NAME">$1<ex>Files</ex></ph>, Installed App
</message> </message>
<message name="IDS_APP_ACCESSIBILITY_INTERNAL_APP_ANNOUNCEMENT" desc="Accessibility text to specify a search result is an internal app."> <message name="IDS_APP_ACCESSIBILITY_INTERNAL_APP_ANNOUNCEMENT" desc="Accessibility text to specify a search result is an internal app.">
App <ph name="APP_NAME">$1<ex>Camera</ex></ph>, App
</message> </message>
<message name="IDS_APP_ACCESSIBILITY_APP_RECOMMENDATION_ARC" desc="Accessibility text to specify a search result is an app recommendation."> <message name="IDS_APP_ACCESSIBILITY_APP_RECOMMENDATION_ARC" desc="Accessibility text to specify a search result is an app recommendation.">
App recommendation <ph name="APP_NAME">$1<ex>Instagram</ex></ph>, App recommendation
</message> </message>
<!-- Strings describing the touch calibration UX --> <!-- Strings describing the touch calibration UX -->
<message name="IDS_DISPLAY_TOUCH_CALIBRATION_EXIT_LABEL" desc="A message to notify the user about using the escape key to exit the calibration mode."> <message name="IDS_DISPLAY_TOUCH_CALIBRATION_EXIT_LABEL" desc="A message to notify the user about using the escape key to exit the calibration mode.">
......
8f60af1d88ddf17cb979ea6f6ed0632424c5190d
\ No newline at end of file
1b2cead5eeae46aa5d9e857f82184f50a0ef472c
\ No newline at end of file
b0324e916b6be340806c566ed7cd2cdd563c04ee
\ No newline at end of file
2e913c0554fca034c7d0df7c798086caac2adcd1
\ No newline at end of file
93af8a3f78b7c0158ee205542826f0bec72f0d18
\ No newline at end of file
ea0ecb9e9c0aa0ef7df32df377d86de5dd472386
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment