Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 440753003: Omnibox: Make Exact Match Tab-to-Search Work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: loop termination condition Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_provider_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..433bba3043667f6b75c3f96decc0a21334f90134 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) {
- for (; *keys; ++keys)
- ASSERT_NO_FATAL_FAILURE(SendKey(static_cast<ui::KeyboardCode>(*keys), 0));
+ void SendKeySequence(const ui::KeyboardCode* keys) {
+ for (; *keys != ui::VKEY_UNKNOWN; ++keys)
+ 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());
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_provider_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698