| 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 // This file declares the C++ side of PyAuto, the python interface to | 5 // This file declares the C++ side of PyAuto, the python interface to |
| 6 // Chromium automation. It access Chromium's internals using Automation Proxy. | 6 // Chromium automation. It access Chromium's internals using Automation Proxy. |
| 7 | 7 |
| 8 #ifndef CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 8 #ifndef CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
| 9 #define CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 9 #define CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Only public methods are accessible from swig. | 43 // Only public methods are accessible from swig. |
| 44 | 44 |
| 45 // Constructor. Lookup pyauto.py for doc on these args. | 45 // Constructor. Lookup pyauto.py for doc on these args. |
| 46 PyUITestBase(bool clear_profile, std::wstring homepage); | 46 PyUITestBase(bool clear_profile, std::wstring homepage); |
| 47 ~PyUITestBase(); | 47 ~PyUITestBase(); |
| 48 | 48 |
| 49 // Initialize the setup. Should be called before launching the browser. | 49 // Initialize the setup. Should be called before launching the browser. |
| 50 // |browser_dir| is the path to dir containing chromium binaries. | 50 // |browser_dir| is the path to dir containing chromium binaries. |
| 51 void Initialize(const FilePath& browser_dir); | 51 void Initialize(const FilePath& browser_dir); |
| 52 | 52 |
| 53 void UseNamedChannelID(const std::string& named_channel_id) { |
| 54 named_channel_id_ = named_channel_id; |
| 55 } |
| 56 |
| 57 virtual ProxyLauncher* CreateProxyLauncher(); |
| 58 |
| 53 // SetUp,TearDown is redeclared as public to make it accessible from swig. | 59 // SetUp,TearDown is redeclared as public to make it accessible from swig. |
| 54 virtual void SetUp(); | 60 virtual void SetUp(); |
| 55 virtual void TearDown(); | 61 virtual void TearDown(); |
| 56 | 62 |
| 57 // Navigate to the given URL in the active tab. Blocks until page loaded. | 63 // Navigate to the given URL in the active tab. Blocks until page loaded. |
| 58 void NavigateToURL(const char* url_string); | 64 void NavigateToURL(const char* url_string); |
| 59 | 65 |
| 60 // Navigate to the given URL in the active tab in the given window. | 66 // Navigate to the given URL in the active tab in the given window. |
| 61 void NavigateToURL(const char* url_string, int window_index); | 67 void NavigateToURL(const char* url_string, int window_index); |
| 62 | 68 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 bool ReparentBookmark(std::wstring& id, std::wstring& new_parent_id, | 155 bool ReparentBookmark(std::wstring& id, std::wstring& new_parent_id, |
| 150 int index); | 156 int index); |
| 151 bool SetBookmarkTitle(std::wstring& id, std::wstring& title); | 157 bool SetBookmarkTitle(std::wstring& id, std::wstring& title); |
| 152 bool SetBookmarkURL(std::wstring& id, std::wstring& url); | 158 bool SetBookmarkURL(std::wstring& id, std::wstring& url); |
| 153 // Finally, bookmark deletion: | 159 // Finally, bookmark deletion: |
| 154 bool RemoveBookmark(std::wstring& id); | 160 bool RemoveBookmark(std::wstring& id); |
| 155 | 161 |
| 156 // Get a handle to browser window at the given index, or NULL on failure. | 162 // Get a handle to browser window at the given index, or NULL on failure. |
| 157 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); | 163 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); |
| 158 | 164 |
| 159 // Meta-method. Experimental pattern of passing args and response as | 165 // Meta-methods. Generic pattern of passing args and response as |
| 160 // JSON dict to avoid future use of the SWIG interface and | 166 // JSON dict to avoid future use of the SWIG interface and |
| 161 // automation proxy additions. Returns response as JSON dict. | 167 // automation proxy additions. Returns response as JSON dict. |
| 162 std::string _SendJSONRequest(int window_index, std::string& request); | 168 // Use -ve window_index for automation calls not targetted at a browser |
| 169 // window. Example: Login call for chromeos. |
| 170 std::string _SendJSONRequest(int window_index, const std::string& request); |
| 163 | 171 |
| 164 // Execute javascript in a given tab, and return the response. This is | 172 // Execute javascript in a given tab, and return the response. This is |
| 165 // a low-level method intended for use mostly by GetDOMValue(). Note that | 173 // a low-level method intended for use mostly by GetDOMValue(). Note that |
| 166 // any complicated manipulation of the page should be done by something | 174 // any complicated manipulation of the page should be done by something |
| 167 // like WebDriver, not PyAuto. Also note that in order for the script to | 175 // like WebDriver, not PyAuto. Also note that in order for the script to |
| 168 // return a value to the calling code, it invoke | 176 // return a value to the calling code, it invoke |
| 169 // window.domAutomationController.send(), passing in the intended return | 177 // window.domAutomationController.send(), passing in the intended return |
| 170 // value. | 178 // value. |
| 171 std::wstring ExecuteJavascript(const std::wstring& script, | 179 std::wstring ExecuteJavascript(const std::wstring& script, |
| 172 int window_index = 0, | 180 int window_index = 0, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 199 } | 207 } |
| 200 | 208 |
| 201 private: | 209 private: |
| 202 // Enables PostTask to main thread. | 210 // Enables PostTask to main thread. |
| 203 // Should be shared across multiple instances of PyUITestBase so that this | 211 // Should be shared across multiple instances of PyUITestBase so that this |
| 204 // class is re-entrant and multiple instances can be created. | 212 // class is re-entrant and multiple instances can be created. |
| 205 // This is necessary since python's unittest module creates instances of | 213 // This is necessary since python's unittest module creates instances of |
| 206 // TestCase at load time itself. | 214 // TestCase at load time itself. |
| 207 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); | 215 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); |
| 208 static MessageLoop* message_loop_; | 216 static MessageLoop* message_loop_; |
| 217 |
| 218 // Path to named channel id. |
| 219 std::string named_channel_id_; |
| 209 }; | 220 }; |
| 210 | 221 |
| 211 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 222 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
| OLD | NEW |