Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 32 #include "chrome/test/base/in_process_browser_test.h" | 32 #include "chrome/test/base/in_process_browser_test.h" |
| 33 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
| 34 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 36 #include "net/base/mock_host_resolver.h" | 36 #include "net/base/mock_host_resolver.h" |
| 37 #include "ui/base/events.h" | 37 #include "ui/base/events.h" |
| 38 #include "ui/base/keycodes/keyboard_codes.h" | 38 #include "ui/base/keycodes/keyboard_codes.h" |
| 39 | 39 |
| 40 #if defined(TOOLKIT_GTK) | |
| 41 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | |
| 42 #endif | |
| 43 | |
| 40 #if defined(TOOLKIT_USES_GTK) | 44 #if defined(TOOLKIT_USES_GTK) |
| 41 #include <gdk/gdk.h> | 45 #include <gdk/gdk.h> |
| 42 #include <gtk/gtk.h> | 46 #include <gtk/gtk.h> |
| 43 #endif | 47 #endif |
| 44 | 48 |
| 45 #if defined(TOOLKIT_VIEWS) | 49 #if defined(TOOLKIT_VIEWS) |
| 46 #include "ui/views/controls/textfield/native_textfield_views.h" | 50 #include "ui/views/controls/textfield/native_textfield_views.h" |
| 47 #include "ui/views/events/event.h" | 51 #include "ui/views/events/event.h" |
| 48 #include "ui/views/widget/widget.h" | 52 #include "ui/views/widget/widget.h" |
| 49 #endif | 53 #endif |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 public content::NotificationObserver { | 154 public content::NotificationObserver { |
| 151 protected: | 155 protected: |
| 152 OmniboxViewTest() | 156 OmniboxViewTest() |
| 153 : location_bar_focus_view_id_(VIEW_ID_LOCATION_BAR) { | 157 : location_bar_focus_view_id_(VIEW_ID_LOCATION_BAR) { |
| 154 set_show_window(true); | 158 set_show_window(true); |
| 155 // TODO(mrossetti): HQP does not yet support DeleteMatch. | 159 // TODO(mrossetti): HQP does not yet support DeleteMatch. |
| 156 // http://crbug.com/82335 | 160 // http://crbug.com/82335 |
| 157 HistoryQuickProvider::set_disabled(true); | 161 HistoryQuickProvider::set_disabled(true); |
| 158 } | 162 } |
| 159 | 163 |
| 164 #if defined(TOOLKIT_GTK) | |
| 165 virtual void OnBeforeShowBrowser(Browser* browser) { | |
|
Mike Mammarella
2012/02/04 01:47:57
FYI, this part should no longer be necessary.
| |
| 166 // Disable the timer because it causes the browser to move, which results | |
| 167 // in the popup closing before results are verified. | |
| 168 static_cast<BrowserWindowGtk*>( | |
| 169 browser->window())->DisableDebounceTimerForTests(true); | |
| 170 } | |
| 171 #endif | |
| 172 | |
| 160 virtual void SetUpOnMainThread() { | 173 virtual void SetUpOnMainThread() { |
| 161 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 174 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 162 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | 175 ASSERT_NO_FATAL_FAILURE(SetupComponents()); |
| 163 browser()->FocusLocationBar(); | 176 browser()->FocusLocationBar(); |
| 164 // Use Textfield's view id on pure views. See crbug.com/71144. | 177 // Use Textfield's view id on pure views. See crbug.com/71144. |
| 165 #if defined(TOOLKIT_VIEWS) | 178 #if defined(TOOLKIT_VIEWS) |
| 166 if (views::Widget::IsPureViews()) | 179 if (views::Widget::IsPureViews()) |
| 167 location_bar_focus_view_id_ = VIEW_ID_OMNIBOX; | 180 location_bar_focus_view_id_ = VIEW_ID_OMNIBOX; |
| 168 #endif | 181 #endif |
| 169 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 182 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 | 753 |
| 741 // Revert to keyword hint mode. | 754 // Revert to keyword hint mode. |
| 742 omnibox_view->model()->ClearKeyword(string16()); | 755 omnibox_view->model()->ClearKeyword(string16()); |
| 743 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 756 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 744 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 757 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 745 ASSERT_EQ(text, omnibox_view->GetText()); | 758 ASSERT_EQ(text, omnibox_view->GetText()); |
| 746 | 759 |
| 747 // Keyword should also be accepted by typing an ideographic space. | 760 // Keyword should also be accepted by typing an ideographic space. |
| 748 omnibox_view->OnBeforePossibleChange(); | 761 omnibox_view->OnBeforePossibleChange(); |
| 749 omnibox_view->SetWindowTextAndCaretPos(text + WideToUTF16(L"\x3000"), | 762 omnibox_view->SetWindowTextAndCaretPos(text + WideToUTF16(L"\x3000"), |
| 750 text.length() + 1); | 763 text.length() + 1, false, false); |
| 751 omnibox_view->OnAfterPossibleChange(); | 764 omnibox_view->OnAfterPossibleChange(); |
| 752 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 765 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 753 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 766 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 754 ASSERT_TRUE(omnibox_view->GetText().empty()); | 767 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 755 | 768 |
| 756 // Revert to keyword hint mode. | 769 // Revert to keyword hint mode. |
| 757 omnibox_view->model()->ClearKeyword(string16()); | 770 omnibox_view->model()->ClearKeyword(string16()); |
| 758 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 771 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 759 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 772 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 760 ASSERT_EQ(text, omnibox_view->GetText()); | 773 ASSERT_EQ(text, omnibox_view->GetText()); |
| 761 | 774 |
| 762 // Keyword shouldn't be accepted by pressing space with a trailing | 775 // Keyword shouldn't be accepted by pressing space with a trailing |
| 763 // whitespace. | 776 // whitespace. |
| 764 omnibox_view->SetWindowTextAndCaretPos( | 777 omnibox_view->SetWindowTextAndCaretPos( |
| 765 text + char16(' '), text.length() + 1); | 778 text + char16(' '), text.length() + 1, false, false); |
| 766 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 779 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 767 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 780 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 768 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 781 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 769 ASSERT_EQ(text + ASCIIToUTF16(" "), omnibox_view->GetText()); | 782 ASSERT_EQ(text + ASCIIToUTF16(" "), omnibox_view->GetText()); |
| 770 | 783 |
| 771 // Keyword shouldn't be accepted by deleting the trailing space. | 784 // Keyword shouldn't be accepted by deleting the trailing space. |
| 772 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 785 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 773 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 786 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 774 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 787 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 775 ASSERT_EQ(text + char16(' '), omnibox_view->GetText()); | 788 ASSERT_EQ(text + char16(' '), omnibox_view->GetText()); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 792 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); | 805 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); |
| 793 | 806 |
| 794 // Keyword shouldn't be accepted by pasting "foo bar". | 807 // Keyword shouldn't be accepted by pasting "foo bar". |
| 795 omnibox_view->SetUserText(string16()); | 808 omnibox_view->SetUserText(string16()); |
| 796 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 809 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 797 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 810 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
| 798 | 811 |
| 799 omnibox_view->OnBeforePossibleChange(); | 812 omnibox_view->OnBeforePossibleChange(); |
| 800 omnibox_view->model()->on_paste(); | 813 omnibox_view->model()->on_paste(); |
| 801 omnibox_view->SetWindowTextAndCaretPos(text + ASCIIToUTF16(" bar"), | 814 omnibox_view->SetWindowTextAndCaretPos(text + ASCIIToUTF16(" bar"), |
| 802 text.length() + 4); | 815 text.length() + 4, false, false); |
| 803 omnibox_view->OnAfterPossibleChange(); | 816 omnibox_view->OnAfterPossibleChange(); |
| 804 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 817 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 805 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 818 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
| 806 ASSERT_EQ(text + ASCIIToUTF16(" bar"), omnibox_view->GetText()); | 819 ASSERT_EQ(text + ASCIIToUTF16(" bar"), omnibox_view->GetText()); |
| 807 | 820 |
| 808 // Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar". | 821 // Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar". |
| 809 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 822 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 810 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 823 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 811 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 824 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 812 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 825 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1019 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 1007 #endif | 1020 #endif |
| 1008 | 1021 |
| 1009 // As the current selected item is the new default item, pressing Escape key | 1022 // As the current selected item is the new default item, pressing Escape key |
| 1010 // should revert all directly. | 1023 // should revert all directly. |
| 1011 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); | 1024 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); |
| 1012 ASSERT_EQ(old_text, omnibox_view->GetText()); | 1025 ASSERT_EQ(old_text, omnibox_view->GetText()); |
| 1013 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 1026 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
| 1014 } | 1027 } |
| 1015 | 1028 |
| 1016 void TabMoveCursorToEndTest() { | 1029 void TabAcceptKeyword() { |
| 1017 OmniboxView* omnibox_view = NULL; | 1030 OmniboxView* omnibox_view = NULL; |
| 1018 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1031 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1019 | 1032 |
| 1020 omnibox_view->SetUserText(ASCIIToUTF16("Hello world")); | 1033 string16 text = ASCIIToUTF16(kSearchKeyword); |
| 1021 | 1034 |
| 1022 // Move cursor to the beginning. | 1035 // Trigger keyword hint mode. |
| 1023 #if defined(OS_MACOSX) | 1036 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 1024 // Home doesn't work on Mac trybot. | 1037 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 1025 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN)); | 1038 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 1026 #else | 1039 ASSERT_EQ(text, omnibox_view->GetText()); |
| 1027 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, 0)); | |
| 1028 #endif | |
| 1029 | 1040 |
| 1030 size_t start, end; | 1041 // Trigger keyword mode by tab. |
| 1031 omnibox_view->GetSelectionBounds(&start, &end); | 1042 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1032 EXPECT_EQ(0U, start); | 1043 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 1033 EXPECT_EQ(0U, end); | 1044 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 1045 ASSERT_TRUE(omnibox_view->GetText().empty()); | |
| 1034 | 1046 |
| 1035 // Pressing tab should move cursor to the end. | 1047 // Revert to keyword hint mode. |
| 1036 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1048 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 1037 | 1049 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 1038 omnibox_view->GetSelectionBounds(&start, &end); | 1050 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 1039 EXPECT_EQ(omnibox_view->GetText().size(), start); | 1051 ASSERT_EQ(text, omnibox_view->GetText()); |
| 1040 EXPECT_EQ(omnibox_view->GetText().size(), end); | |
| 1041 | 1052 |
| 1042 // The location bar should still have focus. | 1053 // The location bar should still have focus. |
| 1043 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1054 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1044 location_bar_focus_view_id_)); | 1055 location_bar_focus_view_id_)); |
| 1045 | 1056 |
| 1046 // Select all text. | 1057 // Trigger keyword mode by tab. |
| 1047 omnibox_view->SelectAll(true); | 1058 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1048 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 1059 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 1049 omnibox_view->GetSelectionBounds(&start, &end); | 1060 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
| 1050 EXPECT_EQ(0U, start); | 1061 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 1051 EXPECT_EQ(omnibox_view->GetText().size(), end); | |
| 1052 | 1062 |
| 1053 // Pressing tab should move cursor to the end. | 1063 // Revert to keyword hint mode with SHIFT+TAB. |
| 1064 #if defined(OS_MACOSX) | |
| 1065 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACKTAB, 0)); | |
| 1066 #else | |
| 1067 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); | |
| 1068 #endif | |
| 1069 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | |
| 1070 ASSERT_EQ(text, omnibox_view->model()->keyword()); | |
| 1071 ASSERT_EQ(text, omnibox_view->GetText()); | |
| 1072 | |
| 1073 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | |
| 1074 location_bar_focus_view_id_)); | |
| 1075 } | |
| 1076 | |
| 1077 void TabTraverseResultsTest() { | |
| 1078 OmniboxView* omnibox_view = NULL; | |
| 1079 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | |
| 1080 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model(); | |
| 1081 ASSERT_TRUE(popup_model); | |
| 1082 | |
| 1083 // Input something to trigger results. | |
| 1084 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); | |
| 1085 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | |
| 1086 ASSERT_TRUE(popup_model->IsOpen()); | |
| 1087 | |
| 1088 size_t old_selected_line = popup_model->selected_line(); | |
| 1089 EXPECT_EQ(0U, old_selected_line); | |
| 1090 | |
| 1091 // Move down the results. | |
| 1092 for (size_t size = popup_model->result().size(); | |
| 1093 popup_model->selected_line() < size - 1; | |
| 1094 old_selected_line = popup_model->selected_line()) { | |
| 1095 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | |
| 1096 ASSERT_LT(old_selected_line, popup_model->selected_line()); | |
| 1097 } | |
| 1098 | |
| 1099 // Don't move past the end. | |
| 1054 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1100 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1101 ASSERT_EQ(old_selected_line, popup_model->selected_line()); | |
| 1102 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | |
| 1103 location_bar_focus_view_id_)); | |
| 1055 | 1104 |
| 1056 omnibox_view->GetSelectionBounds(&start, &end); | 1105 // Move back up the results. |
| 1057 EXPECT_EQ(omnibox_view->GetText().size(), start); | 1106 for (; popup_model->selected_line() > 0U; |
| 1058 EXPECT_EQ(omnibox_view->GetText().size(), end); | 1107 old_selected_line = popup_model->selected_line()) { |
| 1108 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); | |
| 1109 ASSERT_GT(old_selected_line, popup_model->selected_line()); | |
| 1110 } | |
| 1111 | |
| 1112 // Don't move past the beginning. | |
| 1113 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); | |
| 1114 ASSERT_EQ(0U, popup_model->selected_line()); | |
| 1115 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | |
| 1116 location_bar_focus_view_id_)); | |
| 1117 | |
| 1118 const TestHistoryEntry kHistoryFoo = { | |
| 1119 "http://foo/", "Page foo", kSearchText, 1, 1, false | |
| 1120 }; | |
| 1121 | |
| 1122 // Add a history entry so "foo" gets multiple matches. | |
| 1123 ASSERT_NO_FATAL_FAILURE( | |
| 1124 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromHours(1))); | |
| 1125 | |
| 1126 // Load results. | |
| 1127 ASSERT_NO_FATAL_FAILURE(omnibox_view->SelectAll(false)); | |
| 1128 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | |
| 1129 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | |
| 1130 | |
| 1131 // Trigger keyword mode by tab. | |
| 1132 string16 text = ASCIIToUTF16(kSearchKeyword); | |
| 1133 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | |
| 1134 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | |
| 1135 ASSERT_EQ(text, omnibox_view->model()->keyword()); | |
| 1136 ASSERT_TRUE(omnibox_view->GetText().empty()); | |
| 1059 | 1137 |
| 1060 // The location bar should still have focus. | 1138 // The location bar should still have focus. |
| 1061 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1139 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1062 location_bar_focus_view_id_)); | 1140 location_bar_focus_view_id_)); |
| 1063 | 1141 |
| 1064 // Pressing tab when cursor is at the end should change focus. | 1142 // Pressing tab again should move to the next result and clear keyword |
| 1143 // mode. | |
| 1065 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1144 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1145 ASSERT_EQ(1U, omnibox_view->model()->popup_model()->selected_line()); | |
| 1146 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | |
| 1147 ASSERT_NE(text, omnibox_view->model()->keyword()); | |
| 1066 | 1148 |
| 1067 ASSERT_FALSE(ui_test_utils::IsViewFocused(browser(), | 1149 // The location bar should still have focus. |
| 1068 location_bar_focus_view_id_)); | 1150 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1151 location_bar_focus_view_id_)); | |
| 1152 | |
| 1153 // Moving back up should not show keyword mode. | |
| 1154 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); | |
| 1155 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | |
| 1156 ASSERT_EQ(text, omnibox_view->model()->keyword()); | |
| 1157 | |
| 1158 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | |
| 1159 location_bar_focus_view_id_)); | |
| 1069 } | 1160 } |
| 1070 | 1161 |
| 1071 void PersistKeywordModeOnTabSwitch() { | 1162 void PersistKeywordModeOnTabSwitch() { |
| 1072 OmniboxView* omnibox_view = NULL; | 1163 OmniboxView* omnibox_view = NULL; |
| 1073 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1164 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1074 | 1165 |
| 1075 // Trigger keyword hint mode. | 1166 // Trigger keyword hint mode. |
| 1076 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 1167 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 1077 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1168 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
| 1078 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 1169 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 | 1275 |
| 1185 #if defined(OS_POSIX) | 1276 #if defined(OS_POSIX) |
| 1186 // Flaky on Mac 10.6, Linux http://crbug.com/84420 | 1277 // Flaky on Mac 10.6, Linux http://crbug.com/84420 |
| 1187 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FLAKY_DeleteItem) { | 1278 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FLAKY_DeleteItem) { |
| 1188 #else | 1279 #else |
| 1189 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DeleteItem) { | 1280 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DeleteItem) { |
| 1190 #endif | 1281 #endif |
| 1191 DeleteItemTest(); | 1282 DeleteItemTest(); |
| 1192 } | 1283 } |
| 1193 | 1284 |
| 1194 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabMoveCursorToEnd) { | 1285 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabAcceptKeyword) { |
| 1195 TabMoveCursorToEndTest(); | 1286 TabAcceptKeyword(); |
| 1196 } | 1287 } |
| 1197 | 1288 |
| 1289 #if !defined(OS_MACOSX) | |
| 1290 // Mac intentionally does not support this behavior. | |
| 1291 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabTraverseResultsTest) { | |
| 1292 TabTraverseResultsTest(); | |
| 1293 } | |
| 1294 #endif | |
| 1295 | |
| 1198 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, | 1296 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, |
| 1199 PersistKeywordModeOnTabSwitch) { | 1297 PersistKeywordModeOnTabSwitch) { |
| 1200 PersistKeywordModeOnTabSwitch(); | 1298 PersistKeywordModeOnTabSwitch(); |
| 1201 } | 1299 } |
| 1202 | 1300 |
| 1203 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, | 1301 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, |
| 1204 CtrlKeyPressedWithInlineAutocompleteTest) { | 1302 CtrlKeyPressedWithInlineAutocompleteTest) { |
| 1205 CtrlKeyPressedWithInlineAutocompleteTest(); | 1303 CtrlKeyPressedWithInlineAutocompleteTest(); |
| 1206 } | 1304 } |
| 1207 | 1305 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 | 1425 |
| 1328 // Paste text. | 1426 // Paste text. |
| 1329 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); | 1427 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); |
| 1330 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1428 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1331 ASSERT_TRUE(popup_model->IsOpen()); | 1429 ASSERT_TRUE(popup_model->IsOpen()); |
| 1332 | 1430 |
| 1333 // Inline autocomplete shouldn't be triggered. | 1431 // Inline autocomplete shouldn't be triggered. |
| 1334 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); | 1432 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); |
| 1335 } | 1433 } |
| 1336 #endif | 1434 #endif |
| OLD | NEW |