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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 12377065: Consolidate VIEW_ID_LOCATION_BAR into VIEW_ID_OMNIBOX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/omnibox/action_box_browsertest.cc ('k') | chrome/browser/ui/view_ids.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/ui/views/frame/browser_view.h" 50 #include "chrome/browser/ui/views/frame/browser_view.h"
51 #endif 51 #endif
52 52
53 using base::Time; 53 using base::Time;
54 using base::TimeDelta; 54 using base::TimeDelta;
55 55
56 namespace { 56 namespace {
57 57
58 const char kSearchKeyword[] = "foo"; 58 const char kSearchKeyword[] = "foo";
59 const char kSearchKeyword2[] = "footest.com"; 59 const char kSearchKeyword2[] = "footest.com";
60 const wchar_t kSearchKeywordKeys[] = { 60 const wchar_t kSearchKeywordKeys[] = { ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, 0 };
61 ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, 0
62 };
63 const char kSearchURL[] = "http://www.foo.com/search?q={searchTerms}"; 61 const char kSearchURL[] = "http://www.foo.com/search?q={searchTerms}";
64 const char kSearchShortName[] = "foo"; 62 const char kSearchShortName[] = "foo";
65 const char kSearchText[] = "abc"; 63 const char kSearchText[] = "abc";
66 const wchar_t kSearchTextKeys[] = { 64 const wchar_t kSearchTextKeys[] = { ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, 0 };
67 ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, 0
68 };
69 const char kSearchTextURL[] = "http://www.foo.com/search?q=abc"; 65 const char kSearchTextURL[] = "http://www.foo.com/search?q=abc";
70 const char kSearchSingleChar[] = "z"; 66 const char kSearchSingleChar[] = "z";
71 const wchar_t kSearchSingleCharKeys[] = { ui::VKEY_Z, 0 }; 67 const wchar_t kSearchSingleCharKeys[] = { ui::VKEY_Z, 0 };
72 const char kSearchSingleCharURL[] = "http://www.foo.com/search?q=z"; 68 const char kSearchSingleCharURL[] = "http://www.foo.com/search?q=z";
73 69
74 const char kHistoryPageURL[] = "chrome://history/#q=abc"; 70 const char kHistoryPageURL[] = "chrome://history/#q=abc";
75 71
76 const char kDesiredTLDHostname[] = "www.bar.com"; 72 const char kDesiredTLDHostname[] = "www.bar.com";
77 const wchar_t kDesiredTLDKeys[] = { 73 const wchar_t kDesiredTLDKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 };
78 ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0
79 };
80 74
81 const char kInlineAutocompleteText[] = "def"; 75 const char kInlineAutocompleteText[] = "def";
82 const wchar_t kInlineAutocompleteTextKeys[] = { 76 const wchar_t kInlineAutocompleteTextKeys[] = {
83 ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0 77 ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0
84 }; 78 };
85 79
86 // Hostnames that shall be blocked by host resolver. 80 // Hostnames that shall be blocked by host resolver.
87 const char *kBlockedHostnames[] = { 81 const char *kBlockedHostnames[] = {
88 "foo", 82 "foo",
89 "*.foo.com", 83 "*.foo.com",
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN; 147 const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN;
154 #else 148 #else
155 const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN; 149 const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN;
156 #endif 150 #endif
157 151
158 } // namespace 152 } // namespace
159 153
160 class OmniboxViewTest : public InProcessBrowserTest, 154 class OmniboxViewTest : public InProcessBrowserTest,
161 public content::NotificationObserver { 155 public content::NotificationObserver {
162 protected: 156 protected:
163 OmniboxViewTest()
164 : location_bar_focus_view_id_(VIEW_ID_LOCATION_BAR) {
165 }
166
167 virtual void SetUpOnMainThread() OVERRIDE { 157 virtual void SetUpOnMainThread() OVERRIDE {
168 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 158 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
169 ASSERT_NO_FATAL_FAILURE(SetupComponents()); 159 ASSERT_NO_FATAL_FAILURE(SetupComponents());
170 chrome::FocusLocationBar(browser()); 160 chrome::FocusLocationBar(browser());
171 // Use Textfield's view id on pure views. See crbug.com/71144. 161 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
172 #if defined(USE_AURA)
173 location_bar_focus_view_id_ = VIEW_ID_OMNIBOX;
174 #endif
175 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(),
176 location_bar_focus_view_id_));
177 } 162 }
178 163
179 static void GetOmniboxViewForBrowser( 164 static void GetOmniboxViewForBrowser(
180 const Browser* browser, 165 const Browser* browser,
181 OmniboxView** omnibox_view) { 166 OmniboxView** omnibox_view) {
182 BrowserWindow* window = browser->window(); 167 BrowserWindow* window = browser->window();
183 ASSERT_TRUE(window); 168 ASSERT_TRUE(window);
184 LocationBar* loc_bar = window->GetLocationBar(); 169 LocationBar* loc_bar = window->GetLocationBar();
185 ASSERT_TRUE(loc_bar); 170 ASSERT_TRUE(loc_bar);
186 *omnibox_view = loc_bar->GetLocationEntry(); 171 *omnibox_view = loc_bar->GetLocationEntry();
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 ASSERT_EQ(text, omnibox_view->model()->keyword()); 1101 ASSERT_EQ(text, omnibox_view->model()->keyword());
1117 ASSERT_TRUE(omnibox_view->GetText().empty()); 1102 ASSERT_TRUE(omnibox_view->GetText().empty());
1118 1103
1119 // Revert to keyword hint mode. 1104 // Revert to keyword hint mode.
1120 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); 1105 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
1121 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 1106 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
1122 ASSERT_EQ(text, omnibox_view->model()->keyword()); 1107 ASSERT_EQ(text, omnibox_view->model()->keyword());
1123 ASSERT_EQ(text, omnibox_view->GetText()); 1108 ASSERT_EQ(text, omnibox_view->GetText());
1124 1109
1125 // The location bar should still have focus. 1110 // The location bar should still have focus.
1126 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1111 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1127 location_bar_focus_view_id_));
1128 1112
1129 // Trigger keyword mode by tab. 1113 // Trigger keyword mode by tab.
1130 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); 1114 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1131 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); 1115 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
1132 ASSERT_EQ(text, omnibox_view->model()->keyword()); 1116 ASSERT_EQ(text, omnibox_view->model()->keyword());
1133 ASSERT_TRUE(omnibox_view->GetText().empty()); 1117 ASSERT_TRUE(omnibox_view->GetText().empty());
1134 1118
1135 // Revert to keyword hint mode with SHIFT+TAB. 1119 // Revert to keyword hint mode with SHIFT+TAB.
1136 #if defined(OS_MACOSX) 1120 #if defined(OS_MACOSX)
1137 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACKTAB, 0)); 1121 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACKTAB, 0));
1138 #else 1122 #else
1139 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); 1123 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN));
1140 #endif 1124 #endif
1141 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 1125 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
1142 ASSERT_EQ(text, omnibox_view->model()->keyword()); 1126 ASSERT_EQ(text, omnibox_view->model()->keyword());
1143 ASSERT_EQ(text, omnibox_view->GetText()); 1127 ASSERT_EQ(text, omnibox_view->GetText());
1144 1128 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1145 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(),
1146 location_bar_focus_view_id_));
1147 } 1129 }
1148 1130
1149 void TabTraverseResultsTest() { 1131 void TabTraverseResultsTest() {
1150 OmniboxView* omnibox_view = NULL; 1132 OmniboxView* omnibox_view = NULL;
1151 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 1133 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
1152 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); 1134 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model();
1153 ASSERT_TRUE(popup_model); 1135 ASSERT_TRUE(popup_model);
1154 1136
1155 // Input something to trigger results. 1137 // Input something to trigger results.
1156 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); 1138 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys));
1157 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1139 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1158 ASSERT_TRUE(popup_model->IsOpen()); 1140 ASSERT_TRUE(popup_model->IsOpen());
1159 1141
1160 size_t old_selected_line = popup_model->selected_line(); 1142 size_t old_selected_line = popup_model->selected_line();
1161 EXPECT_EQ(0U, old_selected_line); 1143 EXPECT_EQ(0U, old_selected_line);
1162 1144
1163 // Move down the results. 1145 // Move down the results.
1164 for (size_t size = popup_model->result().size(); 1146 for (size_t size = popup_model->result().size();
1165 popup_model->selected_line() < size - 1; 1147 popup_model->selected_line() < size - 1;
1166 old_selected_line = popup_model->selected_line()) { 1148 old_selected_line = popup_model->selected_line()) {
1167 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); 1149 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1168 ASSERT_LT(old_selected_line, popup_model->selected_line()); 1150 ASSERT_LT(old_selected_line, popup_model->selected_line());
1169 } 1151 }
1170 1152
1171 // Don't move past the end. 1153 // Don't move past the end.
1172 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); 1154 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1173 ASSERT_EQ(old_selected_line, popup_model->selected_line()); 1155 ASSERT_EQ(old_selected_line, popup_model->selected_line());
1174 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1156 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1175 location_bar_focus_view_id_));
1176 1157
1177 // Move back up the results. 1158 // Move back up the results.
1178 for (; popup_model->selected_line() > 0U; 1159 for (; popup_model->selected_line() > 0U;
1179 old_selected_line = popup_model->selected_line()) { 1160 old_selected_line = popup_model->selected_line()) {
1180 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); 1161 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN));
1181 ASSERT_GT(old_selected_line, popup_model->selected_line()); 1162 ASSERT_GT(old_selected_line, popup_model->selected_line());
1182 } 1163 }
1183 1164
1184 // Don't move past the beginning. 1165 // Don't move past the beginning.
1185 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); 1166 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN));
1186 ASSERT_EQ(0U, popup_model->selected_line()); 1167 ASSERT_EQ(0U, popup_model->selected_line());
1187 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1168 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1188 location_bar_focus_view_id_));
1189 1169
1190 const TestHistoryEntry kHistoryFoo = { 1170 const TestHistoryEntry kHistoryFoo = {
1191 "http://foo/", "Page foo", kSearchText, 1, 1, false 1171 "http://foo/", "Page foo", kSearchText, 1, 1, false
1192 }; 1172 };
1193 1173
1194 // Add a history entry so "foo" gets multiple matches. 1174 // Add a history entry so "foo" gets multiple matches.
1195 ASSERT_NO_FATAL_FAILURE( 1175 ASSERT_NO_FATAL_FAILURE(
1196 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromHours(1))); 1176 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromHours(1)));
1197 1177
1198 // Load results. 1178 // Load results.
1199 ASSERT_NO_FATAL_FAILURE(omnibox_view->SelectAll(false)); 1179 ASSERT_NO_FATAL_FAILURE(omnibox_view->SelectAll(false));
1200 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); 1180 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
1201 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1181 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1202 1182
1203 // Trigger keyword mode by tab. 1183 // Trigger keyword mode by tab.
1204 string16 text = ASCIIToUTF16(kSearchKeyword); 1184 string16 text = ASCIIToUTF16(kSearchKeyword);
1205 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); 1185 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1206 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); 1186 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
1207 ASSERT_EQ(text, omnibox_view->model()->keyword()); 1187 ASSERT_EQ(text, omnibox_view->model()->keyword());
1208 ASSERT_TRUE(omnibox_view->GetText().empty()); 1188 ASSERT_TRUE(omnibox_view->GetText().empty());
1209 1189
1210 // The location bar should still have focus. 1190 // The location bar should still have focus.
1211 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1191 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1212 location_bar_focus_view_id_));
1213 1192
1214 // Pressing tab again should move to the next result and clear keyword 1193 // Pressing tab again should move to the next result and clear keyword
1215 // mode. 1194 // mode.
1216 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); 1195 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1217 ASSERT_EQ(1U, omnibox_view->model()->popup_model()->selected_line()); 1196 ASSERT_EQ(1U, omnibox_view->model()->popup_model()->selected_line());
1218 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); 1197 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
1219 ASSERT_NE(text, omnibox_view->model()->keyword()); 1198 ASSERT_NE(text, omnibox_view->model()->keyword());
1220 1199
1221 // The location bar should still have focus. 1200 // The location bar should still have focus.
1222 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1201 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1223 location_bar_focus_view_id_));
1224 1202
1225 // Moving back up should not show keyword mode. 1203 // Moving back up should not show keyword mode.
1226 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); 1204 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN));
1227 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 1205 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
1228 ASSERT_EQ(text, omnibox_view->model()->keyword()); 1206 ASSERT_EQ(text, omnibox_view->model()->keyword());
1229 1207
1230 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1208 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1231 location_bar_focus_view_id_));
1232 } 1209 }
1233 1210
1234 void PersistKeywordModeOnTabSwitch() { 1211 void PersistKeywordModeOnTabSwitch() {
1235 OmniboxView* omnibox_view = NULL; 1212 OmniboxView* omnibox_view = NULL;
1236 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 1213 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
1237 1214
1238 // Trigger keyword hint mode. 1215 // Trigger keyword hint mode.
1239 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); 1216 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
1240 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 1217 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
1241 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); 1218 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword()));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 // Inline autocomplete should still be there. 1257 // Inline autocomplete should still be there.
1281 EXPECT_EQ(old_text, omnibox_view->GetText()); 1258 EXPECT_EQ(old_text, omnibox_view->GetText());
1282 } 1259 }
1283 1260
1284 #if defined(USE_AURA) 1261 #if defined(USE_AURA)
1285 const BrowserView* GetBrowserView() const { 1262 const BrowserView* GetBrowserView() const {
1286 return static_cast<BrowserView*>(browser()->window()); 1263 return static_cast<BrowserView*>(browser()->window());
1287 } 1264 }
1288 1265
1289 const views::View* GetFocusView() const { 1266 const views::View* GetFocusView() const {
1290 return GetBrowserView()->GetViewByID(location_bar_focus_view_id_); 1267 return GetBrowserView()->GetViewByID(VIEW_ID_OMNIBOX);
1291 } 1268 }
1292 1269
1293 // Move the mouse to the center of the browser window and left-click. 1270 // Move the mouse to the center of the browser window and left-click.
1294 void ClickBrowserWindowCenter() { 1271 void ClickBrowserWindowCenter() {
1295 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( 1272 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
1296 GetBrowserView()->GetBoundsInScreen().CenterPoint())); 1273 GetBrowserView()->GetBoundsInScreen().CenterPoint()));
1297 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( 1274 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
1298 ui_controls::LEFT, ui_controls::DOWN)); 1275 ui_controls::LEFT, ui_controls::DOWN));
1299 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( 1276 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
1300 ui_controls::LEFT, ui_controls::UP)); 1277 ui_controls::LEFT, ui_controls::UP));
1301 } 1278 }
1302 1279
1303 // Press and release the mouse in the focus view at an offset from its origin. 1280 // Press and release the mouse in the focus view at an offset from its origin.
1304 // If |release_offset| differs from |press_offset|, the mouse will be moved 1281 // If |release_offset| differs from |press_offset|, the mouse will be moved
1305 // between the press and release. 1282 // between the press and release.
1306 void ClickFocusViewOrigin(ui_controls::MouseButton button, 1283 void ClickFocusViewOrigin(ui_controls::MouseButton button,
1307 const gfx::Vector2d& press_offset, 1284 const gfx::Vector2d& press_offset,
1308 const gfx::Vector2d& release_offset) { 1285 const gfx::Vector2d& release_offset) {
1309 gfx::Point focus_view_origin = GetFocusView()->GetBoundsInScreen().origin(); 1286 gfx::Point focus_view_origin = GetFocusView()->GetBoundsInScreen().origin();
1310 gfx::Point press_point = focus_view_origin + press_offset; 1287 gfx::Point press_point = focus_view_origin + press_offset;
1311 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(press_point)); 1288 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(press_point));
1312 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::DOWN)); 1289 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::DOWN));
1313 1290
1314 gfx::Point release_point = focus_view_origin + release_offset; 1291 gfx::Point release_point = focus_view_origin + release_offset;
1315 if (release_point != press_point) 1292 if (release_point != press_point)
1316 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(release_point)); 1293 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(release_point));
1317 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::UP)); 1294 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::UP));
1318 } 1295 }
1319 #endif // defined(USE_AURA) 1296 #endif // defined(USE_AURA)
1320
1321 ViewID location_bar_focus_view_id() const {
1322 return location_bar_focus_view_id_;
1323 }
1324
1325 private:
1326 ViewID location_bar_focus_view_id_;
1327 }; 1297 };
1328 1298
1329 // Test if ctrl-* accelerators are workable in omnibox. 1299 // Test if ctrl-* accelerators are workable in omnibox.
1330 // See http://crbug.com/19193: omnibox blocks ctrl-* commands 1300 // See http://crbug.com/19193: omnibox blocks ctrl-* commands
1331 // 1301 //
1332 // Flaky on interactive tests (dbg), http://crbug.com/69433 1302 // Flaky on interactive tests (dbg), http://crbug.com/69433
1333 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { 1303 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) {
1334 BrowserAcceleratorsTest(); 1304 BrowserAcceleratorsTest();
1335 } 1305 }
1336 1306
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 omnibox_view->SetUserText(ASCIIToUTF16(target_url)); 1670 omnibox_view->SetUserText(ASCIIToUTF16(target_url));
1701 1671
1702 // Set permanent text thus making sure that omnibox treats 'google.com' 1672 // Set permanent text thus making sure that omnibox treats 'google.com'
1703 // as URL (not as ordinary user input). 1673 // as URL (not as ordinary user input).
1704 OmniboxEditModel* edit_model = omnibox_view->model(); 1674 OmniboxEditModel* edit_model = omnibox_view->model();
1705 ASSERT_NE(static_cast<OmniboxEditModel*>(NULL), edit_model); 1675 ASSERT_NE(static_cast<OmniboxEditModel*>(NULL), edit_model);
1706 edit_model->UpdatePermanentText(ASCIIToUTF16("http://www.google.com/")); 1676 edit_model->UpdatePermanentText(ASCIIToUTF16("http://www.google.com/"));
1707 1677
1708 // Location bar must have focus to receive Ctrl-C. 1678 // Location bar must have focus to receive Ctrl-C.
1709 chrome::FocusLocationBar(browser()); 1679 chrome::FocusLocationBar(browser());
1710 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), 1680 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
1711 location_bar_focus_view_id()));
1712 1681
1713 // Select full URL and copy it to clipboard. General text and html should 1682 // Select full URL and copy it to clipboard. General text and html should
1714 // be available. 1683 // be available.
1715 omnibox_view->SelectAll(true); 1684 omnibox_view->SelectAll(true);
1716 EXPECT_TRUE(omnibox_view->IsSelectAll()); 1685 EXPECT_TRUE(omnibox_view->IsSelectAll());
1717 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 1686 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
1718 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); 1687 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
1719 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_C, kCtrlOrCmdMask)); 1688 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_C, kCtrlOrCmdMask));
1720 EXPECT_TRUE(clipboard->IsFormatAvailable( 1689 EXPECT_TRUE(clipboard->IsFormatAvailable(
1721 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1690 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
1722 1691
1723 // MAC is the only platform which doesn't write html. 1692 // MAC is the only platform which doesn't write html.
1724 #if !defined(OS_MACOSX) 1693 #if !defined(OS_MACOSX)
1725 EXPECT_TRUE(clipboard->IsFormatAvailable( 1694 EXPECT_TRUE(clipboard->IsFormatAvailable(
1726 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1695 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
1727 #endif 1696 #endif
1728 1697
1729 // These platforms should read bookmark format. 1698 // These platforms should read bookmark format.
1730 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 1699 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
1731 string16 title; 1700 string16 title;
1732 std::string url; 1701 std::string url;
1733 clipboard->ReadBookmark(&title, &url); 1702 clipboard->ReadBookmark(&title, &url);
1734 EXPECT_EQ(target_url, url); 1703 EXPECT_EQ(target_url, url);
1735 EXPECT_EQ(ASCIIToUTF16(target_url), title); 1704 EXPECT_EQ(ASCIIToUTF16(target_url), title);
1736 #endif 1705 #endif
1737 } 1706 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/action_box_browsertest.cc ('k') | chrome/browser/ui/view_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698