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_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ |
6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ | 6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/task.h" | 16 #include "base/task.h" |
17 #include "chrome/common/automation_constants.h" | 17 #include "chrome/common/automation_constants.h" |
18 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
19 | 19 |
| 20 class AutomationId; |
20 class AutomationProxy; | 21 class AutomationProxy; |
21 class ProxyLauncher; | 22 class ProxyLauncher; |
22 struct WebKeyEvent; | 23 struct WebKeyEvent; |
| 24 class WebViewId; |
| 25 struct WebViewInfo; |
| 26 class WebViewLocator; |
23 | 27 |
24 namespace base { | 28 namespace base { |
25 class DictionaryValue; | 29 class DictionaryValue; |
26 class ListValue; | 30 class ListValue; |
27 } | 31 } |
28 | 32 |
29 namespace webdriver { | 33 namespace webdriver { |
30 | 34 |
31 class Error; | 35 class Error; |
32 class FramePath; | 36 class FramePath; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 69 |
66 // Start the system's default Chrome binary. | 70 // Start the system's default Chrome binary. |
67 void Init(const BrowserOptions& options, Error** error); | 71 void Init(const BrowserOptions& options, Error** error); |
68 | 72 |
69 // Terminates this session and disconnects its automation proxy. After | 73 // Terminates this session and disconnects its automation proxy. After |
70 // invoking this method, the Automation can safely be deleted. | 74 // invoking this method, the Automation can safely be deleted. |
71 void Terminate(); | 75 void Terminate(); |
72 | 76 |
73 // Executes the given |script| in the specified frame of the current | 77 // Executes the given |script| in the specified frame of the current |
74 // tab. |result| will be set to the JSON result. Returns true on success. | 78 // tab. |result| will be set to the JSON result. Returns true on success. |
75 void ExecuteScript(int tab_id, | 79 void ExecuteScript(const WebViewId& view_id, |
76 const FramePath& frame_path, | 80 const FramePath& frame_path, |
77 const std::string& script, | 81 const std::string& script, |
78 std::string* result, | 82 std::string* result, |
79 Error** error); | 83 Error** error); |
80 | 84 |
81 // Sends a webkit key event to the current browser. Waits until the key has | 85 // Sends a webkit key event to the current browser. Waits until the key has |
82 // been processed by the web page. | 86 // been processed by the web page. |
83 void SendWebKeyEvent(int tab_id, | 87 void SendWebKeyEvent(const WebViewId& view_id, |
84 const WebKeyEvent& key_event, | 88 const WebKeyEvent& key_event, |
85 Error** error); | 89 Error** error); |
86 | 90 |
87 // Sends an OS level key event to the current browser. Waits until the key | 91 // Sends an OS level key event to the current browser. Waits until the key |
88 // has been processed by the browser. | 92 // has been processed by the browser. |
89 void SendNativeKeyEvent(int tab_id, | 93 void SendNativeKeyEvent(const WebViewId& view_id, |
90 ui::KeyboardCode key_code, | 94 ui::KeyboardCode key_code, |
91 int modifiers, | 95 int modifiers, |
92 Error** error); | 96 Error** error); |
93 | 97 |
94 // Drag and drop the file paths to the given location. | 98 // Drag and drop the file paths to the given location. |
95 void DragAndDropFilePaths(int tab_id, | 99 void DragAndDropFilePaths(const WebViewId& view_id, |
96 const Point& location, | 100 const Point& location, |
97 const std::vector<FilePath::StringType>& paths, | 101 const std::vector<FilePath::StringType>& paths, |
98 Error** error); | 102 Error** error); |
99 | 103 |
100 // Captures a snapshot of the tab to the specified path. The PNG will | 104 // Captures a snapshot of the tab to the specified path. The PNG will |
101 // contain the entire page, including what is not in the current view | 105 // contain the entire page, including what is not in the current view |
102 // on the screen. | 106 // on the screen. |
103 void CaptureEntirePageAsPNG(int tab_id, const FilePath& path, Error** error); | 107 void CaptureEntirePageAsPNG( |
| 108 const WebViewId& view_id, const FilePath& path, Error** error); |
104 | 109 |
105 void NavigateToURL(int tab_id, const std::string& url, Error** error); | 110 void NavigateToURL( |
106 void NavigateToURLAsync(int tab_id, const std::string& url, Error** error); | 111 const WebViewId& view_id, const std::string& url, Error** error); |
107 void GoForward(int tab_id, Error** error); | 112 void NavigateToURLAsync( |
108 void GoBack(int tab_id, Error** error); | 113 const WebViewId& view_id, const std::string& url, Error** error); |
109 void Reload(int tab_id, Error** error); | 114 void GoForward(const WebViewId& view_id, Error** error); |
| 115 void GoBack(const WebViewId& view_id, Error** error); |
| 116 void Reload(const WebViewId& view_id, Error** error); |
110 | 117 |
111 void GetCookies(const std::string& url, | 118 void GetCookies(const std::string& url, |
112 base::ListValue** cookies, | 119 base::ListValue** cookies, |
113 Error** error); | 120 Error** error); |
114 void DeleteCookie(const std::string& url, | 121 void DeleteCookie(const std::string& url, |
115 const std::string& cookie_name, | 122 const std::string& cookie_name, |
116 Error** error); | 123 Error** error); |
117 void SetCookie(const std::string& url, | 124 void SetCookie(const std::string& url, |
118 base::DictionaryValue* cookie_dict, | 125 base::DictionaryValue* cookie_dict, |
119 Error** error); | 126 Error** error); |
120 | 127 |
121 void MouseMove(int tab_id, const Point& p, Error** error); | 128 void MouseMove(const WebViewId& view_id, const Point& p, Error** error); |
122 void MouseClick(int tab_id, | 129 void MouseClick(const WebViewId& view_id, |
123 const Point& p, | 130 const Point& p, |
124 automation::MouseButton button, | 131 automation::MouseButton button, |
125 Error** error); | 132 Error** error); |
126 void MouseDrag(int tab_id, | 133 void MouseDrag(const WebViewId& view_id, |
127 const Point& start, | 134 const Point& start, |
128 const Point& end, | 135 const Point& end, |
129 Error** error); | 136 Error** error); |
130 void MouseButtonDown(int tab_id, const Point& p, Error** error); | 137 void MouseButtonDown(const WebViewId& view_id, |
131 void MouseButtonUp(int tab_id, const Point& p, Error** error); | 138 const Point& p, |
132 void MouseDoubleClick(int tab_id, const Point& p, Error** error); | 139 Error** error); |
| 140 void MouseButtonUp(const WebViewId& view_id, |
| 141 const Point& p, |
| 142 Error** error); |
| 143 void MouseDoubleClick(const WebViewId& view_id, |
| 144 const Point& p, |
| 145 Error** error); |
133 | 146 |
134 // Get persistent IDs for all the tabs currently open. These IDs can be used | 147 // Get info for all views currently open. |
135 // to identify the tab as long as the tab exists. | 148 void GetViews(std::vector<WebViewInfo>* views, Error** error); |
136 void GetTabIds(std::vector<int>* tab_ids, Error** error); | |
137 | 149 |
138 // Check if the given tab exists currently. | 150 // Check if the given view exists currently. |
139 void DoesTabExist(int tab_id, bool* does_exist, Error** error); | 151 void DoesViewExist(const WebViewId& view_id, bool* does_exist, Error** error); |
140 | 152 |
141 void CloseTab(int tab_id, Error** error); | 153 // Closes the given view. |
| 154 void CloseView(const WebViewId& view_id, Error** error); |
142 | 155 |
143 // Gets the active JavaScript modal dialog's message. | 156 // Gets the active JavaScript modal dialog's message. |
144 void GetAppModalDialogMessage(std::string* message, Error** error); | 157 void GetAppModalDialogMessage(std::string* message, Error** error); |
145 | 158 |
146 // Accepts or dismisses the active JavaScript modal dialog. | 159 // Accepts or dismisses the active JavaScript modal dialog. |
147 void AcceptOrDismissAppModalDialog(bool accept, Error** error); | 160 void AcceptOrDismissAppModalDialog(bool accept, Error** error); |
148 | 161 |
149 // Accepts an active prompt JavaScript modal dialog, using the given | 162 // Accepts an active prompt JavaScript modal dialog, using the given |
150 // prompt text as the result of the prompt. | 163 // prompt text as the result of the prompt. |
151 void AcceptPromptAppModalDialog(const std::string& prompt_text, | 164 void AcceptPromptAppModalDialog(const std::string& prompt_text, |
152 Error** error); | 165 Error** error); |
153 | 166 |
154 // Gets the version of the runing browser. | 167 // Gets the version of the runing browser. |
155 void GetBrowserVersion(std::string* version); | 168 void GetBrowserVersion(std::string* version); |
156 | 169 |
157 // Gets the ChromeDriver automation version supported by the automation | 170 // Gets the ChromeDriver automation version supported by the automation |
158 // server. | 171 // server. |
159 void GetChromeDriverAutomationVersion(int* version, Error** error); | 172 void GetChromeDriverAutomationVersion(int* version, Error** error); |
160 | 173 |
161 // Waits for all tabs to stop loading. | 174 // Waits for all views to stop loading. |
162 void WaitForAllTabsToStopLoading(Error** error); | 175 void WaitForAllViewsToStopLoading(Error** error); |
163 | 176 |
164 // Install packed extension. | 177 // Install packed extension. |
165 void InstallExtensionDeprecated(const FilePath& path, Error** error); | 178 void InstallExtensionDeprecated(const FilePath& path, Error** error); |
166 | 179 |
167 // Gets all installed extension IDs. | |
168 void GetInstalledExtensions(std::vector<std::string>* extension_ids, | |
169 Error** error); | |
170 | |
171 // Install a packed or unpacked extension. If the path ends with '.crx', | 180 // Install a packed or unpacked extension. If the path ends with '.crx', |
172 // the extension is assumed to be packed. | 181 // the extension is assumed to be packed. |
173 void InstallExtension(const FilePath& path, std::string* extension_id, | 182 void InstallExtension(const FilePath& path, std::string* extension_id, |
174 Error** error); | 183 Error** error); |
175 | 184 |
| 185 // Gets a list of dictionary information about all installed extensions. |
| 186 void GetExtensionsInfo(base::ListValue* extensions_list, Error** error); |
| 187 |
| 188 // Gets a list of dictionary information about all installed extensions. |
| 189 void IsPageActionVisible(const WebViewId& tab_id, |
| 190 const std::string& extension_id, |
| 191 bool* is_visible, |
| 192 Error** error); |
| 193 |
| 194 // Sets whether the extension is enabled or not. |
| 195 void SetExtensionState(const std::string& extension_id, |
| 196 bool enable, |
| 197 Error** error); |
| 198 |
| 199 // Clicks the extension action button. If |browser_action| is false, the |
| 200 // page action will be clicked. |
| 201 void ClickExtensionButton(const std::string& extension_id, |
| 202 bool browser_action, |
| 203 Error** error); |
| 204 |
| 205 // Uninstalls the given extension. |
| 206 void UninstallExtension(const std::string& extension_id, Error** error); |
| 207 |
| 208 |
176 private: | 209 private: |
177 AutomationProxy* automation() const; | 210 AutomationProxy* automation() const; |
178 Error* GetIndicesForTab(int tab_id, int* browser_index, int* tab_index); | 211 Error* ConvertViewIdToLocator(const WebViewId& view_id, |
| 212 WebViewLocator* view_locator); |
179 Error* CompareVersion(int client_build_no, | 213 Error* CompareVersion(int client_build_no, |
180 int client_patch_no, | 214 int client_patch_no, |
181 bool* is_newer_or_equal); | 215 bool* is_newer_or_equal); |
182 Error* CheckVersion(int client_build_no, | 216 Error* CheckVersion(int client_build_no, |
183 int client_patch_no, | 217 int client_patch_no, |
184 const std::string& error_msg); | 218 const std::string& error_msg); |
185 Error* CheckAlertsSupported(); | 219 Error* CheckAlertsSupported(); |
186 Error* CheckAdvancedInteractionsSupported(); | 220 Error* CheckAdvancedInteractionsSupported(); |
187 Error* CheckNewExtensionInterfaceSupported(); | 221 Error* CheckNewExtensionInterfaceSupported(); |
188 | 222 |
189 scoped_ptr<ProxyLauncher> launcher_; | 223 scoped_ptr<ProxyLauncher> launcher_; |
190 | 224 |
191 DISALLOW_COPY_AND_ASSIGN(Automation); | 225 DISALLOW_COPY_AND_ASSIGN(Automation); |
192 }; | 226 }; |
193 | 227 |
194 } // namespace webdriver | 228 } // namespace webdriver |
195 | 229 |
196 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); | 230 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
197 | 231 |
198 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ | 232 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ |
OLD | NEW |