1 // Copyright
2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Swig Interface for PyAuto.
6 // PyAuto makes the Automation Proxy interface available in Python
9 // swig
-python
-c
++ chrome
/test
/pyautolib
/pyautolib.i
10 // would generate pyautolib.py
, pyautolib_wrap.cxx
12 // When adding a new class or method
, make sure you specify the doc string using
13 // %feature
("docstring", "doc string goes here") NODENAME
;
14 // and attach it to your node
(class or method
). This doc string will be
15 // copied over in the generated python classes
/methods.
17 %module
(docstring
="Python interface to Automation Proxy.") pyautolib
18 %feature
("autodoc", "1");
21 %include
<std_string.i
>
22 %include
<std_wstring.i
>
24 %include
"chrome/test/pyautolib/argc_argv.i"
26 // NOTE
: All files included in this file should also be listed under
27 // pyautolib_sources in chrome_tests.gypi.
29 // Headers that can be swigged directly.
30 %include
"chrome/app/chrome_command_ids.h"
31 %include
"chrome/app/chrome_dll_resource.h"
32 %include
"chrome/common/automation_constants.h"
33 %include
"chrome/common/pref_names.h"
34 %include
"content/public/common/page_type.h"
35 %include
"content/public/common/security_style.h"
36 // Must come before cert_status_flags.h
37 %include
"net/base/net_export.h"
38 %ignore net
::MapNetErrorToCertStatus
(int
);
39 %include
"net/cert/cert_status_flags.h"
42 #include
"chrome/common/automation_constants.h"
43 #include
"chrome/common/pref_names.h"
44 #include
"chrome/test/automation/browser_proxy.h"
45 #include
"chrome/test/automation/tab_proxy.h"
46 #include
"chrome/test/pyautolib/pyautolib.h"
47 #include
"content/public/common/security_style.h"
48 #include
"net/test/spawned_test_server/spawned_test_server.h"
51 // Handle type uint32 conversions as int
52 %apply int
{ uint32
};
63 T
* operator-
>() const
;
67 %feature
("docstring", "Represent a URL. Call spec() to get the string.") GURL
;
71 explicit GURL
(const std
::string
& url_string);
72 %feature
("docstring", "Get the string representation.") spec
;
73 const std
::string
& spec() const;
79 "Represent a file path. Call value() to get the string.") FilePath
;
82 %feature
("docstring", "Get the string representation.") value
;
84 typedef std
::wstring StringType
;
86 typedef std
::string StringType
;
88 const StringType
& value() const;
89 %feature
("docstring", "Construct an empty FilePath from a string.")
92 explicit FilePath
(const StringType
& path);
96 class PyUITestSuiteBase
{
98 %feature
("docstring", "Create the suite.") PyUITestSuiteBase
;
99 PyUITestSuiteBase
(int argc
, char
** argv
);
100 virtual ~PyUITestSuiteBase
();
102 %feature
("docstring", "Initialize from the path to browser dir.")
104 void InitializeWithPath
(const base
::FilePath
& browser_dir);
105 %feature
("docstring", "Set chrome source root path, used in some tests")
107 void SetCrSourceRoot
(const base
::FilePath
& path);
112 PyUITestBase
(bool clear_profile
, std
::wstring homepage
);
114 %feature
("docstring", "Initialize the entire setup. Should be called "
115 "before launching the browser. For internal use.") Initialize
;
116 void Initialize
(const base
::FilePath
& browser_dir);
118 %feature
("docstring", "Appends a command-line switch (with associated value "
119 "if given) to the list of switches to be passed to the browser "
120 "upon launch. Should be called before launching the browser. "
121 "For internal use only.")
122 AppendBrowserLaunchSwitch
;
123 void AppendBrowserLaunchSwitch
(const char
* name
);
124 void AppendBrowserLaunchSwitch
(const char
* name
, const char
* value
);
126 %feature
("docstring", "Begins tracing with the given category_patterns "
129 bool BeginTracing
(const std
::string
& category_patterns);
131 %feature
("docstring", "Ends tracing and returns the collected events.")
133 std
::string EndTracing
();
135 void UseNamedChannelID
(const std
::string
& named_channel_id);
137 %feature
("docstring",
138 "Fires up the browser and opens a window.") SetUp
;
139 virtual void SetUp
();
140 %feature
("docstring",
141 "Closes all windows and destroys the browser.") TearDown
;
142 virtual void TearDown
();
144 %feature
("docstring", "Launches the browser and IPC testing server.")
145 LaunchBrowserAndServer
;
146 void LaunchBrowserAndServer
();
147 %feature
("docstring", "Closes the browser and IPC testing server.")
148 CloseBrowserAndServer
;
149 void CloseBrowserAndServer
();
151 %feature
("docstring", "Determine if the profile is set to be cleared on "
152 "next startup.") get_clear_profile
;
153 bool get_clear_profile
() const
;
154 %feature
("docstring", "If False, sets the flag so that the profile is "
155 "not cleared on next startup. Useful for persisting profile "
156 "across restarts. By default the state is True, to clear profile.")
158 void set_clear_profile
(bool clear_profile
);
160 %feature
("docstring", "Get the path to profile directory.") user_data_dir
;
161 base
::FilePath user_data_dir
() const
;
164 %feature
("docstring", "Send a sync JSON request to Chrome. "
165 "Returns a JSON dict as a response. "
166 "Given timeout in milliseconds."
169 std
::string _SendJSONRequest
(int window_index
,
170 const std
::string
& request,
173 %feature
("docstring",
174 "Returns empty string if there were no unexpected Chrome asserts or "
175 "crashes, a string describing the failures otherwise. As a side "
176 "effect, it will fail with EXPECT_EQ macros if this code runs "
177 "within a gtest harness.") GetErrorsAndCrashes
;
178 std
::string CheckErrorsAndCrashes
() const
;
183 %feature
("docstring",
184 "SpawnedTestServer. Serves files in data dir over a local http server")
186 class SpawnedTestServer
{
194 // Initialize a SpawnedTestServer listening on the specified host
196 SpawnedTestServer
(Type type
, const std
::string
& host,
197 const base
::FilePath
& document_root);
198 // Initialize a SpawnedTestServer with a specific set of SSLOptions.
199 SpawnedTestServer
(Type type
,
200 const SSLOptions
& ssl_options,
201 const base
::FilePath
& document_root);
203 %feature
("docstring", "Start SpawnedTestServer over an ephemeral port") Start
;
206 %feature
("docstring", "Stop SpawnedTestServer") Stop
;
209 %feature
("docstring", "Get FilePath to the document root") document_root
;
210 const base
::FilePath
& document_root() const;
212 std
::string GetScheme
() const
;
214 %feature
("docstring", "Get URL for a file path") GetURL
;
215 GURL GetURL
(const std
::string
& path) const;
218 %extend SpawnedTestServer
{
219 %feature
("docstring", "Get port number.") GetPort
;
220 int GetPort
() const
{
222 $self-
>server_data
().GetInteger
("port", &val);
229 %feature
("docstring",
230 "SSLOptions. Sets one of three types of a cert")
233 enum ServerCertificate
{
235 CERT_MISMATCHED_NAME
,
239 // Initialize a new SSLOptions that will use the specified certificate.
240 explicit SSLOptions
(ServerCertificate cert
);
244 typedef net
::SpawnedTestServer
::SSLOptions SSLOptions
;
247 %pointer_class
(int
, int_ptr
);
248 %pointer_class
(uint32
, uint32_ptr
);