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 | |
44 #if defined(TOOLKIT_USES_GTK) | 40 #if defined(TOOLKIT_USES_GTK) |
45 #include <gdk/gdk.h> | 41 #include <gdk/gdk.h> |
46 #include <gtk/gtk.h> | 42 #include <gtk/gtk.h> |
47 #endif | 43 #endif |
48 | 44 |
49 #if defined(TOOLKIT_VIEWS) | 45 #if defined(TOOLKIT_VIEWS) |
50 #include "ui/views/controls/textfield/native_textfield_views.h" | 46 #include "ui/views/controls/textfield/native_textfield_views.h" |
51 #include "ui/views/events/event.h" | 47 #include "ui/views/events/event.h" |
52 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
53 #endif | 49 #endif |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 public content::NotificationObserver { | 150 public content::NotificationObserver { |
155 protected: | 151 protected: |
156 OmniboxViewTest() | 152 OmniboxViewTest() |
157 : location_bar_focus_view_id_(VIEW_ID_LOCATION_BAR) { | 153 : location_bar_focus_view_id_(VIEW_ID_LOCATION_BAR) { |
158 set_show_window(true); | 154 set_show_window(true); |
159 // TODO(mrossetti): HQP does not yet support DeleteMatch. | 155 // TODO(mrossetti): HQP does not yet support DeleteMatch. |
160 // http://crbug.com/82335 | 156 // http://crbug.com/82335 |
161 HistoryQuickProvider::set_disabled(true); | 157 HistoryQuickProvider::set_disabled(true); |
162 } | 158 } |
163 | 159 |
164 #if defined(TOOLKIT_GTK) | |
165 virtual void OnBeforeShowBrowser(Browser* browser) { | |
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 | |
173 virtual void SetUpOnMainThread() { | 160 virtual void SetUpOnMainThread() { |
174 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 161 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
175 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | 162 ASSERT_NO_FATAL_FAILURE(SetupComponents()); |
176 browser()->FocusLocationBar(); | 163 browser()->FocusLocationBar(); |
177 // Use Textfield's view id on pure views. See crbug.com/71144. | 164 // Use Textfield's view id on pure views. See crbug.com/71144. |
178 #if defined(TOOLKIT_VIEWS) | 165 #if defined(TOOLKIT_VIEWS) |
179 if (views::Widget::IsPureViews()) | 166 if (views::Widget::IsPureViews()) |
180 location_bar_focus_view_id_ = VIEW_ID_OMNIBOX; | 167 location_bar_focus_view_id_ = VIEW_ID_OMNIBOX; |
181 #endif | 168 #endif |
182 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 169 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 | 740 |
754 // Revert to keyword hint mode. | 741 // Revert to keyword hint mode. |
755 omnibox_view->model()->ClearKeyword(string16()); | 742 omnibox_view->model()->ClearKeyword(string16()); |
756 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 743 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
757 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 744 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
758 ASSERT_EQ(text, omnibox_view->GetText()); | 745 ASSERT_EQ(text, omnibox_view->GetText()); |
759 | 746 |
760 // Keyword should also be accepted by typing an ideographic space. | 747 // Keyword should also be accepted by typing an ideographic space. |
761 omnibox_view->OnBeforePossibleChange(); | 748 omnibox_view->OnBeforePossibleChange(); |
762 omnibox_view->SetWindowTextAndCaretPos(text + WideToUTF16(L"\x3000"), | 749 omnibox_view->SetWindowTextAndCaretPos(text + WideToUTF16(L"\x3000"), |
763 text.length() + 1, false, false); | 750 text.length() + 1); |
764 omnibox_view->OnAfterPossibleChange(); | 751 omnibox_view->OnAfterPossibleChange(); |
765 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 752 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
766 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 753 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
767 ASSERT_TRUE(omnibox_view->GetText().empty()); | 754 ASSERT_TRUE(omnibox_view->GetText().empty()); |
768 | 755 |
769 // Revert to keyword hint mode. | 756 // Revert to keyword hint mode. |
770 omnibox_view->model()->ClearKeyword(string16()); | 757 omnibox_view->model()->ClearKeyword(string16()); |
771 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 758 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
772 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 759 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
773 ASSERT_EQ(text, omnibox_view->GetText()); | 760 ASSERT_EQ(text, omnibox_view->GetText()); |
774 | 761 |
775 // Keyword shouldn't be accepted by pressing space with a trailing | 762 // Keyword shouldn't be accepted by pressing space with a trailing |
776 // whitespace. | 763 // whitespace. |
777 omnibox_view->SetWindowTextAndCaretPos( | 764 omnibox_view->SetWindowTextAndCaretPos( |
778 text + char16(' '), text.length() + 1, false, false); | 765 text + char16(' '), text.length() + 1); |
779 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 766 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
780 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 767 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
781 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 768 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
782 ASSERT_EQ(text + ASCIIToUTF16(" "), omnibox_view->GetText()); | 769 ASSERT_EQ(text + ASCIIToUTF16(" "), omnibox_view->GetText()); |
783 | 770 |
784 // Keyword shouldn't be accepted by deleting the trailing space. | 771 // Keyword shouldn't be accepted by deleting the trailing space. |
785 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 772 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
786 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 773 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
787 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 774 ASSERT_EQ(text, omnibox_view->model()->keyword()); |
788 ASSERT_EQ(text + char16(' '), omnibox_view->GetText()); | 775 ASSERT_EQ(text + char16(' '), omnibox_view->GetText()); |
(...skipping 16 matching lines...) Expand all Loading... |
805 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); | 792 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); |
806 | 793 |
807 // Keyword shouldn't be accepted by pasting "foo bar". | 794 // Keyword shouldn't be accepted by pasting "foo bar". |
808 omnibox_view->SetUserText(string16()); | 795 omnibox_view->SetUserText(string16()); |
809 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 796 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
810 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 797 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
811 | 798 |
812 omnibox_view->OnBeforePossibleChange(); | 799 omnibox_view->OnBeforePossibleChange(); |
813 omnibox_view->model()->on_paste(); | 800 omnibox_view->model()->on_paste(); |
814 omnibox_view->SetWindowTextAndCaretPos(text + ASCIIToUTF16(" bar"), | 801 omnibox_view->SetWindowTextAndCaretPos(text + ASCIIToUTF16(" bar"), |
815 text.length() + 4, false, false); | 802 text.length() + 4); |
816 omnibox_view->OnAfterPossibleChange(); | 803 omnibox_view->OnAfterPossibleChange(); |
817 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 804 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
818 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 805 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
819 ASSERT_EQ(text + ASCIIToUTF16(" bar"), omnibox_view->GetText()); | 806 ASSERT_EQ(text + ASCIIToUTF16(" bar"), omnibox_view->GetText()); |
820 | 807 |
821 // Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar". | 808 // Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar". |
822 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 809 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
823 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 810 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
824 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 811 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
825 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 812 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1006 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
1020 #endif | 1007 #endif |
1021 | 1008 |
1022 // As the current selected item is the new default item, pressing Escape key | 1009 // As the current selected item is the new default item, pressing Escape key |
1023 // should revert all directly. | 1010 // should revert all directly. |
1024 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); | 1011 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); |
1025 ASSERT_EQ(old_text, omnibox_view->GetText()); | 1012 ASSERT_EQ(old_text, omnibox_view->GetText()); |
1026 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 1013 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
1027 } | 1014 } |
1028 | 1015 |
1029 void TabAcceptKeyword() { | 1016 void TabMoveCursorToEndTest() { |
1030 OmniboxView* omnibox_view = NULL; | 1017 OmniboxView* omnibox_view = NULL; |
1031 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1018 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
1032 | 1019 |
1033 string16 text = ASCIIToUTF16(kSearchKeyword); | 1020 omnibox_view->SetUserText(ASCIIToUTF16("Hello world")); |
1034 | 1021 |
1035 // Trigger keyword hint mode. | 1022 // Move cursor to the beginning. |
1036 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 1023 #if defined(OS_MACOSX) |
1037 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1024 // Home doesn't work on Mac trybot. |
1038 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1025 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN)); |
1039 ASSERT_EQ(text, omnibox_view->GetText()); | 1026 #else |
| 1027 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, 0)); |
| 1028 #endif |
1040 | 1029 |
1041 // Trigger keyword mode by tab. | 1030 size_t start, end; |
| 1031 omnibox_view->GetSelectionBounds(&start, &end); |
| 1032 EXPECT_EQ(0U, start); |
| 1033 EXPECT_EQ(0U, end); |
| 1034 |
| 1035 // Pressing tab should move cursor to the end. |
1042 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1036 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
1043 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | |
1044 ASSERT_EQ(text, omnibox_view->model()->keyword()); | |
1045 ASSERT_TRUE(omnibox_view->GetText().empty()); | |
1046 | 1037 |
1047 // Revert to keyword hint mode. | 1038 omnibox_view->GetSelectionBounds(&start, &end); |
1048 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 1039 EXPECT_EQ(omnibox_view->GetText().size(), start); |
1049 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1040 EXPECT_EQ(omnibox_view->GetText().size(), end); |
1050 ASSERT_EQ(text, omnibox_view->model()->keyword()); | |
1051 ASSERT_EQ(text, omnibox_view->GetText()); | |
1052 | 1041 |
1053 // The location bar should still have focus. | 1042 // The location bar should still have focus. |
1054 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1043 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
1055 location_bar_focus_view_id_)); | 1044 location_bar_focus_view_id_)); |
1056 | 1045 |
1057 // Trigger keyword mode by tab. | 1046 // Select all text. |
| 1047 omnibox_view->SelectAll(true); |
| 1048 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 1049 omnibox_view->GetSelectionBounds(&start, &end); |
| 1050 EXPECT_EQ(0U, start); |
| 1051 EXPECT_EQ(omnibox_view->GetText().size(), end); |
| 1052 |
| 1053 // Pressing tab should move cursor to the end. |
1058 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1054 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
1059 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | |
1060 ASSERT_EQ(text, omnibox_view->model()->keyword()); | |
1061 ASSERT_TRUE(omnibox_view->GetText().empty()); | |
1062 | 1055 |
1063 // Revert to keyword hint mode with SHIFT+TAB. | 1056 omnibox_view->GetSelectionBounds(&start, &end); |
1064 #if defined(OS_MACOSX) | 1057 EXPECT_EQ(omnibox_view->GetText().size(), start); |
1065 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACKTAB, 0)); | 1058 EXPECT_EQ(omnibox_view->GetText().size(), end); |
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. | |
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_)); | |
1104 | |
1105 // Move back up the results. | |
1106 for (; popup_model->selected_line() > 0U; | |
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()); | |
1137 | 1059 |
1138 // The location bar should still have focus. | 1060 // The location bar should still have focus. |
1139 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1061 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
1140 location_bar_focus_view_id_)); | 1062 location_bar_focus_view_id_)); |
1141 | 1063 |
1142 // Pressing tab again should move to the next result and clear keyword | 1064 // Pressing tab when cursor is at the end should change focus. |
1143 // mode. | |
1144 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1065 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()); | |
1148 | 1066 |
1149 // The location bar should still have focus. | 1067 ASSERT_FALSE(ui_test_utils::IsViewFocused(browser(), |
1150 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1068 location_bar_focus_view_id_)); |
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_)); | |
1160 } | 1069 } |
1161 | 1070 |
1162 void PersistKeywordModeOnTabSwitch() { | 1071 void PersistKeywordModeOnTabSwitch() { |
1163 OmniboxView* omnibox_view = NULL; | 1072 OmniboxView* omnibox_view = NULL; |
1164 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1073 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
1165 | 1074 |
1166 // Trigger keyword hint mode. | 1075 // Trigger keyword hint mode. |
1167 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 1076 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
1168 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1077 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
1169 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 1078 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 | 1184 |
1276 #if defined(OS_POSIX) | 1185 #if defined(OS_POSIX) |
1277 // Flaky on Mac 10.6, Linux http://crbug.com/84420 | 1186 // Flaky on Mac 10.6, Linux http://crbug.com/84420 |
1278 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FLAKY_DeleteItem) { | 1187 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FLAKY_DeleteItem) { |
1279 #else | 1188 #else |
1280 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DeleteItem) { | 1189 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DeleteItem) { |
1281 #endif | 1190 #endif |
1282 DeleteItemTest(); | 1191 DeleteItemTest(); |
1283 } | 1192 } |
1284 | 1193 |
1285 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabAcceptKeyword) { | 1194 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabMoveCursorToEnd) { |
1286 TabAcceptKeyword(); | 1195 TabMoveCursorToEndTest(); |
1287 } | 1196 } |
1288 | 1197 |
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 | |
1296 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, | 1198 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, |
1297 PersistKeywordModeOnTabSwitch) { | 1199 PersistKeywordModeOnTabSwitch) { |
1298 PersistKeywordModeOnTabSwitch(); | 1200 PersistKeywordModeOnTabSwitch(); |
1299 } | 1201 } |
1300 | 1202 |
1301 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, | 1203 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, |
1302 CtrlKeyPressedWithInlineAutocompleteTest) { | 1204 CtrlKeyPressedWithInlineAutocompleteTest) { |
1303 CtrlKeyPressedWithInlineAutocompleteTest(); | 1205 CtrlKeyPressedWithInlineAutocompleteTest(); |
1304 } | 1206 } |
1305 | 1207 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 | 1327 |
1426 // Paste text. | 1328 // Paste text. |
1427 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); | 1329 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); |
1428 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1330 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
1429 ASSERT_TRUE(popup_model->IsOpen()); | 1331 ASSERT_TRUE(popup_model->IsOpen()); |
1430 | 1332 |
1431 // Inline autocomplete shouldn't be triggered. | 1333 // Inline autocomplete shouldn't be triggered. |
1432 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); | 1334 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); |
1433 } | 1335 } |
1434 #endif | 1336 #endif |
OLD | NEW |