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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "chrome/test/automation/automation_proxy.h" | 7 #include "chrome/test/automation/automation_proxy.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 command_execution_timeout_ms(), NULL); | 292 command_execution_timeout_ms(), NULL); |
293 | 293 |
294 if (!succeeded) { | 294 if (!succeeded) { |
295 DLOG(ERROR) << "GetWindowCount did not complete in a timely fashion"; | 295 DLOG(ERROR) << "GetWindowCount did not complete in a timely fashion"; |
296 return false; | 296 return false; |
297 } | 297 } |
298 | 298 |
299 return succeeded; | 299 return succeeded; |
300 } | 300 } |
301 | 301 |
| 302 bool AutomationProxy::GetNormalBrowserWindowCount(int* num_windows) { |
| 303 if (!num_windows) { |
| 304 NOTREACHED(); |
| 305 return false; |
| 306 } |
| 307 |
| 308 bool succeeded = SendWithTimeout( |
| 309 new AutomationMsg_NormalBrowserWindowCount(0, num_windows), |
| 310 command_execution_timeout_ms(), NULL); |
| 311 |
| 312 if (!succeeded) { |
| 313 DLOG(ERROR) << "GetNormalWindowCount did not complete in a timely fashion"; |
| 314 return false; |
| 315 } |
| 316 |
| 317 return succeeded; |
| 318 } |
| 319 |
302 bool AutomationProxy::WaitForWindowCountToBecome(int count, | 320 bool AutomationProxy::WaitForWindowCountToBecome(int count, |
303 int wait_timeout) { | 321 int wait_timeout) { |
304 const TimeTicks start = TimeTicks::Now(); | 322 const TimeTicks start = TimeTicks::Now(); |
305 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); | 323 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); |
306 while (TimeTicks::Now() - start < timeout) { | 324 while (TimeTicks::Now() - start < timeout) { |
307 int new_count; | 325 int new_count; |
308 bool succeeded = GetBrowserWindowCount(&new_count); | 326 bool succeeded = GetBrowserWindowCount(&new_count); |
309 if (!succeeded) { | 327 if (!succeeded) { |
310 // Try again next round, but log it. | 328 // Try again next round, but log it. |
311 DLOG(ERROR) << "GetBrowserWindowCount returned false"; | 329 DLOG(ERROR) << "GetBrowserWindowCount returned false"; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 int handle = 0; | 449 int handle = 0; |
432 | 450 |
433 if (!SendWithTimeout(new AutomationMsg_ActiveWindow(0, &handle), | 451 if (!SendWithTimeout(new AutomationMsg_ActiveWindow(0, &handle), |
434 command_execution_timeout_ms(), NULL)) { | 452 command_execution_timeout_ms(), NULL)) { |
435 return NULL; | 453 return NULL; |
436 } | 454 } |
437 | 455 |
438 return new WindowProxy(this, tracker_.get(), handle); | 456 return new WindowProxy(this, tracker_.get(), handle); |
439 } | 457 } |
440 | 458 |
441 | |
442 BrowserProxy* AutomationProxy::GetBrowserWindow(int window_index) { | 459 BrowserProxy* AutomationProxy::GetBrowserWindow(int window_index) { |
443 int handle = 0; | 460 int handle = 0; |
444 | 461 |
445 if (!SendWithTimeout(new AutomationMsg_BrowserWindow(0, window_index, | 462 if (!SendWithTimeout(new AutomationMsg_BrowserWindow(0, window_index, |
446 &handle), | 463 &handle), |
447 command_execution_timeout_ms(), NULL)) { | 464 command_execution_timeout_ms(), NULL)) { |
448 DLOG(ERROR) << "GetBrowserWindow did not complete in a timely fashion"; | 465 DLOG(ERROR) << "GetBrowserWindow did not complete in a timely fashion"; |
449 return NULL; | 466 return NULL; |
450 } | 467 } |
451 | 468 |
452 if (handle == 0) { | 469 if (handle == 0) { |
453 return NULL; | 470 return NULL; |
454 } | 471 } |
455 | 472 |
456 return new BrowserProxy(this, tracker_.get(), handle); | 473 return new BrowserProxy(this, tracker_.get(), handle); |
457 } | 474 } |
458 | 475 |
| 476 BrowserProxy* AutomationProxy::FindNormalBrowserWindow() { |
| 477 int handle = 0; |
| 478 |
| 479 if (!SendWithTimeout(new AutomationMsg_FindNormalBrowserWindow(0, &handle), |
| 480 command_execution_timeout_ms(), NULL)) { |
| 481 return NULL; |
| 482 } |
| 483 |
| 484 if (handle == 0) { |
| 485 return NULL; |
| 486 } |
| 487 |
| 488 return new BrowserProxy(this, tracker_.get(), handle); |
| 489 } |
| 490 |
459 BrowserProxy* AutomationProxy::GetLastActiveBrowserWindow() { | 491 BrowserProxy* AutomationProxy::GetLastActiveBrowserWindow() { |
460 int handle = 0; | 492 int handle = 0; |
461 | 493 |
462 if (!SendWithTimeout(new AutomationMsg_LastActiveBrowserWindow( | 494 if (!SendWithTimeout(new AutomationMsg_LastActiveBrowserWindow( |
463 0, &handle), command_execution_timeout_ms(), NULL)) { | 495 0, &handle), command_execution_timeout_ms(), NULL)) { |
464 DLOG(ERROR) << | 496 DLOG(ERROR) << |
465 "GetLastActiveBrowserWindow did not complete in a timely fashion"; | 497 "GetLastActiveBrowserWindow did not complete in a timely fashion"; |
466 return NULL; | 498 return NULL; |
467 } | 499 } |
468 | 500 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 &handle)); | 563 &handle)); |
532 if (!succeeded) { | 564 if (!succeeded) { |
533 return NULL; | 565 return NULL; |
534 } | 566 } |
535 | 567 |
536 DCHECK(IsWindow(*external_tab_container)); | 568 DCHECK(IsWindow(*external_tab_container)); |
537 | 569 |
538 return new TabProxy(this, tracker_.get(), handle); | 570 return new TabProxy(this, tracker_.get(), handle); |
539 } | 571 } |
540 #endif // defined(OS_WIN) | 572 #endif // defined(OS_WIN) |
OLD | NEW |