OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Swig Interface for PyAuto. | 5 // Swig Interface for PyAuto. |
6 // PyAuto makes the Automation Proxy interface available in Python | 6 // PyAuto makes the Automation Proxy interface available in Python |
7 // | 7 // |
8 // Running swig as: | 8 // Running swig as: |
9 // swig -python -c++ chrome/test/pyautolib/pyautolib.i | 9 // swig -python -c++ chrome/test/pyautolib/pyautolib.i |
10 // would generate pyautolib.py, pyautolib_wrap.cxx | 10 // would generate pyautolib.py, pyautolib_wrap.cxx |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 template <class T> | 54 template <class T> |
55 class scoped_refptr { | 55 class scoped_refptr { |
56 public: | 56 public: |
57 scoped_refptr(); | 57 scoped_refptr(); |
58 scoped_refptr(T* p); | 58 scoped_refptr(T* p); |
59 ~scoped_refptr(); | 59 ~scoped_refptr(); |
60 | 60 |
61 T* get() const; | 61 T* get() const; |
62 T* operator->() const; | 62 T* operator->() const; |
63 }; | 63 }; |
64 %template(scoped_refptr__BrowserProxy) scoped_refptr<BrowserProxy>; | |
65 %template(scoped_refptr__TabProxy) scoped_refptr<TabProxy>; | |
66 | 64 |
67 // GURL | 65 // GURL |
68 %feature("docstring", "Represent a URL. Call spec() to get the string.") GURL; | 66 %feature("docstring", "Represent a URL. Call spec() to get the string.") GURL; |
69 class GURL { | 67 class GURL { |
70 public: | 68 public: |
71 GURL(); | 69 GURL(); |
72 explicit GURL(const std::string& url_string); | 70 explicit GURL(const std::string& url_string); |
73 %feature("docstring", "Get the string representation.") spec; | 71 %feature("docstring", "Get the string representation.") spec; |
74 const std::string& spec() const; | 72 const std::string& spec() const; |
75 }; | 73 }; |
76 | 74 |
77 // FilePath | 75 // FilePath |
78 %feature("docstring", | 76 %feature("docstring", |
79 "Represent a file path. Call value() to get the string.") FilePath; | 77 "Represent a file path. Call value() to get the string.") FilePath; |
80 class FilePath { | 78 class FilePath { |
81 public: | 79 public: |
82 %feature("docstring", "Get the string representation.") value; | 80 %feature("docstring", "Get the string representation.") value; |
83 #ifdef SWIGWIN | 81 #ifdef SWIGWIN |
84 typedef std::wstring StringType; | 82 typedef std::wstring StringType; |
85 #else | 83 #else |
86 typedef std::string StringType; | 84 typedef std::string StringType; |
87 #endif // SWIGWIN | 85 #endif // SWIGWIN |
88 const StringType& value() const; | 86 const StringType& value() const; |
89 %feature("docstring", "Construct an empty FilePath from a string.") | 87 %feature("docstring", "Construct an empty FilePath from a string.") |
90 FilePath; | 88 FilePath; |
91 FilePath(); | 89 FilePath(); |
92 explicit FilePath(const StringType& path); | 90 explicit FilePath(const StringType& path); |
93 }; | 91 }; |
94 | 92 |
95 // BrowserProxy | |
96 %feature("docstring", "Proxy handle to a browser window.") BrowserProxy; | |
97 %nodefaultctor BrowserProxy; | |
98 %nodefaultdtor BrowserProxy; | |
99 class BrowserProxy { | |
100 public: | |
101 %feature("docstring", "Activate the tab at the given zero-based index") | |
102 ActivateTab; | |
103 bool ActivateTab(int tab_index); | |
104 | |
105 %feature("docstring", "Activate the browser's window and bring it to front.") | |
106 BringToFront; | |
107 bool BringToFront(); | |
108 | |
109 %feature("docstring", "Get proxy to the tab at the given zero-based index") | |
110 GetTab; | |
111 scoped_refptr<TabProxy> GetTab(int tab_index) const; | |
112 }; | |
113 | |
114 // TabProxy | |
115 %feature("docstring", "Proxy handle to a tab.") TabProxy; | |
116 %nodefaultctor TabProxy; | |
117 %nodefaultdtor TabProxy; | |
118 class TabProxy { | |
119 public: | |
120 // Navigation | |
121 %feature("docstring", "Navigates to a given GURL. " | |
122 "Blocks until the navigation completes. ") NavigateToURL; | |
123 AutomationMsg_NavigationResponseValues NavigateToURL(const GURL& url); | |
124 %feature("docstring", "Navigates to a given GURL. Blocks until the given " | |
125 "number of navigations complete.") | |
126 NavigateToURLBlockUntilNavigationsComplete; | |
127 AutomationMsg_NavigationResponseValues | |
128 NavigateToURLBlockUntilNavigationsComplete( | |
129 const GURL& url, int number_of_navigations); | |
130 %feature("docstring", "Navigates to a given GURL asynchronously. " | |
131 "Does not wait for the navigation to complete, or even begin; " | |
132 "Use NavigateToURL() if you want to wait.") NavigateToURLAsync; | |
133 bool TabProxy::NavigateToURLAsync(const GURL& url); | |
134 %feature("docstring", "Equivalent to hitting the Back button. " | |
135 "Blocks until navigation completes.") GoBack; | |
136 AutomationMsg_NavigationResponseValues GoBack(); | |
137 %feature("docstring", "Equivalent to hitting the Forward button. " | |
138 "Blocks until navigation completes.") GoForward; | |
139 AutomationMsg_NavigationResponseValues GoForward(); | |
140 %feature("docstring", "Equivalent to hitting the Reload button. " | |
141 "Blocks until navigation completes.") Reload; | |
142 AutomationMsg_NavigationResponseValues Reload(); | |
143 %feature("docstring", "Closes the tab. Supply True to wait " | |
144 "until the tab has closed, else it'll wait only until the call " | |
145 "has been initiated. Be careful while closing the last tab " | |
146 "since it might close the browser.") Close; | |
147 bool Close(); | |
148 bool Close(bool wait_until_closed); | |
149 %feature("docstring", "Blocks until tab is completely restored.") | |
150 WaitForTabToBeRestored; | |
151 bool WaitForTabToBeRestored(uint32 timeout_ms); | |
152 %feature("docstring", "Simulates user action on the SSL blocking page." | |
153 "if |proceed| is true, this is equivalent to clicking the 'Proceed' " | |
154 "button, if false to 'Take me out of there' button.") | |
155 TakeActionOnSSLBlockingPage; | |
156 bool TakeActionOnSSLBlockingPage(bool proceed); | |
157 %extend { | |
158 %feature("docstring", "Retrieves the different security states for the " | |
159 "current tab.") | |
160 GetSecurityState; | |
161 PyObject* GetSecurityState() { | |
162 content::SecurityStyle security_style; | |
163 net::CertStatus ssl_cert_status; | |
164 int insecure_content_status; | |
165 PyObject* result_dict = PyDict_New(); | |
166 if ($self->GetSecurityState( | |
167 &security_style, &ssl_cert_status, &insecure_content_status)) { | |
168 PyDict_SetItem(result_dict, PyString_FromString("security_style"), | |
169 PyInt_FromLong(security_style)); | |
170 PyDict_SetItem(result_dict, PyString_FromString("ssl_cert_status"), | |
171 PyInt_FromLong(ssl_cert_status)); | |
172 PyDict_SetItem(result_dict, | |
173 PyString_FromString("insecure_content_status"), | |
174 PyInt_FromLong(insecure_content_status)); | |
175 } | |
176 return result_dict; | |
177 } | |
178 }; | |
179 %extend { | |
180 %feature("docstring", "Returns the type of page currently showing " | |
181 "(normal, interstitial, error.") | |
182 GetPageType; | |
183 PyObject* GetPageType() { | |
184 content::PageType page_type; | |
185 PyObject* result_dict = PyDict_New(); | |
186 if ($self->GetPageType(&page_type)) { | |
187 PyDict_SetItem(result_dict, PyString_FromString("page_type"), | |
188 PyInt_FromLong(page_type)); | |
189 } | |
190 return result_dict; | |
191 } | |
192 }; | |
193 | |
194 }; | |
195 | |
196 class PyUITestSuiteBase { | 93 class PyUITestSuiteBase { |
197 public: | 94 public: |
198 %feature("docstring", "Create the suite.") PyUITestSuiteBase; | 95 %feature("docstring", "Create the suite.") PyUITestSuiteBase; |
199 PyUITestSuiteBase(int argc, char** argv); | 96 PyUITestSuiteBase(int argc, char** argv); |
200 virtual ~PyUITestSuiteBase(); | 97 virtual ~PyUITestSuiteBase(); |
201 | 98 |
202 %feature("docstring", "Initialize from the path to browser dir.") | 99 %feature("docstring", "Initialize from the path to browser dir.") |
203 InitializeWithPath; | 100 InitializeWithPath; |
204 void InitializeWithPath(const FilePath& browser_dir); | 101 void InitializeWithPath(const FilePath& browser_dir); |
205 %feature("docstring", "Set chrome source root path, used in some tests") | 102 %feature("docstring", "Set chrome source root path, used in some tests") |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 int window_index=0); | 221 int window_index=0); |
325 | 222 |
326 %feature("docstring", "Set the URL of a bookmark.") SetBookmarkURL; | 223 %feature("docstring", "Set the URL of a bookmark.") SetBookmarkURL; |
327 bool SetBookmarkURL(std::wstring id, | 224 bool SetBookmarkURL(std::wstring id, |
328 const std::wstring url, | 225 const std::wstring url, |
329 int window_index=0); | 226 int window_index=0); |
330 | 227 |
331 %feature("docstring", "Remove (delete) a bookmark.") RemoveBookmark; | 228 %feature("docstring", "Remove (delete) a bookmark.") RemoveBookmark; |
332 bool RemoveBookmark(std::wstring id, int window_index=0); | 229 bool RemoveBookmark(std::wstring id, int window_index=0); |
333 | 230 |
334 // Misc methods | |
335 %feature("docstring", "Get a proxy to the browser window at the given " | |
336 "zero-based index.") GetBrowserWindow; | |
337 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); | |
338 | |
339 // Meta-method | 231 // Meta-method |
340 %feature("docstring", "Send a sync JSON request to Chrome. " | 232 %feature("docstring", "Send a sync JSON request to Chrome. " |
341 "Returns a JSON dict as a response. " | 233 "Returns a JSON dict as a response. " |
342 "Given timeout in milliseconds." | 234 "Given timeout in milliseconds." |
343 "Internal method.") | 235 "Internal method.") |
344 _SendJSONRequest; | 236 _SendJSONRequest; |
345 std::string _SendJSONRequest(int window_index, | 237 std::string _SendJSONRequest(int window_index, |
346 const std::string& request, | 238 const std::string& request, |
347 int timeout); | 239 int timeout); |
348 | 240 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Initialize a new HTTPSOptions that will use the specified certificate. | 313 // Initialize a new HTTPSOptions that will use the specified certificate. |
422 explicit HTTPSOptions(ServerCertificate cert); | 314 explicit HTTPSOptions(ServerCertificate cert); |
423 }; | 315 }; |
424 | 316 |
425 %{ | 317 %{ |
426 typedef net::TestServer::HTTPSOptions HTTPSOptions; | 318 typedef net::TestServer::HTTPSOptions HTTPSOptions; |
427 %} | 319 %} |
428 | 320 |
429 %pointer_class(int, int_ptr); | 321 %pointer_class(int, int_ptr); |
430 %pointer_class(uint32, uint32_ptr); | 322 %pointer_class(uint32, uint32_ptr); |
OLD | NEW |