OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/test/automation/browser_proxy.h" | 5 #include "chrome/test/automation/browser_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "base/gfx/point.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/platform_thread.h" | 11 #include "base/platform_thread.h" |
11 #include "base/time.h" | 12 #include "base/time.h" |
12 #include "chrome/test/automation/autocomplete_edit_proxy.h" | 13 #include "chrome/test/automation/autocomplete_edit_proxy.h" |
13 #include "chrome/test/automation/automation_constants.h" | 14 #include "chrome/test/automation/automation_constants.h" |
14 #include "chrome/test/automation/automation_messages.h" | 15 #include "chrome/test/automation/automation_messages.h" |
15 #include "chrome/test/automation/automation_proxy.h" | 16 #include "chrome/test/automation/automation_proxy.h" |
16 #include "chrome/test/automation/tab_proxy.h" | 17 #include "chrome/test/automation/tab_proxy.h" |
17 #include "chrome/test/automation/window_proxy.h" | 18 #include "chrome/test/automation/window_proxy.h" |
18 | 19 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 succeeded = false; | 172 succeeded = false; |
172 } | 173 } |
173 | 174 |
174 return succeeded; | 175 return succeeded; |
175 } | 176 } |
176 | 177 |
177 bool BrowserProxy::ApplyAccelerator(int id) { | 178 bool BrowserProxy::ApplyAccelerator(int id) { |
178 return RunCommandAsync(id); | 179 return RunCommandAsync(id); |
179 } | 180 } |
180 | 181 |
181 #if defined(OS_WIN) | 182 bool BrowserProxy::SimulateDrag(const gfx::Point& start, |
182 // TODO(port): Replace POINT. | 183 const gfx::Point& end, |
183 bool BrowserProxy::SimulateDrag(const POINT& start, | |
184 const POINT& end, | |
185 int flags, | 184 int flags, |
186 bool press_escape_en_route) { | 185 bool press_escape_en_route) { |
187 return SimulateDragWithTimeout(start, end, flags, base::kNoTimeout, NULL, | 186 return SimulateDragWithTimeout(start, end, flags, base::kNoTimeout, NULL, |
188 press_escape_en_route); | 187 press_escape_en_route); |
189 } | 188 } |
190 | 189 |
191 bool BrowserProxy::SimulateDragWithTimeout(const POINT& start, | 190 bool BrowserProxy::SimulateDragWithTimeout(const gfx::Point& start, |
192 const POINT& end, | 191 const gfx::Point& end, |
193 int flags, | 192 int flags, |
194 uint32 timeout_ms, | 193 uint32 timeout_ms, |
195 bool* is_timeout, | 194 bool* is_timeout, |
196 bool press_escape_en_route) { | 195 bool press_escape_en_route) { |
197 if (!is_valid()) | 196 if (!is_valid()) |
198 return false; | 197 return false; |
199 | 198 |
200 std::vector<POINT> drag_path; | 199 std::vector<gfx::Point> drag_path; |
201 drag_path.push_back(start); | 200 drag_path.push_back(start); |
202 drag_path.push_back(end); | 201 drag_path.push_back(end); |
203 | 202 |
204 bool result = false; | 203 bool result = false; |
205 | 204 |
206 sender_->SendWithTimeout(new AutomationMsg_WindowDrag( | 205 sender_->SendWithTimeout(new AutomationMsg_WindowDrag( |
207 0, handle_, drag_path, flags, press_escape_en_route, &result), | 206 0, handle_, drag_path, flags, press_escape_en_route, &result), |
208 timeout_ms, is_timeout); | 207 timeout_ms, is_timeout); |
209 | 208 |
210 return result; | 209 return result; |
211 } | 210 } |
212 #endif // defined(OS_WIN) | |
213 | 211 |
214 bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) { | 212 bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) { |
215 const TimeTicks start = TimeTicks::Now(); | 213 const TimeTicks start = TimeTicks::Now(); |
216 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); | 214 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); |
217 while (TimeTicks::Now() - start < timeout) { | 215 while (TimeTicks::Now() - start < timeout) { |
218 PlatformThread::Sleep(automation::kSleepTime); | 216 PlatformThread::Sleep(automation::kSleepTime); |
219 bool is_timeout; | 217 bool is_timeout; |
220 int new_count; | 218 int new_count; |
221 bool succeeded = GetTabCountWithTimeout(&new_count, wait_timeout, | 219 bool succeeded = GetTabCountWithTimeout(&new_count, wait_timeout, |
222 &is_timeout); | 220 &is_timeout); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 263 |
266 if (!is_visible) { | 264 if (!is_visible) { |
267 NOTREACHED(); | 265 NOTREACHED(); |
268 return false; | 266 return false; |
269 } | 267 } |
270 | 268 |
271 return sender_->Send( | 269 return sender_->Send( |
272 new AutomationMsg_FindWindowVisibility(0, handle_, is_visible)); | 270 new AutomationMsg_FindWindowVisibility(0, handle_, is_visible)); |
273 } | 271 } |
274 | 272 |
275 #if defined(OS_WIN) | |
276 // TODO(port): Replace HWND. | |
277 bool BrowserProxy::GetHWND(HWND* handle) const { | |
278 if (!is_valid()) | |
279 return false; | |
280 | |
281 if (!handle) { | |
282 NOTREACHED(); | |
283 return false; | |
284 } | |
285 | |
286 return sender_->Send(new AutomationMsg_WindowHWND(0, handle_, handle)); | |
287 } | |
288 #endif // defined(OS_WIN) | |
289 | |
290 bool BrowserProxy::RunCommandAsync(int browser_command) const { | 273 bool BrowserProxy::RunCommandAsync(int browser_command) const { |
291 if (!is_valid()) | 274 if (!is_valid()) |
292 return false; | 275 return false; |
293 | 276 |
294 bool result = false; | 277 bool result = false; |
295 | 278 |
296 sender_->Send(new AutomationMsg_WindowExecuteCommandAsync(0, handle_, | 279 sender_->Send(new AutomationMsg_WindowExecuteCommandAsync(0, handle_, |
297 browser_command, | 280 browser_command, |
298 &result)); | 281 &result)); |
299 | 282 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (!is_valid()) | 371 if (!is_valid()) |
389 return false; | 372 return false; |
390 | 373 |
391 bool result = false; | 374 bool result = false; |
392 | 375 |
393 sender_->Send(new AutomationMsg_SetBooleanPreference(0, handle_, name, | 376 sender_->Send(new AutomationMsg_SetBooleanPreference(0, handle_, name, |
394 value, &result)); | 377 value, &result)); |
395 return result; | 378 return result; |
396 } | 379 } |
397 | 380 |
| 381 bool BrowserProxy::TerminateSession() { |
| 382 if (!is_valid()) |
| 383 return false; |
| 384 |
| 385 bool result = false; |
| 386 |
| 387 sender_->Send(new AutomationMsg_TerminateSession(0, handle_, &result)); |
| 388 |
| 389 return result; |
| 390 } |
| 391 |
398 scoped_refptr<WindowProxy> BrowserProxy::GetWindow() const { | 392 scoped_refptr<WindowProxy> BrowserProxy::GetWindow() const { |
399 if (!is_valid()) | 393 if (!is_valid()) |
400 return NULL; | 394 return NULL; |
401 | 395 |
402 bool handle_ok = false; | 396 bool handle_ok = false; |
403 int window_handle = 0; | 397 int window_handle = 0; |
404 | 398 |
405 sender_->Send(new AutomationMsg_WindowForBrowser(0, handle_, &handle_ok, | 399 sender_->Send(new AutomationMsg_WindowForBrowser(0, handle_, &handle_ok, |
406 &window_handle)); | 400 &window_handle)); |
407 if (!handle_ok) | 401 if (!handle_ok) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 if (!p) { | 433 if (!p) { |
440 p = new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle); | 434 p = new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle); |
441 p->AddRef(); | 435 p->AddRef(); |
442 } | 436 } |
443 | 437 |
444 // Since there is no scoped_refptr::attach. | 438 // Since there is no scoped_refptr::attach. |
445 scoped_refptr<AutocompleteEditProxy> result; | 439 scoped_refptr<AutocompleteEditProxy> result; |
446 result.swap(&p); | 440 result.swap(&p); |
447 return result; | 441 return result; |
448 } | 442 } |
OLD | NEW |