Chromium Code Reviews| Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| index 4ffb3341d2068cd6bb2412f7fd91b5e3791deae5..1d8cf4820b0cdd413265c684ecc1d30b8d62c22b 100644 |
| --- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| +++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| @@ -56,16 +56,26 @@ namespace { |
| const char kSearchKeyword[] = "foo"; |
| const char kSearchKeyword2[] = "footest.com"; |
| -const wchar_t kSearchKeywordKeys[] = { ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, 0 }; |
| +const ui::KeyboardCode kSearchKeywordKeys[] = { |
| + ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, ui::VKEY_UNKNOWN |
| +}; |
| +const ui::KeyboardCode kSearchKeywordPrefixKeys[] = { |
| + ui::VKEY_F, ui::VKEY_O, ui::VKEY_UNKNOWN |
| +}; |
| +const ui::KeyboardCode kSearchKeywordCompletionKeys[] = { |
| + ui::VKEY_O, ui::VKEY_UNKNOWN |
| +}; |
| const char kSearchURL[] = "http://www.foo.com/search?q={searchTerms}"; |
| const char kSearchShortName[] = "foo"; |
| const char kSearchText[] = "abc"; |
| -const wchar_t kSearchTextKeys[] = { ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, 0 }; |
| +const ui::KeyboardCode kSearchTextKeys[] = { |
| + ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, ui::VKEY_UNKNOWN |
| +}; |
| const char kSearchTextURL[] = "http://www.foo.com/search?q=abc"; |
| const char kInlineAutocompleteText[] = "def"; |
| -const wchar_t kInlineAutocompleteTextKeys[] = { |
| - ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0 |
| +const ui::KeyboardCode kInlineAutocompleteTextKeys[] = { |
| + ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, ui::VKEY_UNKNOWN |
| }; |
| // Hostnames that shall be blocked by host resolver. |
| @@ -167,9 +177,9 @@ class OmniboxViewTest : public InProcessBrowserTest, |
| SendKeyForBrowser(browser(), key, modifiers); |
| } |
| - void SendKeySequence(const wchar_t* keys) { |
| + void SendKeySequence(const ui::KeyboardCode* keys) { |
| for (; *keys; ++keys) |
|
Peter Kasting
2014/08/05 23:13:36
Tiny nit: For maximum clarity, we should probably
Mark P
2014/08/05 23:19:38
I can't use 0 because it's the wrong type. (I'd n
|
| - ASSERT_NO_FATAL_FAILURE(SendKey(static_cast<ui::KeyboardCode>(*keys), 0)); |
| + ASSERT_NO_FATAL_FAILURE(SendKey(*keys, 0)); |
| } |
| bool SendKeyAndWait(const Browser* browser, |
| @@ -563,7 +573,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DesiredTLD) { |
| ASSERT_TRUE(popup_model); |
| // Test ctrl-Enter. |
| - const wchar_t kKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 }; |
| + const ui::KeyboardCode kKeys[] = { |
| + ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, ui::VKEY_UNKNOWN |
| + }; |
| ASSERT_NO_FATAL_FAILURE(SendKeySequence(kKeys)); |
| ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| ASSERT_TRUE(popup_model->IsOpen()); |
| @@ -600,7 +612,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DesiredTLDWithTemporaryText) { |
| template_url_service->Add(new TemplateURL(data)); |
| // Send "ab", so that an "abc" entry appears in the popup. |
| - const wchar_t kSearchTextPrefixKeys[] = { ui::VKEY_A, ui::VKEY_B, 0 }; |
| + const ui::KeyboardCode kSearchTextPrefixKeys[] = { |
| + ui::VKEY_A, ui::VKEY_B, ui::VKEY_UNKNOWN |
| + }; |
| ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextPrefixKeys)); |
| ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| ASSERT_TRUE(popup_model->IsOpen()); |
| @@ -665,7 +679,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_EnterToSearch) { |
| EXPECT_EQ(kSearchTextURL, url.spec()); |
| // Test that entering a single character then Enter performs a search. |
| - const wchar_t kSearchSingleCharKeys[] = { ui::VKEY_Z, 0 }; |
| + const ui::KeyboardCode kSearchSingleCharKeys[] = { |
| + ui::VKEY_Z, ui::VKEY_UNKNOWN |
| + }; |
| chrome::FocusLocationBar(browser()); |
| EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys)); |
| @@ -929,8 +945,8 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_AcceptKeywordBySpace) { |
| ASSERT_NO_FATAL_FAILURE( |
| AddHistoryEntry(kHistoryFoobar, Time::Now() - TimeDelta::FromHours(1))); |
| - // Type "foo" to trigger inline autocomplete. |
| - ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| + // Type "fo" to trigger inline autocomplete. |
| + ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordPrefixKeys)); |
| ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
| ASSERT_NE(search_keyword, omnibox_view->GetText()); |
| @@ -939,6 +955,15 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_AcceptKeywordBySpace) { |
| ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
| + // Add the "o". Inline autocompletion should still happen, but now we |
| + // should also get a keyword hint because we've typed a keyword exactly. |
| + ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordCompletionKeys)); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
| + ASSERT_NE(search_keyword, omnibox_view->GetText()); |
| + ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| + ASSERT_FALSE(omnibox_view->model()->keyword().empty()); |
| + |
| // Trigger keyword mode by space. |
| ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| @@ -1229,7 +1254,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_TabTraverseResultsTest) { |
| ASSERT_TRUE(popup_model); |
| // Input something to trigger results. |
| - const wchar_t kKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 }; |
| + const ui::KeyboardCode kKeys[] = { |
| + ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, ui::VKEY_UNKNOWN |
| + }; |
| ASSERT_NO_FATAL_FAILURE(SendKeySequence(kKeys)); |
| ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| ASSERT_TRUE(popup_model->IsOpen()); |
| @@ -1700,7 +1727,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CtrlArrowAfterArrowSuggestions) { |
| ASSERT_TRUE(popup_model); |
| // Input something to trigger results. |
| - const wchar_t kKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 }; |
| + const ui::KeyboardCode kKeys[] = { |
| + ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, ui::VKEY_UNKNOWN |
| + }; |
| ASSERT_NO_FATAL_FAILURE(SendKeySequence(kKeys)); |
| ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| ASSERT_TRUE(popup_model->IsOpen()); |