Commit 73aa29be authored by My Nguyen's avatar My Nguyen Committed by Commit Bot

Check if virtual keyboard is visible for suggestions

Virtual keyboard can be enabled and not visible. When it's not visible,
suggestions should still be shown normally.

Bug: b/162293447
Change-Id: I3a9ef621abe4ab70031ea7ef0c1154ac61a7e11a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355152Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: My Nguyen <myy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797955}
parent 1043cf8e
...@@ -223,7 +223,7 @@ bool EmojiSuggester::Suggest(const base::string16& text) { ...@@ -223,7 +223,7 @@ bool EmojiSuggester::Suggest(const base::string16& text) {
} }
void EmojiSuggester::ShowSuggestion(const std::string& text) { void EmojiSuggester::ShowSuggestion(const std::string& text) {
if (ChromeKeyboardControllerClient::Get()->is_keyboard_enabled()) if (ChromeKeyboardControllerClient::Get()->is_keyboard_visible())
return; return;
highlighted_index_ = kNoneHighlighted; highlighted_index_ = kNoneHighlighted;
......
...@@ -118,7 +118,7 @@ class EmojiSuggesterTest : public testing::Test { ...@@ -118,7 +118,7 @@ class EmojiSuggesterTest : public testing::Test {
emoji_suggester_->LoadEmojiMapForTesting(kEmojiData); emoji_suggester_->LoadEmojiMapForTesting(kEmojiData);
chrome_keyboard_controller_client_ = chrome_keyboard_controller_client_ =
ChromeKeyboardControllerClient::CreateForTest(); ChromeKeyboardControllerClient::CreateForTest();
chrome_keyboard_controller_client_->set_keyboard_enabled_for_test(false); chrome_keyboard_controller_client_->set_keyboard_visible_for_test(false);
} }
SuggestionStatus Press(std::string event_key) { SuggestionStatus Press(std::string event_key) {
...@@ -156,7 +156,7 @@ TEST_F(EmojiSuggesterTest, DoNotSuggestWhenWordNotInMap) { ...@@ -156,7 +156,7 @@ TEST_F(EmojiSuggesterTest, DoNotSuggestWhenWordNotInMap) {
} }
TEST_F(EmojiSuggesterTest, DoNotShowSuggestionWhenVirtualKeyboardEnabled) { TEST_F(EmojiSuggesterTest, DoNotShowSuggestionWhenVirtualKeyboardEnabled) {
chrome_keyboard_controller_client_->set_keyboard_enabled_for_test(true); chrome_keyboard_controller_client_->set_keyboard_visible_for_test(true);
EXPECT_TRUE(emoji_suggester_->Suggest(base::UTF8ToUTF16("happy "))); EXPECT_TRUE(emoji_suggester_->Suggest(base::UTF8ToUTF16("happy ")));
EXPECT_FALSE(emoji_suggester_->GetSuggestionShownForTesting()); EXPECT_FALSE(emoji_suggester_->GetSuggestionShownForTesting());
} }
......
...@@ -308,7 +308,7 @@ base::string16 PersonalInfoSuggester::GetSuggestion( ...@@ -308,7 +308,7 @@ base::string16 PersonalInfoSuggester::GetSuggestion(
void PersonalInfoSuggester::ShowSuggestion(const base::string16& text, void PersonalInfoSuggester::ShowSuggestion(const base::string16& text,
const size_t confirmed_length) { const size_t confirmed_length) {
if (ChromeKeyboardControllerClient::Get()->is_keyboard_enabled()) { if (ChromeKeyboardControllerClient::Get()->is_keyboard_visible()) {
const std::vector<std::string> args{base::UTF16ToUTF8(text)}; const std::vector<std::string> args{base::UTF16ToUTF8(text)};
suggestion_handler_->OnSuggestionsChanged(args); suggestion_handler_->OnSuggestionsChanged(args);
return; return;
......
...@@ -159,7 +159,7 @@ class PersonalInfoSuggesterTest : public testing::Test { ...@@ -159,7 +159,7 @@ class PersonalInfoSuggesterTest : public testing::Test {
chrome_keyboard_controller_client_ = chrome_keyboard_controller_client_ =
ChromeKeyboardControllerClient::CreateForTest(); ChromeKeyboardControllerClient::CreateForTest();
chrome_keyboard_controller_client_->set_keyboard_enabled_for_test(false); chrome_keyboard_controller_client_->set_keyboard_visible_for_test(false);
} }
void SendKeyboardEvent(std::string key) { void SendKeyboardEvent(std::string key) {
...@@ -216,7 +216,7 @@ TEST_F(PersonalInfoSuggesterTest, DoNotSuggestEmail) { ...@@ -216,7 +216,7 @@ TEST_F(PersonalInfoSuggesterTest, DoNotSuggestEmail) {
} }
TEST_F(PersonalInfoSuggesterTest, DoNotSuggestWhenVirtualKeyboardEnabled) { TEST_F(PersonalInfoSuggesterTest, DoNotSuggestWhenVirtualKeyboardEnabled) {
chrome_keyboard_controller_client_->set_keyboard_enabled_for_test(true); chrome_keyboard_controller_client_->set_keyboard_visible_for_test(true);
profile_->set_profile_name(base::UTF16ToUTF8(email_)); profile_->set_profile_name(base::UTF16ToUTF8(email_));
suggester_->Suggest(base::UTF8ToUTF16("my email is ")); suggester_->Suggest(base::UTF8ToUTF16("my email is "));
...@@ -225,7 +225,7 @@ TEST_F(PersonalInfoSuggesterTest, DoNotSuggestWhenVirtualKeyboardEnabled) { ...@@ -225,7 +225,7 @@ TEST_F(PersonalInfoSuggesterTest, DoNotSuggestWhenVirtualKeyboardEnabled) {
TEST_F(PersonalInfoSuggesterTest, TEST_F(PersonalInfoSuggesterTest,
SendsEmailSuggestionToExtensionWhenVirtualKeyboardEnabled) { SendsEmailSuggestionToExtensionWhenVirtualKeyboardEnabled) {
chrome_keyboard_controller_client_->set_keyboard_enabled_for_test(true); chrome_keyboard_controller_client_->set_keyboard_visible_for_test(true);
profile_->set_profile_name(base::UTF16ToUTF8(email_)); profile_->set_profile_name(base::UTF16ToUTF8(email_));
suggester_->Suggest(base::UTF8ToUTF16("my email is ")); suggester_->Suggest(base::UTF8ToUTF16("my email is "));
......
...@@ -137,6 +137,9 @@ class ChromeKeyboardControllerClient ...@@ -137,6 +137,9 @@ class ChromeKeyboardControllerClient
void set_keyboard_enabled_for_test(bool enabled) { void set_keyboard_enabled_for_test(bool enabled) {
is_keyboard_enabled_ = enabled; is_keyboard_enabled_ = enabled;
} }
void set_keyboard_visible_for_test(bool visible) {
is_keyboard_visible_ = visible;
}
void set_profile_for_test(Profile* profile) { profile_for_test_ = profile; } void set_profile_for_test(Profile* profile) { profile_for_test_ = profile; }
void set_virtual_keyboard_url_for_test(const GURL& url) { void set_virtual_keyboard_url_for_test(const GURL& url) {
virtual_keyboard_url_for_test_ = url; virtual_keyboard_url_for_test_ = url;
......
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