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 AutomationProxy; | 20 class AutomationProxy; |
21 class ProxyLauncher; | 21 class ProxyLauncher; |
22 struct WebKeyEvent; | 22 struct WebKeyEvent; |
| 23 struct WebViewId; |
| 24 struct WebViewInfo; |
| 25 struct WebViewLocator; |
23 | 26 |
24 namespace base { | 27 namespace base { |
25 class DictionaryValue; | 28 class DictionaryValue; |
26 class ListValue; | 29 class ListValue; |
27 } | 30 } |
28 | 31 |
29 namespace webdriver { | 32 namespace webdriver { |
30 | 33 |
31 class Error; | 34 class Error; |
32 class FramePath; | 35 class FramePath; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 68 |
66 // Start the system's default Chrome binary. | 69 // Start the system's default Chrome binary. |
67 void Init(const BrowserOptions& options, Error** error); | 70 void Init(const BrowserOptions& options, Error** error); |
68 | 71 |
69 // Terminates this session and disconnects its automation proxy. After | 72 // Terminates this session and disconnects its automation proxy. After |
70 // invoking this method, the Automation can safely be deleted. | 73 // invoking this method, the Automation can safely be deleted. |
71 void Terminate(); | 74 void Terminate(); |
72 | 75 |
73 // Executes the given |script| in the specified frame of the current | 76 // 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. | 77 // tab. |result| will be set to the JSON result. Returns true on success. |
75 void ExecuteScript(int tab_id, | 78 void ExecuteScript(const WebViewId& view_id, |
76 const FramePath& frame_path, | 79 const FramePath& frame_path, |
77 const std::string& script, | 80 const std::string& script, |
78 std::string* result, | 81 std::string* result, |
79 Error** error); | 82 Error** error); |
80 | 83 |
81 // Sends a webkit key event to the current browser. Waits until the key has | 84 // Sends a webkit key event to the current browser. Waits until the key has |
82 // been processed by the web page. | 85 // been processed by the web page. |
83 void SendWebKeyEvent(int tab_id, | 86 void SendWebKeyEvent(const WebViewId& view_id, |
84 const WebKeyEvent& key_event, | 87 const WebKeyEvent& key_event, |
85 Error** error); | 88 Error** error); |
86 | 89 |
87 // Sends an OS level key event to the current browser. Waits until the key | 90 // Sends an OS level key event to the current browser. Waits until the key |
88 // has been processed by the browser. | 91 // has been processed by the browser. |
89 void SendNativeKeyEvent(int tab_id, | 92 void SendNativeKeyEvent(int tab_id, |
90 ui::KeyboardCode key_code, | 93 ui::KeyboardCode key_code, |
91 int modifiers, | 94 int modifiers, |
92 Error** error); | 95 Error** error); |
93 | 96 |
94 // Drag and drop the file paths to the given location. | 97 // Drag and drop the file paths to the given location. |
95 void DragAndDropFilePaths(int tab_id, | 98 void DragAndDropFilePaths(const WebViewId& view_id, |
96 const Point& location, | 99 const Point& location, |
97 const std::vector<FilePath::StringType>& paths, | 100 const std::vector<FilePath::StringType>& paths, |
98 Error** error); | 101 Error** error); |
99 | 102 |
100 // Captures a snapshot of the tab to the specified path. The PNG will | 103 // 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 | 104 // contain the entire page, including what is not in the current view |
102 // on the screen. | 105 // on the screen. |
103 void CaptureEntirePageAsPNG(int tab_id, const FilePath& path, Error** error); | 106 void CaptureEntirePageAsPNG(int tab_id, const FilePath& path, Error** error); |
104 | 107 |
105 void NavigateToURL(int tab_id, const std::string& url, Error** error); | 108 void NavigateToURL(int tab_id, const std::string& url, Error** error); |
106 void NavigateToURLAsync(int tab_id, const std::string& url, Error** error); | 109 void NavigateToURLAsync(int tab_id, const std::string& url, Error** error); |
107 void GoForward(int tab_id, Error** error); | 110 void GoForward(int tab_id, Error** error); |
108 void GoBack(int tab_id, Error** error); | 111 void GoBack(int tab_id, Error** error); |
109 void Reload(int tab_id, Error** error); | 112 void Reload(int tab_id, Error** error); |
110 | 113 |
111 void GetCookies(const std::string& url, | 114 void GetCookies(const std::string& url, |
112 base::ListValue** cookies, | 115 base::ListValue** cookies, |
113 Error** error); | 116 Error** error); |
114 void DeleteCookie(const std::string& url, | 117 void DeleteCookie(const std::string& url, |
115 const std::string& cookie_name, | 118 const std::string& cookie_name, |
116 Error** error); | 119 Error** error); |
117 void SetCookie(const std::string& url, | 120 void SetCookie(const std::string& url, |
118 base::DictionaryValue* cookie_dict, | 121 base::DictionaryValue* cookie_dict, |
119 Error** error); | 122 Error** error); |
120 | 123 |
121 void MouseMove(int tab_id, const Point& p, Error** error); | 124 void MouseMove(const WebViewId& view_id, const Point& p, Error** error); |
122 void MouseClick(int tab_id, | 125 void MouseClick(const WebViewId& view_id, |
123 const Point& p, | 126 const Point& p, |
124 automation::MouseButton button, | 127 automation::MouseButton button, |
125 Error** error); | 128 Error** error); |
126 void MouseDrag(int tab_id, | 129 void MouseDrag(const WebViewId& view_id, |
127 const Point& start, | 130 const Point& start, |
128 const Point& end, | 131 const Point& end, |
129 Error** error); | 132 Error** error); |
130 void MouseButtonDown(int tab_id, const Point& p, Error** error); | 133 void MouseButtonDown(const WebViewId& view_id, |
131 void MouseButtonUp(int tab_id, const Point& p, Error** error); | 134 const Point& p, |
132 void MouseDoubleClick(int tab_id, const Point& p, Error** error); | 135 Error** error); |
| 136 void MouseButtonUp(const WebViewId& view_id, |
| 137 const Point& p, |
| 138 Error** error); |
| 139 void MouseDoubleClick(const WebViewId& view_id, |
| 140 const Point& p, |
| 141 Error** error); |
133 | 142 |
134 // Get persistent IDs for all the tabs currently open. These IDs can be used | 143 // Get info for all views currently open. |
135 // to identify the tab as long as the tab exists. | 144 void GetViews(std::vector<WebViewInfo>* views, Error** error); |
136 void GetTabIds(std::vector<int>* tab_ids, Error** error); | |
137 | 145 |
138 // Check if the given tab exists currently. | 146 // Check if the given view exists currently. |
139 void DoesTabExist(int tab_id, bool* does_exist, Error** error); | 147 void DoesViewExist(const WebViewId& view_id, bool* does_exist, Error** error); |
140 | 148 |
141 void CloseTab(int tab_id, Error** error); | 149 void CloseTab(int tab_id, Error** error); |
142 | 150 |
143 // Gets the active JavaScript modal dialog's message. | 151 // Gets the active JavaScript modal dialog's message. |
144 void GetAppModalDialogMessage(std::string* message, Error** error); | 152 void GetAppModalDialogMessage(std::string* message, Error** error); |
145 | 153 |
146 // Accepts or dismisses the active JavaScript modal dialog. | 154 // Accepts or dismisses the active JavaScript modal dialog. |
147 void AcceptOrDismissAppModalDialog(bool accept, Error** error); | 155 void AcceptOrDismissAppModalDialog(bool accept, Error** error); |
148 | 156 |
149 // Accepts an active prompt JavaScript modal dialog, using the given | 157 // Accepts an active prompt JavaScript modal dialog, using the given |
(...skipping 18 matching lines...) Expand all Loading... |
168 void GetInstalledExtensions(std::vector<std::string>* extension_ids, | 176 void GetInstalledExtensions(std::vector<std::string>* extension_ids, |
169 Error** error); | 177 Error** error); |
170 | 178 |
171 // Install a packed or unpacked extension. If the path ends with '.crx', | 179 // Install a packed or unpacked extension. If the path ends with '.crx', |
172 // the extension is assumed to be packed. | 180 // the extension is assumed to be packed. |
173 void InstallExtension(const FilePath& path, std::string* extension_id, | 181 void InstallExtension(const FilePath& path, std::string* extension_id, |
174 Error** error); | 182 Error** error); |
175 | 183 |
176 private: | 184 private: |
177 AutomationProxy* automation() const; | 185 AutomationProxy* automation() const; |
178 Error* GetIndicesForTab(int tab_id, int* browser_index, int* tab_index); | 186 Error* GetIndicesForTab( |
| 187 int tab_id, int* browser_index, int* tab_index); |
| 188 Error* ConvertViewIdToLocator(const WebViewId& view_id, |
| 189 WebViewLocator* view_locator); |
179 Error* CompareVersion(int client_build_no, | 190 Error* CompareVersion(int client_build_no, |
180 int client_patch_no, | 191 int client_patch_no, |
181 bool* is_newer_or_equal); | 192 bool* is_newer_or_equal); |
182 Error* CheckVersion(int client_build_no, | 193 Error* CheckVersion(int client_build_no, |
183 int client_patch_no, | 194 int client_patch_no, |
184 const std::string& error_msg); | 195 const std::string& error_msg); |
185 Error* CheckAlertsSupported(); | 196 Error* CheckAlertsSupported(); |
186 Error* CheckAdvancedInteractionsSupported(); | 197 Error* CheckAdvancedInteractionsSupported(); |
187 Error* CheckNewExtensionInterfaceSupported(); | 198 Error* CheckNewExtensionInterfaceSupported(); |
188 | 199 |
189 scoped_ptr<ProxyLauncher> launcher_; | 200 scoped_ptr<ProxyLauncher> launcher_; |
190 | 201 |
191 DISALLOW_COPY_AND_ASSIGN(Automation); | 202 DISALLOW_COPY_AND_ASSIGN(Automation); |
192 }; | 203 }; |
193 | 204 |
194 } // namespace webdriver | 205 } // namespace webdriver |
195 | 206 |
196 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); | 207 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
197 | 208 |
198 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ | 209 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_AUTOMATION_H_ |
OLD | NEW |