Commit d8fada70 authored by Jing Wang's avatar Jing Wang Committed by Commit Bot

Correct ChromeVox messages in personal info suggester.

This is requested by UX in https://docs.google.com/document/d/1bZASllOcjDJdufpJdedUuM0cTQlIaoVO7K8AhXtWBrs/edit#

Besides the announcement text change, now we will always announce the
instruction about how to browse, accept and dismiss no matter if the
annotation icon is displayed. So removed one inapplicable test.

Test: Tested on DUT
Bug: 1116298
Change-Id: I9fe24ea6ff50de5af4c24d4512dcf337f616b391
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355530
Commit-Queue: Jing Wang <jiwan@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798536}
parent 86d59963
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "third_party/re2/src/re2/re2.h" #include "third_party/re2/src/re2/re2.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos { namespace chromeos {
...@@ -46,8 +45,22 @@ const char kPhoneNumberRegex[] = ...@@ -46,8 +45,22 @@ const char kPhoneNumberRegex[] =
const char kFirstNameRegex[] = "first name"; const char kFirstNameRegex[] = "first name";
const char kLastNameRegex[] = "last name"; const char kLastNameRegex[] = "last name";
const char kAnnounceAnnotation[] = const char kShowPersonalInfoSuggestionMessage[] =
"Press down to navigate and enter to insert."; "Personal info suggested. Press down arrow to access; escape to ignore.";
const char kDismissPersonalInfoSuggestionMessage[] = "Suggestion dismissed.";
const char kAcceptPersonalInfoSuggestionMessage[] = "Suggestion inserted.";
// The current personal information would only provide one suggestion, so there
// could be only two possible UI: 1. only one suggestion, 2. one suggestion and
// one learn more button, and the suggestion is always before the learn more
// button. So suggestion could be 1 of 1 or 1 of 2 depending on whether the
// learn more button is displayed, but learn more button can only be 2 of 2.
const char kSuggestionMessageTemplate[] =
"Suggestion %s. Button. Menu item 1 of %d. Press enter to insert; escape "
"to dismiss.";
const char kLearnMoreMessage[] =
"Learn more about suggestions. Link. Menu item 2 of 2. Press enter to "
"activate; escape to dismiss.";
const int kNoneHighlighted = -1; const int kNoneHighlighted = -1;
constexpr base::TimeDelta kTtsShowDelay = constexpr base::TimeDelta kTtsShowDelay =
...@@ -172,7 +185,7 @@ PersonalInfoSuggester::PersonalInfoSuggester( ...@@ -172,7 +185,7 @@ PersonalInfoSuggester::PersonalInfoSuggester(
ui::ime::AssistiveWindowType::kPersonalInfoSuggestion; ui::ime::AssistiveWindowType::kPersonalInfoSuggestion;
suggestion_button_.index = 0; suggestion_button_.index = 0;
settings_button_.id = ui::ime::ButtonId::kSmartInputsSettingLink; settings_button_.id = ui::ime::ButtonId::kSmartInputsSettingLink;
settings_button_.announce_string = l10n_util::GetStringUTF8(IDS_LEARN_MORE); settings_button_.announce_string = kLearnMoreMessage;
settings_button_.window_type = settings_button_.window_type =
ui::ime::AssistiveWindowType::kPersonalInfoSuggestion; ui::ime::AssistiveWindowType::kPersonalInfoSuggestion;
} }
...@@ -335,7 +348,9 @@ void PersonalInfoSuggester::ShowSuggestion(const base::string16& text, ...@@ -335,7 +348,9 @@ void PersonalInfoSuggester::ShowSuggestion(const base::string16& text,
LOG(ERROR) << "Fail to show suggestion. " << error; LOG(ERROR) << "Fail to show suggestion. " << error;
} }
suggestion_button_.announce_string = base::UTF16ToUTF8(text); suggestion_button_.announce_string = base::StringPrintf(
kSuggestionMessageTemplate, base::UTF16ToUTF8(text).c_str(),
details.show_setting_link ? 2 : 1);
buttons_.clear(); buttons_.clear();
buttons_.push_back(suggestion_button_); buttons_.push_back(suggestion_button_);
if (details.show_setting_link) if (details.show_setting_link)
...@@ -349,11 +364,9 @@ void PersonalInfoSuggester::ShowSuggestion(const base::string16& text, ...@@ -349,11 +364,9 @@ void PersonalInfoSuggester::ShowSuggestion(const base::string16& text,
IncrementPrefValueTilCapped(kPersonalInfoSuggesterShowSettingCount, IncrementPrefValueTilCapped(kPersonalInfoSuggesterShowSettingCount,
kMaxShowSettingCount); kMaxShowSettingCount);
tts_handler_->Announce( tts_handler_->Announce(
// TODO(jiwan): Add translation to other languages when we support more // TODO(jiwan): Add translation to other languages when we support
// than English. // more than English.
base::StringPrintf("Suggestion %s. %s", base::UTF16ToUTF8(text).c_str(), kShowPersonalInfoSuggestionMessage, kTtsShowDelay);
show_annotation ? kAnnounceAnnotation : ""),
kTtsShowDelay);
} }
suggestion_shown_ = true; suggestion_shown_ = true;
...@@ -398,8 +411,7 @@ bool PersonalInfoSuggester::AcceptSuggestion(size_t index) { ...@@ -398,8 +411,7 @@ bool PersonalInfoSuggester::AcceptSuggestion(size_t index) {
IncrementPrefValueTilCapped(kPersonalInfoSuggesterAcceptanceCount, IncrementPrefValueTilCapped(kPersonalInfoSuggesterAcceptanceCount,
kMaxAcceptanceCount); kMaxAcceptanceCount);
suggestion_shown_ = false; suggestion_shown_ = false;
tts_handler_->Announce(base::StringPrintf( tts_handler_->Announce(kAcceptPersonalInfoSuggestionMessage);
"Inserted suggestion %s.", base::UTF16ToUTF8(suggestion_).c_str()));
return true; return true;
} }
...@@ -413,6 +425,7 @@ void PersonalInfoSuggester::DismissSuggestion() { ...@@ -413,6 +425,7 @@ void PersonalInfoSuggester::DismissSuggestion() {
} }
suggestion_shown_ = false; suggestion_shown_ = false;
RecordTimeToDismiss(base::TimeTicks::Now() - session_start_); RecordTimeToDismiss(base::TimeTicks::Now() - session_start_);
tts_handler_->Announce(kDismissPersonalInfoSuggestionMessage);
} }
void PersonalInfoSuggester::SetButtonHighlighted( void PersonalInfoSuggester::SetButtonHighlighted(
......
...@@ -464,15 +464,21 @@ TEST_F(PersonalInfoSuggesterTest, AnnounceSpokenFeedbackWhenChromeVoxIsOn) { ...@@ -464,15 +464,21 @@ TEST_F(PersonalInfoSuggesterTest, AnnounceSpokenFeedbackWhenChromeVoxIsOn) {
tts_handler_->VerifyAnnouncement(""); tts_handler_->VerifyAnnouncement("");
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(1000)); task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(1000));
tts_handler_->VerifyAnnouncement(base::StringPrintf( tts_handler_->VerifyAnnouncement(
"Suggestion %s. Press down to navigate and enter to insert.", "Personal info suggested. Press down arrow to access; escape to ignore.");
base::UTF16ToUTF8(email_).c_str()));
SendKeyboardEvent("Down"); SendKeyboardEvent("Down");
SendKeyboardEvent("Enter"); SendKeyboardEvent("Enter");
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(200)); task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(200));
tts_handler_->VerifyAnnouncement(base::StringPrintf( tts_handler_->VerifyAnnouncement("Suggestion inserted.");
"Inserted suggestion %s.", base::UTF16ToUTF8(email_).c_str()));
suggester_->Suggest(base::UTF8ToUTF16("my email is "));
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(1500));
tts_handler_->VerifyAnnouncement(
"Personal info suggested. Press down arrow to access; escape to ignore.");
SendKeyboardEvent("Esc");
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(200));
tts_handler_->VerifyAnnouncement("Suggestion dismissed.");
} }
TEST_F(PersonalInfoSuggesterTest, DoNotShowAnnotationAfterMaxAcceptanceCount) { TEST_F(PersonalInfoSuggesterTest, DoNotShowAnnotationAfterMaxAcceptanceCount) {
...@@ -486,24 +492,6 @@ TEST_F(PersonalInfoSuggesterTest, DoNotShowAnnotationAfterMaxAcceptanceCount) { ...@@ -486,24 +492,6 @@ TEST_F(PersonalInfoSuggesterTest, DoNotShowAnnotationAfterMaxAcceptanceCount) {
suggestion_handler_->VerifyShowAnnotation(false); suggestion_handler_->VerifyShowAnnotation(false);
} }
TEST_F(PersonalInfoSuggesterTest, DoNotAnnounceAnnotationWhenTabNotShown) {
profile_->set_profile_name(base::UTF16ToUTF8(email_));
profile_->GetPrefs()->SetBoolean(
ash::prefs::kAccessibilitySpokenFeedbackEnabled, true);
DictionaryPrefUpdate update(profile_->GetPrefs(),
prefs::kAssistiveInputFeatureSettings);
update->SetIntKey(kPersonalInfoSuggesterAcceptanceCount, kMaxAcceptanceCount);
suggester_->Suggest(base::UTF8ToUTF16("my email is "));
suggestion_handler_->VerifyShowAnnotation(false);
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(500));
tts_handler_->VerifyAnnouncement("");
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(1000));
tts_handler_->VerifyAnnouncement(
base::StringPrintf("Suggestion %s. ", base::UTF16ToUTF8(email_).c_str()));
}
TEST_F(PersonalInfoSuggesterTest, ShowSettingLink) { TEST_F(PersonalInfoSuggesterTest, ShowSettingLink) {
DictionaryPrefUpdate update(profile_->GetPrefs(), DictionaryPrefUpdate update(profile_->GetPrefs(),
prefs::kAssistiveInputFeatureSettings); prefs::kAssistiveInputFeatureSettings);
......
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