| Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
|
| ===================================================================
|
| --- chrome/browser/ui/omnibox/omnibox_view_browsertest.cc (revision 95169)
|
| +++ chrome/browser/ui/omnibox/omnibox_view_browsertest.cc (working copy)
|
| @@ -1014,56 +1014,29 @@
|
| 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 = UTF8ToUTF16(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);
|
| -
|
| - // The location bar should still have focus.
|
| - ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
|
| -
|
| - // 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.
|
| - ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
|
| -
|
| - omnibox_view->GetSelectionBounds(&start, &end);
|
| - EXPECT_EQ(omnibox_view->GetText().size(), start);
|
| - EXPECT_EQ(omnibox_view->GetText().size(), end);
|
| -
|
| - // The location bar should still have focus.
|
| - ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
|
| -
|
| - // 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(), VIEW_ID_LOCATION_BAR));
|
| + // 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());
|
| }
|
|
|
| void PersistKeywordModeOnTabSwitch() {
|
| @@ -1187,8 +1160,8 @@
|
| DeleteItemTest();
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabMoveCursorToEnd) {
|
| - TabMoveCursorToEndTest();
|
| +IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabAcceptKeyword) {
|
| + TabAcceptKeyword();
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(OmniboxViewTest,
|
|
|