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 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ |
6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ | 6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 // Block the thread until the window count becomes the provided value. | 112 // Block the thread until the window count becomes the provided value. |
113 // Returns true on success. | 113 // Returns true on success. |
114 bool WaitForWindowCountToBecome(int target_count) WARN_UNUSED_RESULT; | 114 bool WaitForWindowCountToBecome(int target_count) WARN_UNUSED_RESULT; |
115 | 115 |
116 // Fills the number of open normal browser windows (normal type and | 116 // Fills the number of open normal browser windows (normal type and |
117 // non-incognito mode) into the given variable, returning true on success. | 117 // non-incognito mode) into the given variable, returning true on success. |
118 // False likely indicates an IPC error. | 118 // False likely indicates an IPC error. |
119 bool GetNormalBrowserWindowCount(int* num_windows) WARN_UNUSED_RESULT; | 119 bool GetNormalBrowserWindowCount(int* num_windows) WARN_UNUSED_RESULT; |
120 | 120 |
121 // Gets the locale of the chrome browser, currently all browsers forked from | |
122 // the main chrome share the same UI locale, returning true on success. | |
123 // False likely indicates an IPC error. | |
124 bool GetBrowserLocale(string16* locale) WARN_UNUSED_RESULT; | |
125 | |
126 // Returns whether an app modal dialog window is showing right now (i.e., a | |
127 // javascript alert), and what buttons it contains. | |
128 bool GetShowingAppModalDialog(bool* showing_app_modal_dialog, | |
129 ui::DialogButton* button) WARN_UNUSED_RESULT; | |
130 | |
131 // Simulates a click on a dialog button. Synchronous. | |
132 bool ClickAppModalDialogButton(ui::DialogButton button) WARN_UNUSED_RESULT; | |
133 | |
134 // Block the thread until a modal dialog is displayed. Returns true on | |
135 // success. | |
136 bool WaitForAppModalDialog() WARN_UNUSED_RESULT; | |
137 | |
138 // Returns true if one of the tabs in any window displays given url. | 121 // Returns true if one of the tabs in any window displays given url. |
139 bool IsURLDisplayed(GURL url) WARN_UNUSED_RESULT; | 122 bool IsURLDisplayed(GURL url) WARN_UNUSED_RESULT; |
140 | 123 |
141 // Get the duration of the last |event_name| in the browser. Returns | 124 // Get the duration of the last |event_name| in the browser. Returns |
142 // false if the IPC failed to send. | 125 // false if the IPC failed to send. |
143 bool GetMetricEventDuration(const std::string& event_name, | 126 bool GetMetricEventDuration(const std::string& event_name, |
144 int* duration_ms) WARN_UNUSED_RESULT; | 127 int* duration_ms) WARN_UNUSED_RESULT; |
145 | 128 |
146 // Returns the BrowserProxy for the browser window at the given index, | 129 // Returns the BrowserProxy for the browser window at the given index, |
147 // transferring ownership of the pointer to the caller. | 130 // transferring ownership of the pointer to the caller. |
148 // On failure, returns NULL. | 131 // On failure, returns NULL. |
149 // | 132 // |
150 // Use GetBrowserWindowCount to see how many browser windows you can ask for. | 133 // Use GetBrowserWindowCount to see how many browser windows you can ask for. |
151 // Window numbers are 0-based. | 134 // Window numbers are 0-based. |
152 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); | 135 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); |
153 | 136 |
154 // Finds the first browser window that is not incognito mode and of type | 137 // Finds the first browser window that is not incognito mode and of type |
155 // TYPE_TABBED, and returns its corresponding BrowserProxy, transferring | 138 // TYPE_TABBED, and returns its corresponding BrowserProxy, transferring |
156 // ownership of the pointer to the caller. | 139 // ownership of the pointer to the caller. |
157 // On failure, returns NULL. | 140 // On failure, returns NULL. |
158 scoped_refptr<BrowserProxy> FindTabbedBrowserWindow(); | 141 scoped_refptr<BrowserProxy> FindTabbedBrowserWindow(); |
159 | 142 |
160 // Returns the BrowserProxy for the browser window which was last active, | |
161 // transferring ownership of the pointer to the caller. | |
162 // TODO: If there was no last active browser window, or the last active | |
163 // browser window no longer exists (for example, if it was closed), | |
164 // returns GetBrowserWindow(0). See crbug.com/10501. As for now this | |
165 // function is flakey. | |
166 scoped_refptr<BrowserProxy> GetLastActiveBrowserWindow(); | |
167 | |
168 // Returns the WindowProxy for the currently active window, transferring | 143 // Returns the WindowProxy for the currently active window, transferring |
169 // ownership of the pointer to the caller. | 144 // ownership of the pointer to the caller. |
170 // On failure, returns NULL. | 145 // On failure, returns NULL. |
171 scoped_refptr<WindowProxy> GetActiveWindow(); | 146 scoped_refptr<WindowProxy> GetActiveWindow(); |
172 | 147 |
173 // Tells the browser to enable or disable network request filtering. Returns | 148 // Tells the browser to enable or disable network request filtering. Returns |
174 // false if the message fails to send to the browser. | 149 // false if the message fails to send to the browser. |
175 bool SetFilteredInet(bool enabled) WARN_UNUSED_RESULT; | 150 bool SetFilteredInet(bool enabled) WARN_UNUSED_RESULT; |
176 | 151 |
177 // Returns the number of times a network request filter was used to service a | |
178 // network request. Returns -1 on error. | |
179 int GetFilteredInetHitCount(); | |
180 | |
181 // Sends the browser a new proxy configuration to start using. Returns true | 152 // Sends the browser a new proxy configuration to start using. Returns true |
182 // if the proxy config was successfully sent, false otherwise. | 153 // if the proxy config was successfully sent, false otherwise. |
183 bool SendProxyConfig(const std::string& new_proxy_config) WARN_UNUSED_RESULT; | 154 bool SendProxyConfig(const std::string& new_proxy_config) WARN_UNUSED_RESULT; |
184 | 155 |
185 // These methods are intended to be called by the background thread | 156 // These methods are intended to be called by the background thread |
186 // to signal that the given event has occurred, and that any corresponding | 157 // to signal that the given event has occurred, and that any corresponding |
187 // Wait... function can return. | 158 // Wait... function can return. |
188 void SignalAppLaunch(const std::string& version_string); | 159 void SignalAppLaunch(const std::string& version_string); |
189 void SignalInitialLoads(); | 160 void SignalInitialLoads(); |
190 // load_time is how long, in ms, the tab contents took to load. | 161 // load_time is how long, in ms, the tab contents took to load. |
191 void SignalNewTabUITab(int load_time); | 162 void SignalNewTabUITab(int load_time); |
192 | 163 |
193 // Gets the next extension test result in |result|. Returns false if there | 164 // Gets the next extension test result in |result|. Returns false if there |
194 // was a problem sending the result querying RPC. | 165 // was a problem sending the result querying RPC. |
195 bool GetExtensionTestResult(bool* result, std::string* message); | 166 bool GetExtensionTestResult(bool* result, std::string* message); |
196 | 167 |
197 // Resets to the default theme. Returns true on success. | 168 // Resets to the default theme. Returns true on success. |
198 bool ResetToDefaultTheme(); | 169 bool ResetToDefaultTheme(); |
199 | 170 |
200 // Generic pattern for sending automation requests. | 171 // Generic pattern for sending automation requests. |
201 bool SendJSONRequest(const std::string& request, | 172 bool SendJSONRequest(const std::string& request, |
202 int timeout_ms, | 173 int timeout_ms, |
203 std::string* response) WARN_UNUSED_RESULT; | 174 std::string* response) WARN_UNUSED_RESULT; |
204 | 175 |
205 #if defined(OS_CHROMEOS) | |
206 // Logs in through the Chrome OS login wizard with given |username| | |
207 // and |password|. Returns true on success. | |
208 bool LoginWithUserAndPass(const std::string& username, | |
209 const std::string& password) WARN_UNUSED_RESULT; | |
210 #endif | |
211 | |
212 // Begin tracing specified categories on the browser instance. Blocks until | 176 // Begin tracing specified categories on the browser instance. Blocks until |
213 // browser acknowledges that tracing has begun (or failed if false is | 177 // browser acknowledges that tracing has begun (or failed if false is |
214 // returned). |categories| is a comma-delimited list of category wildcards. | 178 // returned). |categories| is a comma-delimited list of category wildcards. |
215 // A category can have an optional '-' prefix to make it an excluded category. | 179 // A category can have an optional '-' prefix to make it an excluded category. |
216 // Either all categories must be included or all must be excluded. | 180 // Either all categories must be included or all must be excluded. |
217 // | 181 // |
218 // Example: BeginTracing("test_MyTest*"); | 182 // Example: BeginTracing("test_MyTest*"); |
219 // Example: BeginTracing("test_MyTest*,test_OtherStuff"); | 183 // Example: BeginTracing("test_MyTest*,test_OtherStuff"); |
220 // Example: BeginTracing("-excluded_category1,-excluded_category2"); | 184 // Example: BeginTracing("-excluded_category1,-excluded_category2"); |
221 // | 185 // |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 278 |
315 // Delay to let the browser execute the command. | 279 // Delay to let the browser execute the command. |
316 base::TimeDelta action_timeout_; | 280 base::TimeDelta action_timeout_; |
317 | 281 |
318 base::PlatformThreadId listener_thread_id_; | 282 base::PlatformThreadId listener_thread_id_; |
319 | 283 |
320 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); | 284 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); |
321 }; | 285 }; |
322 | 286 |
323 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ | 287 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ |
OLD | NEW |