| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } else if (dialog_shown) { | 336 } else if (dialog_shown) { |
| 337 return true; | 337 return true; |
| 338 } | 338 } |
| 339 Sleep(automation::kSleepTime); | 339 Sleep(automation::kSleepTime); |
| 340 } | 340 } |
| 341 // Dialog never shown. | 341 // Dialog never shown. |
| 342 return false; | 342 return false; |
| 343 } | 343 } |
| 344 #endif // defined(OS_WIN) | 344 #endif // defined(OS_WIN) |
| 345 | 345 |
| 346 bool AutomationProxy::WaitForURLDisplayed(GURL url, int wait_timeout) { |
| 347 const TimeTicks start = TimeTicks::Now(); |
| 348 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); |
| 349 while (TimeTicks::Now() - start < timeout) { |
| 350 int window_count; |
| 351 if (!GetBrowserWindowCount(&window_count)) |
| 352 return false; |
| 353 |
| 354 for (int i = 0; i < window_count; i++) { |
| 355 BrowserProxy* window = GetBrowserWindow(i); |
| 356 if (!window) |
| 357 break; |
| 358 |
| 359 int tab_count; |
| 360 if (!window->GetTabCount(&tab_count)) |
| 361 continue; |
| 362 |
| 363 for (int j = 0; j < tab_count; j++) { |
| 364 TabProxy* tab = window->GetTab(j); |
| 365 if (!tab) |
| 366 break; |
| 367 |
| 368 GURL tab_url; |
| 369 if (!tab->GetCurrentURL(&tab_url)) |
| 370 continue; |
| 371 |
| 372 if (tab_url == url) |
| 373 return true; |
| 374 } |
| 375 } |
| 376 PlatformThread::Sleep(automation::kSleepTime); |
| 377 } |
| 378 |
| 379 return false; |
| 380 } |
| 381 |
| 346 bool AutomationProxy::SetFilteredInet(bool enabled) { | 382 bool AutomationProxy::SetFilteredInet(bool enabled) { |
| 347 return Send(new AutomationMsg_SetFilteredInet(0, enabled)); | 383 return Send(new AutomationMsg_SetFilteredInet(0, enabled)); |
| 348 } | 384 } |
| 349 | 385 |
| 350 void AutomationProxy::Disconnect() { | 386 void AutomationProxy::Disconnect() { |
| 351 channel_.reset(); | 387 channel_.reset(); |
| 352 } | 388 } |
| 353 | 389 |
| 354 void AutomationProxy::OnMessageReceived(const IPC::Message& msg) { | 390 void AutomationProxy::OnMessageReceived(const IPC::Message& msg) { |
| 355 // This won't get called unless AutomationProxy is run from | 391 // This won't get called unless AutomationProxy is run from |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 &handle)); | 498 &handle)); |
| 463 if (!succeeded) { | 499 if (!succeeded) { |
| 464 return NULL; | 500 return NULL; |
| 465 } | 501 } |
| 466 | 502 |
| 467 DCHECK(IsWindow(*external_tab_container)); | 503 DCHECK(IsWindow(*external_tab_container)); |
| 468 | 504 |
| 469 return new TabProxy(this, tracker_.get(), handle); | 505 return new TabProxy(this, tracker_.get(), handle); |
| 470 } | 506 } |
| 471 #endif // defined(OS_WIN) | 507 #endif // defined(OS_WIN) |
| OLD | NEW |