| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "chrome/common/automation_constants.h" | 14 #include "chrome/common/automation_constants.h" |
| 15 #include "chrome/common/automation_messages.h" | 15 #include "chrome/common/automation_messages.h" |
| 16 #include "chrome/test/automation/autocomplete_edit_proxy.h" | |
| 17 #include "chrome/test/automation/automation_proxy.h" | 16 #include "chrome/test/automation/automation_proxy.h" |
| 18 #include "chrome/test/automation/tab_proxy.h" | 17 #include "chrome/test/automation/tab_proxy.h" |
| 19 #include "chrome/test/automation/window_proxy.h" | 18 #include "chrome/test/automation/window_proxy.h" |
| 20 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
| 21 | 20 |
| 22 using base::TimeDelta; | 21 using base::TimeDelta; |
| 23 using base::TimeTicks; | 22 using base::TimeTicks; |
| 24 | 23 |
| 25 | |
| 26 bool BrowserProxy::ActivateTab(int tab_index) { | 24 bool BrowserProxy::ActivateTab(int tab_index) { |
| 27 if (!is_valid()) | 25 if (!is_valid()) |
| 28 return false; | 26 return false; |
| 29 | 27 |
| 30 int activate_tab_response = -1; | 28 int activate_tab_response = -1; |
| 31 | 29 |
| 32 if (!sender_->Send(new AutomationMsg_ActivateTab( | 30 if (!sender_->Send(new AutomationMsg_ActivateTab( |
| 33 handle_, tab_index, &activate_tab_response))) { | 31 handle_, tab_index, &activate_tab_response))) { |
| 34 return false; | 32 return false; |
| 35 } | 33 } |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 window = new WindowProxy(sender_, tracker_, window_handle); | 501 window = new WindowProxy(sender_, tracker_, window_handle); |
| 504 window->AddRef(); | 502 window->AddRef(); |
| 505 } | 503 } |
| 506 | 504 |
| 507 // Since there is no scoped_refptr::attach. | 505 // Since there is no scoped_refptr::attach. |
| 508 scoped_refptr<WindowProxy> result; | 506 scoped_refptr<WindowProxy> result; |
| 509 result.swap(&window); | 507 result.swap(&window); |
| 510 return result; | 508 return result; |
| 511 } | 509 } |
| 512 | 510 |
| 513 scoped_refptr<AutocompleteEditProxy> BrowserProxy::GetAutocompleteEdit() { | |
| 514 if (!is_valid()) | |
| 515 return NULL; | |
| 516 | |
| 517 bool handle_ok = false; | |
| 518 int autocomplete_edit_handle = 0; | |
| 519 | |
| 520 sender_->Send(new AutomationMsg_AutocompleteEditForBrowser( | |
| 521 handle_, &handle_ok, &autocomplete_edit_handle)); | |
| 522 | |
| 523 if (!handle_ok) | |
| 524 return NULL; | |
| 525 | |
| 526 AutocompleteEditProxy* p = static_cast<AutocompleteEditProxy*>( | |
| 527 tracker_->GetResource(autocomplete_edit_handle)); | |
| 528 | |
| 529 if (!p) { | |
| 530 p = new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle); | |
| 531 p->AddRef(); | |
| 532 } | |
| 533 | |
| 534 // Since there is no scoped_refptr::attach. | |
| 535 scoped_refptr<AutocompleteEditProxy> result; | |
| 536 result.swap(&p); | |
| 537 return result; | |
| 538 } | |
| 539 | |
| 540 bool BrowserProxy::IsFullscreen(bool* is_fullscreen) { | 511 bool BrowserProxy::IsFullscreen(bool* is_fullscreen) { |
| 541 DCHECK(is_fullscreen); | 512 DCHECK(is_fullscreen); |
| 542 | 513 |
| 543 if (!is_valid()) | 514 if (!is_valid()) |
| 544 return false; | 515 return false; |
| 545 | 516 |
| 546 return sender_->Send(new AutomationMsg_IsFullscreen(handle_, is_fullscreen)); | 517 return sender_->Send(new AutomationMsg_IsFullscreen(handle_, is_fullscreen)); |
| 547 } | 518 } |
| 548 | 519 |
| 549 bool BrowserProxy::IsFullscreenBubbleVisible(bool* is_visible) { | 520 bool BrowserProxy::IsFullscreenBubbleVisible(bool* is_visible) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 if (i == 0) | 632 if (i == 0) |
| 662 *min_start_time = start_ms; | 633 *min_start_time = start_ms; |
| 663 | 634 |
| 664 *min_start_time = std::min(start_ms, *min_start_time); | 635 *min_start_time = std::min(start_ms, *min_start_time); |
| 665 *max_stop_time = std::max(stop_ms, *max_stop_time); | 636 *max_stop_time = std::max(stop_ms, *max_stop_time); |
| 666 stop_times->push_back(stop_ms); | 637 stop_times->push_back(stop_ms); |
| 667 } | 638 } |
| 668 std::sort(stop_times->begin(), stop_times->end()); | 639 std::sort(stop_times->begin(), stop_times->end()); |
| 669 return true; | 640 return true; |
| 670 } | 641 } |
| OLD | NEW |