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

Side by Side Diff: chrome/test/automated_ui_tests/automated_ui_test_base.cc

Issue 211033: Automated ui test porting + cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: all green\! Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/gfx/point.h"
6 #include "base/gfx/rect.h"
5 #include "chrome/app/chrome_dll_resource.h" 7 #include "chrome/app/chrome_dll_resource.h"
6 #include "chrome/browser/view_ids.h" 8 #include "chrome/browser/view_ids.h"
7 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" 9 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h"
8 #include "chrome/test/automation/browser_proxy.h" 10 #include "chrome/test/automation/browser_proxy.h"
9 #include "chrome/test/automation/tab_proxy.h" 11 #include "chrome/test/automation/tab_proxy.h"
10 #include "chrome/test/automation/window_proxy.h" 12 #include "chrome/test/automation/window_proxy.h"
11 #include "chrome/test/ui/ui_test.h" 13 #include "chrome/test/ui/ui_test.h"
12 14 #include "views/event.h"
13 #if defined(TOOLKIT_VIEWS)
14 #include "views/view.h"
15 #endif
16 15
17 AutomatedUITestBase::AutomatedUITestBase() {} 16 AutomatedUITestBase::AutomatedUITestBase() {}
18 17
19 AutomatedUITestBase::~AutomatedUITestBase() {} 18 AutomatedUITestBase::~AutomatedUITestBase() {}
20 19
21 void AutomatedUITestBase::LogErrorMessage(const std::string& error) {} 20 void AutomatedUITestBase::LogErrorMessage(const std::string& error) {}
22 21
23 void AutomatedUITestBase::LogWarningMessage(const std::string& warning) { 22 void AutomatedUITestBase::LogWarningMessage(const std::string& warning) {
24 } 23 }
25 24
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return false; 76 return false;
78 } 77 }
79 set_active_browser(browser); 78 set_active_browser(browser);
80 return true; 79 return true;
81 } 80 }
82 81
83 bool AutomatedUITestBase::DuplicateTab() { 82 bool AutomatedUITestBase::DuplicateTab() {
84 return RunCommand(IDC_DUPLICATE_TAB); 83 return RunCommand(IDC_DUPLICATE_TAB);
85 } 84 }
86 85
87 #if defined(OS_WIN)
88 bool AutomatedUITestBase::DragTabOut() { 86 bool AutomatedUITestBase::DragTabOut() {
89 BrowserProxy* browser = active_browser(); 87 BrowserProxy* browser = active_browser();
90 if (browser == NULL) { 88 if (browser == NULL) {
91 LogErrorMessage("browser_window_not_found"); 89 LogErrorMessage("browser_window_not_found");
92 return false; 90 return false;
93 } 91 }
94 92
95 scoped_refptr<WindowProxy> window( 93 scoped_refptr<WindowProxy> window(
96 GetAndActivateWindowForBrowser(browser)); 94 GetAndActivateWindowForBrowser(browser));
97 if (window.get() == NULL) { 95 if (window.get() == NULL) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 132
135 gfx::Rect urlbar_bounds; 133 gfx::Rect urlbar_bounds;
136 if (!window->GetViewBoundsWithTimeout(VIEW_ID_LOCATION_BAR, 134 if (!window->GetViewBoundsWithTimeout(VIEW_ID_LOCATION_BAR,
137 &urlbar_bounds, false, 135 &urlbar_bounds, false,
138 action_max_timeout_ms(), 136 action_max_timeout_ms(),
139 &is_timeout)) { 137 &is_timeout)) {
140 LogWarningMessage("no_location_bar_found"); 138 LogWarningMessage("no_location_bar_found");
141 return false; 139 return false;
142 } 140 }
143 141
144 // Click on the center of the tab, and drag it downwads. 142 // Click on the center of the tab, and drag it downwards.
145 POINT start; 143 gfx::Point start;
146 POINT end; 144 gfx::Point end;
147 start.x = dragged_tab_bounds.x() + dragged_tab_bounds.width()/2; 145 start.set_x(dragged_tab_bounds.x() + dragged_tab_bounds.width() / 2);
148 start.y = dragged_tab_bounds.y() + dragged_tab_bounds.height()/2; 146 start.set_y(dragged_tab_bounds.y() + dragged_tab_bounds.height() / 2);
149 end.x = start.x; 147 end.set_x(start.x());
150 end.y = start.y + 3*urlbar_bounds.height(); 148 end.set_y(start.y() + 3 * urlbar_bounds.height());
151 149
152 if (!browser->SimulateDragWithTimeout(start, end, 150 if (!browser->SimulateDragWithTimeout(start, end,
153 views::Event::EF_LEFT_BUTTON_DOWN, 151 views::Event::EF_LEFT_BUTTON_DOWN,
154 action_max_timeout_ms(), 152 action_max_timeout_ms(),
155 &is_timeout, false)) { 153 &is_timeout, false)) {
156 LogWarningMessage("failed_to_simulate_drag"); 154 LogWarningMessage("failed_to_simulate_drag");
157 return false; 155 return false;
158 } 156 }
159 157
160 return true; 158 return true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 gfx::Rect dragged_tab_bounds; 194 gfx::Rect dragged_tab_bounds;
197 if (!window->GetViewBoundsWithTimeout(VIEW_ID_TAB_0 + tab_index, 195 if (!window->GetViewBoundsWithTimeout(VIEW_ID_TAB_0 + tab_index,
198 &dragged_tab_bounds, false, 196 &dragged_tab_bounds, false,
199 action_max_timeout_ms(), 197 action_max_timeout_ms(),
200 &is_timeout)) { 198 &is_timeout)) {
201 LogWarningMessage("no_tab_view_found"); 199 LogWarningMessage("no_tab_view_found");
202 return false; 200 return false;
203 } 201 }
204 202
205 // Click on the center of the tab, and drag it to the left or the right. 203 // Click on the center of the tab, and drag it to the left or the right.
206 POINT dragged_tab_point(dragged_tab_bounds.CenterPoint().ToPOINT()); 204 gfx::Point dragged_tab_point = dragged_tab_bounds.CenterPoint();
207 POINT destination_point(dragged_tab_point); 205 gfx::Point destination_point = dragged_tab_point;
208 206
209 int new_tab_index; 207 int new_tab_index;
210 if (drag_right) { 208 if (drag_right) {
211 if (tab_index >= (tab_count - 1)) { 209 if (tab_index >= (tab_count - 1)) {
212 LogInfoMessage("cant_drag_to_right"); 210 LogInfoMessage("cant_drag_to_right");
213 return false; 211 return false;
214 } 212 }
215 new_tab_index = tab_index + 1; 213 new_tab_index = tab_index + 1;
216 destination_point.x += 2 * dragged_tab_bounds.width() / 3; 214 destination_point.Offset(2 * dragged_tab_bounds.width() / 3, 0);
217 } else { 215 } else {
218 if (tab_index <= 0) { 216 if (tab_index <= 0) {
219 LogInfoMessage("cant_drag_to_left"); 217 LogInfoMessage("cant_drag_to_left");
220 return false; 218 return false;
221 } 219 }
222 new_tab_index = tab_index - 1; 220 new_tab_index = tab_index - 1;
223 destination_point.x -= 2 * dragged_tab_bounds.width() / 3; 221 destination_point.Offset(-2 * dragged_tab_bounds.width() / 3, 0);
224 } 222 }
225 223
226 if (!browser->SimulateDragWithTimeout(dragged_tab_point, 224 if (!browser->SimulateDragWithTimeout(dragged_tab_point,
227 destination_point, 225 destination_point,
228 views::Event::EF_LEFT_BUTTON_DOWN, 226 views::Event::EF_LEFT_BUTTON_DOWN,
229 action_max_timeout_ms(), 227 action_max_timeout_ms(),
230 &is_timeout, false)) { 228 &is_timeout, false)) {
231 LogWarningMessage("failed_to_simulate_drag"); 229 LogWarningMessage("failed_to_simulate_drag");
232 return false; 230 return false;
233 } 231 }
234 232
235 if (!browser->WaitForTabToBecomeActive(new_tab_index, action_timeout_ms())) { 233 if (!browser->WaitForTabToBecomeActive(new_tab_index, action_timeout_ms())) {
236 LogWarningMessage("failed_to_reindex_tab"); 234 LogWarningMessage("failed_to_reindex_tab");
237 return false; 235 return false;
238 } 236 }
239 237
240 return true; 238 return true;
241 } 239 }
242 #endif
243 240
244 bool AutomatedUITestBase::FindInPage() { 241 bool AutomatedUITestBase::FindInPage() {
245 if (!RunCommandAsync(IDC_FIND)) 242 if (!RunCommandAsync(IDC_FIND))
246 return false; 243 return false;
247 244
248 return WaitForFindWindowVisibilityChange(active_browser(), true); 245 return WaitForFindWindowVisibilityChange(active_browser(), true);
249 } 246 }
250 247
251 bool AutomatedUITestBase::ForwardButton() { 248 bool AutomatedUITestBase::ForwardButton() {
252 return RunCommand(IDC_FORWARD); 249 return RunCommand(IDC_FORWARD);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 BrowserProxy* browser) { 407 BrowserProxy* browser) {
411 bool did_timeout; 408 bool did_timeout;
412 if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), 409 if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(),
413 &did_timeout)) { 410 &did_timeout)) {
414 LogWarningMessage("failed_to_bring_window_to_front"); 411 LogWarningMessage("failed_to_bring_window_to_front");
415 return NULL; 412 return NULL;
416 } 413 }
417 414
418 return browser->GetWindow(); 415 return browser->GetWindow();
419 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698