Chromium Code Reviews| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 DLOG(ERROR) << "GetBrowserWindowCount returned false"; | 295 DLOG(ERROR) << "GetBrowserWindowCount returned false"; |
| 296 } else if (count == new_count) { | 296 } else if (count == new_count) { |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 Sleep(automation::kSleepTime); | 299 Sleep(automation::kSleepTime); |
| 300 } | 300 } |
| 301 // Window count never reached the value we sought. | 301 // Window count never reached the value we sought. |
| 302 return false; | 302 return false; |
| 303 } | 303 } |
| 304 | 304 |
| 305 bool AutomationProxy::GetShowingAppModalDialog(bool* showing_app_modal_dialog) { | |
| 306 if (!showing_app_modal_dialog) { | |
| 307 NOTREACHED(); | |
| 308 return false; | |
| 309 } | |
| 310 | |
| 311 IPC::Message* response = NULL; | |
| 312 bool is_timeout = true; | |
| 313 bool succeeded = SendAndWaitForResponseWithTimeout( | |
| 314 new AutomationMsg_ShowingAppModalDialogRequest(0), &response, | |
| 315 AutomationMsg_ShowingAppModalDialogResponse::ID, | |
| 316 kMaxCommandExecutionTime, &is_timeout); | |
| 317 if (!succeeded) | |
| 318 return false; | |
| 319 | |
| 320 if (is_timeout) { | |
| 321 DLOG(ERROR) << "ShowingAppModalDialog did not complete in a timely fashion"; | |
| 322 return false; | |
| 323 } | |
| 324 | |
| 325 void* iter = NULL; | |
| 326 if (!response->ReadBool(&iter, showing_app_modal_dialog)) { | |
| 327 succeeded = false; | |
| 328 } | |
| 329 | |
| 330 delete response; | |
| 331 return succeeded; | |
| 332 } | |
| 333 | |
| 334 bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) { | |
| 335 const TimeTicks start = TimeTicks::Now(); | |
| 336 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); | |
| 337 while (TimeTicks::Now() - start < timeout) { | |
| 338 bool dialog_shown; | |
|
Finnur
2008/11/11 07:30:03
For good measure I would initialize this to false.
| |
| 339 bool succeeded = GetShowingAppModalDialog(&dialog_shown); | |
| 340 if (!succeeded) { | |
| 341 // Try again next round, but log it. | |
| 342 DLOG(ERROR) << "GetBrowserWindowCount returned false"; | |
| 343 } else if (dialog_shown) { | |
| 344 return true; | |
| 345 } | |
| 346 Sleep(automation::kSleepTime); | |
| 347 } | |
| 348 // Dialog never shown. | |
| 349 return false; | |
| 350 } | |
| 351 | |
| 305 bool AutomationProxy::SetFilteredInet(bool enabled) { | 352 bool AutomationProxy::SetFilteredInet(bool enabled) { |
| 306 return Send(new AutomationMsg_SetFilteredInet(0, enabled)); | 353 return Send(new AutomationMsg_SetFilteredInet(0, enabled)); |
| 307 } | 354 } |
| 308 | 355 |
| 309 void AutomationProxy::Disconnect() { | 356 void AutomationProxy::Disconnect() { |
| 310 channel_.reset(); | 357 channel_.reset(); |
| 311 } | 358 } |
| 312 | 359 |
| 313 void AutomationProxy::OnMessageReceived(const IPC::Message& msg) { | 360 void AutomationProxy::OnMessageReceived(const IPC::Message& msg) { |
| 314 // This won't get called unless AutomationProxy is run from | 361 // This won't get called unless AutomationProxy is run from |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 (handle >= 0)) { | 599 (handle >= 0)) { |
| 553 succeeded = true; | 600 succeeded = true; |
| 554 tab_proxy = new TabProxy(this, tracker_.get(), handle); | 601 tab_proxy = new TabProxy(this, tracker_.get(), handle); |
| 555 } | 602 } |
| 556 } else { | 603 } else { |
| 557 succeeded = false; | 604 succeeded = false; |
| 558 } | 605 } |
| 559 delete response; | 606 delete response; |
| 560 return tab_proxy; | 607 return tab_proxy; |
| 561 } | 608 } |
| OLD | NEW |