| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 &is_timeout); | 279 &is_timeout); |
| 280 if (!succeeded) | 280 if (!succeeded) |
| 281 return false; | 281 return false; |
| 282 if (count != *new_count) | 282 if (count != *new_count) |
| 283 return true; | 283 return true; |
| 284 } | 284 } |
| 285 // If we get here, the tab count hasn't changed. | 285 // If we get here, the tab count hasn't changed. |
| 286 return false; | 286 return false; |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) { |
| 290 const TimeTicks start = TimeTicks::Now(); |
| 291 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); |
| 292 while (TimeTicks::Now() - start < timeout) { |
| 293 Sleep(automation::kSleepTime); |
| 294 bool is_timeout; |
| 295 int new_count; |
| 296 bool succeeded = GetTabCountWithTimeout(&new_count, wait_timeout, |
| 297 &is_timeout); |
| 298 if (!succeeded) |
| 299 return false; |
| 300 if (count == new_count) |
| 301 return true; |
| 302 } |
| 303 // If we get here, the tab count doesn't match. |
| 304 return false; |
| 305 } |
| 306 |
| 289 bool BrowserProxy::WaitForTabToBecomeActive(int tab, | 307 bool BrowserProxy::WaitForTabToBecomeActive(int tab, |
| 290 int wait_timeout) { | 308 int wait_timeout) { |
| 291 const TimeTicks start = TimeTicks::Now(); | 309 const TimeTicks start = TimeTicks::Now(); |
| 292 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); | 310 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); |
| 293 while (TimeTicks::Now() - start < timeout) { | 311 while (TimeTicks::Now() - start < timeout) { |
| 294 Sleep(automation::kSleepTime); | 312 Sleep(automation::kSleepTime); |
| 295 int active_tab; | 313 int active_tab; |
| 296 if (GetActiveTabIndex(&active_tab) && active_tab == tab) | 314 if (GetActiveTabIndex(&active_tab) && active_tab == tab) |
| 297 return true; | 315 return true; |
| 298 } | 316 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. | 406 scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. |
| 389 if (!success) | 407 if (!success) |
| 390 return false; | 408 return false; |
| 391 | 409 |
| 392 if (AutomationMsg_SetIntPreferenceResponse::Read(response, &success)) | 410 if (AutomationMsg_SetIntPreferenceResponse::Read(response, &success)) |
| 393 return success; | 411 return success; |
| 394 | 412 |
| 395 // We failed to deserialize the returned value. | 413 // We failed to deserialize the returned value. |
| 396 return false; | 414 return false; |
| 397 } | 415 } |
| OLD | NEW |