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 #ifndef CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_ |
6 #define CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_ | 6 #define CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include <windows.h> | 11 #include <windows.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "chrome/test/automation/automation_handle_tracker.h" | 16 #include "chrome/test/automation/automation_handle_tracker.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 class TabProxy; | 19 class TabProxy; |
20 class WindowProxy; | 20 class WindowProxy; |
21 class AutocompleteEditProxy; | 21 class AutocompleteEditProxy; |
22 | 22 |
23 namespace gfx { | 23 namespace gfx { |
24 class Point; | |
24 class Rect; | 25 class Rect; |
25 } | 26 } |
26 | 27 |
27 // This class presents the interface to actions that can be performed on | 28 // This class presents the interface to actions that can be performed on |
28 // a given browser window. Note that this object can be invalidated at any | 29 // a given browser window. Note that this object can be invalidated at any |
29 // time if the corresponding browser window in the app is closed. In that case, | 30 // time if the corresponding browser window in the app is closed. In that case, |
30 // any subsequent calls will return false immediately. | 31 // any subsequent calls will return false immediately. |
31 class BrowserProxy : public AutomationResourceProxy { | 32 class BrowserProxy : public AutomationResourceProxy { |
32 public: | 33 public: |
33 BrowserProxy(AutomationMessageSender* sender, | 34 BrowserProxy(AutomationMessageSender* sender, |
(...skipping 81 matching lines...) Loading... | |
115 // Returns true if the call was successful. | 116 // Returns true if the call was successful. |
116 // | 117 // |
117 // The alternate way to test the accelerators is to use the Windows messaging | 118 // The alternate way to test the accelerators is to use the Windows messaging |
118 // system to send the actual keyboard events (ui_controls.h) A precondition | 119 // system to send the actual keyboard events (ui_controls.h) A precondition |
119 // to using this system is that the target window should have the keyboard | 120 // to using this system is that the target window should have the keyboard |
120 // focus. This leads to a flaky test behavior in circumstances when the | 121 // focus. This leads to a flaky test behavior in circumstances when the |
121 // desktop screen is locked or the test is being executed over a remote | 122 // desktop screen is locked or the test is being executed over a remote |
122 // desktop. | 123 // desktop. |
123 bool ApplyAccelerator(int id); | 124 bool ApplyAccelerator(int id); |
124 | 125 |
125 #if defined(OS_WIN) | |
126 // TODO(port): Use portable replacement for POINT. | |
127 | |
128 // Performs a drag operation between the start and end points (both defined | 126 // Performs a drag operation between the start and end points (both defined |
129 // in window coordinates). |flags| specifies which buttons are pressed for | 127 // in window coordinates). |flags| specifies which buttons are pressed for |
130 // the drag, as defined in chrome/views/event.h. | 128 // the drag, as defined in chrome/views/event.h. |
131 virtual bool SimulateDrag(const POINT& start, const POINT& end, int flags, | 129 virtual bool SimulateDrag(const gfx::Point& start, |
130 const gfx::Point& end, | |
131 int flags, | |
132 bool press_escape_en_route); | 132 bool press_escape_en_route); |
133 | 133 |
134 // Like SimulateDrag, but returns false if response is not received before | 134 // Like SimulateDrag, but returns false if response is not received before |
135 // the specified timeout. | 135 // the specified timeout. |
136 virtual bool SimulateDragWithTimeout(const POINT& start, const POINT& end, | 136 virtual bool SimulateDragWithTimeout(const gfx::Point& start, |
137 const gfx::Point& end, | |
137 int flags, uint32 timeout_ms, | 138 int flags, uint32 timeout_ms, |
138 bool* is_timeout, | 139 bool* is_timeout, |
139 bool press_escape_en_route); | 140 bool press_escape_en_route); |
140 #endif // defined(OS_WIN) | |
141 | 141 |
142 // Block the thread until the tab count is |count|. | 142 // Block the thread until the tab count is |count|. |
143 // |wait_timeout| is the timeout, in milliseconds, for waiting. | 143 // |wait_timeout| is the timeout, in milliseconds, for waiting. |
144 // Returns true on success. | 144 // Returns true on success. |
145 bool WaitForTabCountToBecome(int count, int wait_timeout); | 145 bool WaitForTabCountToBecome(int count, int wait_timeout); |
146 | 146 |
147 // Block the thread until the specified tab is the active tab. | 147 // Block the thread until the specified tab is the active tab. |
148 // |wait_timeout| is the timeout, in milliseconds, for waiting. | 148 // |wait_timeout| is the timeout, in milliseconds, for waiting. |
149 // Returns false if the tab does not become active. | 149 // Returns false if the tab does not become active. |
150 bool WaitForTabToBecomeActive(int tab, int wait_timeout); | 150 bool WaitForTabToBecomeActive(int tab, int wait_timeout); |
151 | 151 |
152 // Opens the FindInPage box. Note: If you just want to search within a tab | 152 // Opens the FindInPage box. Note: If you just want to search within a tab |
153 // you don't need to call this function, just use FindInPage(...) directly. | 153 // you don't need to call this function, just use FindInPage(...) directly. |
154 bool OpenFindInPage(); | 154 bool OpenFindInPage(); |
155 | 155 |
156 // Get the x, y coordinates for the Find window. If animating, |x| and |y| | 156 // Get the x, y coordinates for the Find window. If animating, |x| and |y| |
157 // will be -1, -1. Returns false on failure. | 157 // will be -1, -1. Returns false on failure. |
158 bool GetFindWindowLocation(int* x, int* y); | 158 bool GetFindWindowLocation(int* x, int* y); |
159 | 159 |
160 // Returns whether the Find window is fully visible If animating, |is_visible| | 160 // Returns whether the Find window is fully visible If animating, |is_visible| |
161 // will be false. Returns false on failure. | 161 // will be false. Returns false on failure. |
162 bool IsFindWindowFullyVisible(bool* is_visible); | 162 bool IsFindWindowFullyVisible(bool* is_visible); |
163 | 163 |
164 #if defined(OS_WIN) | |
165 // TODO(port): Use portable equivalent of HWND. | |
166 | |
167 // Gets the outermost HWND that corresponds to the given browser. | |
168 // Returns true if the call was successful. | |
169 // Note that ideally this should go and the version of WindowProxy should be | |
170 // used instead. We have to keep it for start_up_tests that test against a | |
171 // reference build. | |
172 bool GetHWND(HWND* handle) const; | |
173 #endif // defined(OS_WIN) | |
174 | |
175 // Run the specified command in the browser (see browser_commands.cc for the | 164 // Run the specified command in the browser (see browser_commands.cc for the |
176 // list of supported commands). Returns true if the command was successfully | 165 // list of supported commands). Returns true if the command was successfully |
177 // dispatched, false otherwise. | 166 // dispatched, false otherwise. |
178 bool RunCommandAsync(int browser_command) const; | 167 bool RunCommandAsync(int browser_command) const; |
179 | 168 |
180 // Run the specified command in the browser (see browser_commands.cc for the | 169 // Run the specified command in the browser (see browser_commands.cc for the |
181 // list of supported commands). Returns true if the command was successfully | 170 // list of supported commands). Returns true if the command was successfully |
182 // dispatched and executed, false otherwise. | 171 // dispatched and executed, false otherwise. |
183 bool RunCommand(int browser_command) const; | 172 bool RunCommand(int browser_command) const; |
184 | 173 |
(...skipping 14 matching lines...) Loading... | |
199 | 188 |
200 // Sets the string value of the specified preference. | 189 // Sets the string value of the specified preference. |
201 bool SetStringPreference(const std::wstring& name, const std::wstring& value); | 190 bool SetStringPreference(const std::wstring& name, const std::wstring& value); |
202 | 191 |
203 // Gets the boolean value of the specified preference. | 192 // Gets the boolean value of the specified preference. |
204 bool GetBooleanPreference(const std::wstring& name, bool* value); | 193 bool GetBooleanPreference(const std::wstring& name, bool* value); |
205 | 194 |
206 // Sets the boolean value of the specified preference. | 195 // Sets the boolean value of the specified preference. |
207 bool SetBooleanPreference(const std::wstring& name, bool value); | 196 bool SetBooleanPreference(const std::wstring& name, bool value); |
208 | 197 |
198 // Terminates the browser session. | |
huanr
2009/09/22 03:42:24
Would be helpful if adding comments saying this ha
Evan Stade
2009/09/22 19:42:01
Done.
| |
199 bool TerminateSession(); | |
200 | |
209 protected: | 201 protected: |
210 virtual ~BrowserProxy() {} | 202 virtual ~BrowserProxy() {} |
211 private: | 203 private: |
212 DISALLOW_COPY_AND_ASSIGN(BrowserProxy); | 204 DISALLOW_COPY_AND_ASSIGN(BrowserProxy); |
213 }; | 205 }; |
214 | 206 |
215 #endif // CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_ | 207 #endif // CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_ |
OLD | NEW |