| 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/window_proxy.h" | 5 #include "chrome/test/automation/window_proxy.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "chrome/test/automation/automation_constants.h" | 12 #include "chrome/test/automation/automation_constants.h" |
| 13 #include "chrome/test/automation/automation_messages.h" | 13 #include "chrome/test/automation/automation_messages.h" |
| 14 #include "chrome/test/automation/automation_proxy.h" | 14 #include "chrome/test/automation/automation_proxy.h" |
| 15 #include "chrome/test/automation/browser_proxy.h" | 15 #include "chrome/test/automation/browser_proxy.h" |
| 16 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 | 18 |
| 19 #if defined(OS_WIN) | |
| 20 bool WindowProxy::GetHWND(HWND* handle) const { | |
| 21 if (!is_valid()) return false; | |
| 22 | |
| 23 if (!handle) { | |
| 24 NOTREACHED(); | |
| 25 return false; | |
| 26 } | |
| 27 | |
| 28 return sender_->Send(new AutomationMsg_WindowHWND(0, handle_, handle)); | |
| 29 } | |
| 30 #endif // defined(OS_WIN) | |
| 31 | |
| 32 bool WindowProxy::SimulateOSClick(const gfx::Point& click, int flags) { | 19 bool WindowProxy::SimulateOSClick(const gfx::Point& click, int flags) { |
| 33 if (!is_valid()) return false; | 20 if (!is_valid()) return false; |
| 34 | 21 |
| 35 return sender_->Send( | 22 return sender_->Send( |
| 36 new AutomationMsg_WindowClick(0, handle_, click, flags)); | 23 new AutomationMsg_WindowClick(0, handle_, click, flags)); |
| 37 } | 24 } |
| 38 | 25 |
| 39 bool WindowProxy::GetWindowTitle(string16* text) { | 26 bool WindowProxy::GetWindowTitle(string16* text) { |
| 40 if (!is_valid()) return false; | 27 if (!is_valid()) return false; |
| 41 | 28 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 86 |
| 100 bool result = false; | 87 bool result = false; |
| 101 | 88 |
| 102 sender_->SendWithTimeout(new AutomationMsg_WindowViewBounds( | 89 sender_->SendWithTimeout(new AutomationMsg_WindowViewBounds( |
| 103 0, handle_, view_id, screen_coordinates, &result, bounds), | 90 0, handle_, view_id, screen_coordinates, &result, bounds), |
| 104 timeout_ms, is_timeout); | 91 timeout_ms, is_timeout); |
| 105 | 92 |
| 106 return result; | 93 return result; |
| 107 } | 94 } |
| 108 | 95 |
| 96 bool WindowProxy::GetBounds(gfx::Rect* bounds) { |
| 97 if (!is_valid()) |
| 98 return false; |
| 99 bool result = false; |
| 100 sender_->Send(new AutomationMsg_GetWindowBounds(0, handle_, bounds, |
| 101 &result)); |
| 102 return result; |
| 103 } |
| 104 |
| 109 bool WindowProxy::SetBounds(const gfx::Rect& bounds) { | 105 bool WindowProxy::SetBounds(const gfx::Rect& bounds) { |
| 110 if (!is_valid()) | 106 if (!is_valid()) |
| 111 return false; | 107 return false; |
| 112 bool result = false; | 108 bool result = false; |
| 113 sender_->Send(new AutomationMsg_SetWindowBounds(0, handle_, bounds, | 109 sender_->Send(new AutomationMsg_SetWindowBounds(0, handle_, bounds, |
| 114 &result)); | 110 &result)); |
| 115 return result; | 111 return result; |
| 116 } | 112 } |
| 117 | 113 |
| 118 bool WindowProxy::GetFocusedViewID(int* view_id) { | 114 bool WindowProxy::GetFocusedViewID(int* view_id) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 149 if (!browser) { | 145 if (!browser) { |
| 150 browser = new BrowserProxy(sender_, tracker_, browser_handle); | 146 browser = new BrowserProxy(sender_, tracker_, browser_handle); |
| 151 browser->AddRef(); | 147 browser->AddRef(); |
| 152 } | 148 } |
| 153 | 149 |
| 154 // Since there is no scoped_refptr::attach. | 150 // Since there is no scoped_refptr::attach. |
| 155 scoped_refptr<BrowserProxy> result; | 151 scoped_refptr<BrowserProxy> result; |
| 156 result.swap(&browser); | 152 result.swap(&browser); |
| 157 return result; | 153 return result; |
| 158 } | 154 } |
| 155 |
| 156 bool WindowProxy::IsMaximized(bool* maximized) { |
| 157 if (!is_valid()) |
| 158 return false; |
| 159 |
| 160 bool result = false; |
| 161 |
| 162 sender_->Send(new AutomationMsg_IsWindowMaximized(0, handle_, maximized, |
| 163 &result)); |
| 164 return result; |
| 165 } |
| OLD | NEW |