OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tab_proxy.h" | 5 #include "chrome/test/automation/tab_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/threading/platform_thread.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/common/automation_messages.h" | 13 #include "chrome/common/automation_messages.h" |
13 #include "chrome/common/json_value_serializer.h" | 14 #include "chrome/common/json_value_serializer.h" |
14 #include "chrome/test/automation/automation_proxy.h" | 15 #include "chrome/test/automation/automation_proxy.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 | 17 |
17 TabProxy::TabProxy(AutomationMessageSender* sender, | 18 TabProxy::TabProxy(AutomationMessageSender* sender, |
18 AutomationHandleTracker* tracker, | 19 AutomationHandleTracker* tracker, |
19 int handle) | 20 int handle) |
20 : AutomationResourceProxy(tracker, sender, handle) { | 21 : AutomationResourceProxy(tracker, sender, handle) { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 357 } |
357 | 358 |
358 return sender_->Send(new AutomationMsg_ConstrainedWindowCount( | 359 return sender_->Send(new AutomationMsg_ConstrainedWindowCount( |
359 handle_, count)); | 360 handle_, count)); |
360 } | 361 } |
361 | 362 |
362 bool TabProxy::WaitForChildWindowCountToChange(int count, int* new_count, | 363 bool TabProxy::WaitForChildWindowCountToChange(int count, int* new_count, |
363 int wait_timeout) { | 364 int wait_timeout) { |
364 int intervals = std::max(wait_timeout / automation::kSleepTime, 1); | 365 int intervals = std::max(wait_timeout / automation::kSleepTime, 1); |
365 for (int i = 0; i < intervals; ++i) { | 366 for (int i = 0; i < intervals; ++i) { |
366 PlatformThread::Sleep(automation::kSleepTime); | 367 base::PlatformThread::Sleep(automation::kSleepTime); |
367 bool succeeded = GetConstrainedWindowCount(new_count); | 368 bool succeeded = GetConstrainedWindowCount(new_count); |
368 if (!succeeded) | 369 if (!succeeded) |
369 return false; | 370 return false; |
370 if (count != *new_count) | 371 if (count != *new_count) |
371 return true; | 372 return true; |
372 } | 373 } |
373 // Constrained Window count did not change, return false. | 374 // Constrained Window count did not change, return false. |
374 return false; | 375 return false; |
375 } | 376 } |
376 | 377 |
377 bool TabProxy::GetBlockedPopupCount(int* count) const { | 378 bool TabProxy::GetBlockedPopupCount(int* count) const { |
378 if (!is_valid()) | 379 if (!is_valid()) |
379 return false; | 380 return false; |
380 | 381 |
381 if (!count) { | 382 if (!count) { |
382 NOTREACHED(); | 383 NOTREACHED(); |
383 return false; | 384 return false; |
384 } | 385 } |
385 | 386 |
386 return sender_->Send(new AutomationMsg_BlockedPopupCount( | 387 return sender_->Send(new AutomationMsg_BlockedPopupCount( |
387 handle_, count)); | 388 handle_, count)); |
388 } | 389 } |
389 | 390 |
390 bool TabProxy::WaitForBlockedPopupCountToChangeTo(int target_count, | 391 bool TabProxy::WaitForBlockedPopupCountToChangeTo(int target_count, |
391 int wait_timeout) { | 392 int wait_timeout) { |
392 int intervals = std::max(wait_timeout / automation::kSleepTime, 1); | 393 int intervals = std::max(wait_timeout / automation::kSleepTime, 1); |
393 for (int i = 0; i < intervals; ++i) { | 394 for (int i = 0; i < intervals; ++i) { |
394 PlatformThread::Sleep(automation::kSleepTime); | 395 base::PlatformThread::Sleep(automation::kSleepTime); |
395 int new_count = -1; | 396 int new_count = -1; |
396 bool succeeded = GetBlockedPopupCount(&new_count); | 397 bool succeeded = GetBlockedPopupCount(&new_count); |
397 if (!succeeded) | 398 if (!succeeded) |
398 return false; | 399 return false; |
399 if (target_count == new_count) | 400 if (target_count == new_count) |
400 return true; | 401 return true; |
401 } | 402 } |
402 // Constrained Window count did not change, return false. | 403 // Constrained Window count did not change, return false. |
403 return false; | 404 return false; |
404 } | 405 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 json)); | 818 json)); |
818 } | 819 } |
819 | 820 |
820 void TabProxy::FirstObjectAdded() { | 821 void TabProxy::FirstObjectAdded() { |
821 AddRef(); | 822 AddRef(); |
822 } | 823 } |
823 | 824 |
824 void TabProxy::LastObjectRemoved() { | 825 void TabProxy::LastObjectRemoved() { |
825 Release(); | 826 Release(); |
826 } | 827 } |
OLD | NEW |