| Index: chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
|
| ===================================================================
|
| --- chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc (revision 81359)
|
| +++ chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc (working copy)
|
| @@ -1004,56 +1004,29 @@
|
| ASSERT_TRUE(edit_view->IsSelectAll());
|
| }
|
|
|
| - void TabMoveCursorToEndTest() {
|
| + void TabAcceptKeyword() {
|
| AutocompleteEditView* edit_view = NULL;
|
| ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
|
|
|
| - edit_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(edit_view->model()->is_keyword_hint());
|
| + ASSERT_EQ(text, edit_view->model()->keyword());
|
| + ASSERT_EQ(text, edit_view->GetText());
|
|
|
| - string16::size_type start, end;
|
| - edit_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(edit_view->model()->is_keyword_hint());
|
| + ASSERT_EQ(text, edit_view->model()->keyword());
|
| + ASSERT_TRUE(edit_view->GetText().empty());
|
|
|
| - edit_view->GetSelectionBounds(&start, &end);
|
| - EXPECT_EQ(edit_view->GetText().size(), start);
|
| - EXPECT_EQ(edit_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.
|
| - edit_view->SelectAll(true);
|
| - EXPECT_TRUE(edit_view->IsSelectAll());
|
| - edit_view->GetSelectionBounds(&start, &end);
|
| - EXPECT_EQ(0U, start);
|
| - EXPECT_EQ(edit_view->GetText().size(), end);
|
| -
|
| - // Pressing tab should move cursor to the end.
|
| - ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
|
| -
|
| - edit_view->GetSelectionBounds(&start, &end);
|
| - EXPECT_EQ(edit_view->GetText().size(), start);
|
| - EXPECT_EQ(edit_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.
|
| + edit_view->model()->ClearKeyword(string16());
|
| + ASSERT_TRUE(edit_view->model()->is_keyword_hint());
|
| + ASSERT_EQ(text, edit_view->model()->keyword());
|
| + ASSERT_EQ(text, edit_view->GetText());
|
| }
|
|
|
| void PersistKeywordModeOnTabSwitch() {
|
| @@ -1105,7 +1078,6 @@
|
| // Inline autocomplete should still be there.
|
| EXPECT_EQ(old_text, edit_view->GetText());
|
| }
|
| -
|
| };
|
|
|
| // Test if ctrl-* accelerators are workable in omnibox.
|
| @@ -1167,8 +1139,8 @@
|
| DeleteItemTest();
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, TabMoveCursorToEnd) {
|
| - TabMoveCursorToEndTest();
|
| +IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, TabAcceptKeyword) {
|
| + TabAcceptKeyword();
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest,
|
| @@ -1372,7 +1344,7 @@
|
| // enabling AutocompleteEditViewViews.
|
| IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
|
| DISABLED_TabMoveCursorToEnd) {
|
| - TabMoveCursorToEndTest();
|
| + TabAcceptKeyword();
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
|
|
|