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

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

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 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
Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
===================================================================
--- chrome/browser/ui/omnibox/omnibox_view_browsertest.cc (revision 117356)
+++ chrome/browser/ui/omnibox/omnibox_view_browsertest.cc (working copy)
@@ -791,7 +791,8 @@
ASSERT_EQ(text, omnibox_view->model()->keyword());
ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText());
- // Keyword shouldn't be accepted by pasting "foo bar".
+ // Keyword shouldn't be accepted by pasting "foo bar," but the Omnibox
+ // should still show a keyword hint.
omnibox_view->SetUserText(string16());
ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
ASSERT_TRUE(omnibox_view->model()->keyword().empty());
@@ -801,16 +802,16 @@
omnibox_view->SetWindowTextAndCaretPos(text + ASCIIToUTF16(" bar"),
text.length() + 4);
omnibox_view->OnAfterPossibleChange();
- ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
- ASSERT_TRUE(omnibox_view->model()->keyword().empty());
+ ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
ASSERT_EQ(text + ASCIIToUTF16(" bar"), omnibox_view->GetText());
// Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar".
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0));
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0));
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0));
- ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
- ASSERT_TRUE(omnibox_view->model()->keyword().empty());
+ ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
ASSERT_EQ(text + ASCIIToUTF16(" b ar"), omnibox_view->GetText());
// Keyword could be accepted by pressing space with a selected range at the
@@ -1013,59 +1014,48 @@
ASSERT_TRUE(omnibox_view->IsSelectAll());
}
- void TabMoveCursorToEndTest() {
+ void TabAcceptKeyword() {
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
- omnibox_view->SetUserText(ASCIIToUTF16("Hello world"));
+ string16 text = ASCIIToUTF16(kSearchKeyword);
- // Move cursor to the beginning.
-#if defined(OS_MACOSX)
- // Home doesn't work on Mac trybot.
- ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN));
-#else
- ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, 0));
-#endif
+ // Trigger keyword hint mode.
+ ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
+ ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
+ ASSERT_EQ(text, omnibox_view->GetText());
- size_t start, end;
- omnibox_view->GetSelectionBounds(&start, &end);
- EXPECT_EQ(0U, start);
- EXPECT_EQ(0U, end);
-
- // Pressing tab should move cursor to the end.
+ // Trigger keyword mode by tab.
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
+ ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
+ ASSERT_TRUE(omnibox_view->GetText().empty());
- omnibox_view->GetSelectionBounds(&start, &end);
- EXPECT_EQ(omnibox_view->GetText().size(), start);
- EXPECT_EQ(omnibox_view->GetText().size(), end);
+ // Revert to keyword hint mode.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
+ ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
+ ASSERT_EQ(text, omnibox_view->GetText());
// The location bar should still have focus.
ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
- // Select all text.
- omnibox_view->SelectAll(true);
- EXPECT_TRUE(omnibox_view->IsSelectAll());
- omnibox_view->GetSelectionBounds(&start, &end);
- EXPECT_EQ(0U, start);
- EXPECT_EQ(omnibox_view->GetText().size(), end);
-
- // Pressing tab should move cursor to the end.
+ // Trigger keyword mode by tab.
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
+ ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
+ ASSERT_TRUE(omnibox_view->GetText().empty());
- omnibox_view->GetSelectionBounds(&start, &end);
- EXPECT_EQ(omnibox_view->GetText().size(), start);
- EXPECT_EQ(omnibox_view->GetText().size(), end);
+ // Revert to keyword hint mode with SHIFT+TAB.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN));
+ ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_EQ(text, omnibox_view->model()->keyword());
+ ASSERT_EQ(text, omnibox_view->GetText());
- // The location bar should still have focus.
ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
-
- // Pressing tab when cursor is at the end should change focus.
- ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
-
- ASSERT_FALSE(ui_test_utils::IsViewFocused(browser(),
- location_bar_focus_view_id_));
}
void PersistKeywordModeOnTabSwitch() {
@@ -1191,8 +1181,8 @@
DeleteItemTest();
}
-IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabMoveCursorToEnd) {
- TabMoveCursorToEndTest();
+IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabAcceptKeyword) {
+ TabAcceptKeyword();
}
IN_PROC_BROWSER_TEST_F(OmniboxViewTest,

Powered by Google App Engine
This is Rietveld 408576698