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 // 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 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 virtual ProxyLauncher* CreateProxyLauncher() OVERRIDE; | 66 virtual ProxyLauncher* CreateProxyLauncher() OVERRIDE; |
67 | 67 |
68 // SetUp,TearDown is redeclared as public to make it accessible from swig. | 68 // SetUp,TearDown is redeclared as public to make it accessible from swig. |
69 virtual void SetUp() OVERRIDE; | 69 virtual void SetUp() OVERRIDE; |
70 virtual void TearDown() OVERRIDE; | 70 virtual void TearDown() OVERRIDE; |
71 | 71 |
72 // AutomationProxy methods | 72 // AutomationProxy methods |
73 | 73 |
74 // Returns bookmark bar visibility state. | |
75 bool GetBookmarkBarVisibility(); | |
76 | |
77 // Returns true if the bookmark bar is visible in the detached state. | |
78 bool IsBookmarkBarDetached(); | |
79 | |
80 // Returns bookmark bar animation state. Warning: timing issues may | |
81 // change this return value unexpectedly. | |
82 bool IsBookmarkBarAnimating(); | |
83 | |
84 // Wait for the bookmark bar animation to complete. | |
85 // If |wait_for_open| is true, wait for it to open. | |
86 // If |wait_for_open| is false, wait for it to close. | |
87 bool WaitForBookmarkBarVisibilityChange(bool wait_for_open, | |
88 int window_index = 0); | |
89 | |
90 // Get the bookmarks as a JSON string. Internal method. | |
91 std::string _GetBookmarksAsJSON(int window_index = 0); | |
92 | |
93 // Editing of the bookmark model. Bookmarks are referenced by id. | |
94 // The id is a std::wstring, not an int64, for convenience, since | |
95 // the python side gets IDs converted from a JSON representation | |
96 // (which "extracts" into a string, not an int). Since IDs are | |
97 // grabbed from the current model (and not generated), a conversion | |
98 // is unnecessary. URLs are strings and not GURLs for a similar reason. | |
99 // Bookmark or group (folder) creation: | |
100 bool AddBookmarkGroup(std::wstring& parent_id, int index, | |
101 std::wstring& title, int window_index = 0); | |
102 bool AddBookmarkURL(std::wstring& parent_id, int index, | |
103 std::wstring& title, std::wstring& url, | |
104 int window_index = 0); | |
105 // Bookmark editing: | |
106 bool ReparentBookmark(std::wstring& id, std::wstring& new_parent_id, | |
107 int index, int window_index = 0); | |
108 bool SetBookmarkTitle(std::wstring& id, std::wstring& title, | |
109 int window_index = 0); | |
110 bool SetBookmarkURL(std::wstring& id, std::wstring& url, | |
111 int window_index = 0); | |
112 // Finally, bookmark deletion: | |
113 bool RemoveBookmark(std::wstring& id, int window_index = 0); | |
114 | |
115 // Get a handle to browser window at the given index, or NULL on failure. | 74 // Get a handle to browser window at the given index, or NULL on failure. |
116 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); | 75 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); |
117 | 76 |
118 // Meta-methods. Generic pattern of passing args and response as | 77 // Meta-methods. Generic pattern of passing args and response as |
119 // JSON dict to avoid future use of the SWIG interface and | 78 // JSON dict to avoid future use of the SWIG interface and |
120 // automation proxy additions. Returns response as JSON dict. | 79 // automation proxy additions. Returns response as JSON dict. |
121 // Use -ve window_index for automation calls not targetted at a browser | 80 // Use -ve window_index for automation calls not targetted at a browser |
122 // window. Example: Login call for chromeos. | 81 // window. Example: Login call for chromeos. |
123 std::string _SendJSONRequest(int window_index, | 82 std::string _SendJSONRequest(int window_index, |
124 const std::string& request, | 83 const std::string& request, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Create JSON error responses. | 116 // Create JSON error responses. |
158 void ErrorResponse(const std::string& error_string, | 117 void ErrorResponse(const std::string& error_string, |
159 const std::string& request, | 118 const std::string& request, |
160 std::string* response); | 119 std::string* response); |
161 void RequestFailureResponse( | 120 void RequestFailureResponse( |
162 const std::string& request, | 121 const std::string& request, |
163 const base::TimeDelta& duration, | 122 const base::TimeDelta& duration, |
164 const base::TimeDelta& timeout, | 123 const base::TimeDelta& timeout, |
165 std::string* response); | 124 std::string* response); |
166 | 125 |
167 // Gets the current state of the bookmark bar. Returns false if it failed. | |
168 bool GetBookmarkBarState(bool* visible, bool* detached, int window_index = 0); | |
169 | |
170 // Enables PostTask to main thread. | 126 // Enables PostTask to main thread. |
171 // Should be shared across multiple instances of PyUITestBase so that this | 127 // Should be shared across multiple instances of PyUITestBase so that this |
172 // class is re-entrant and multiple instances can be created. | 128 // class is re-entrant and multiple instances can be created. |
173 // This is necessary since python's unittest module creates instances of | 129 // This is necessary since python's unittest module creates instances of |
174 // TestCase at load time itself. | 130 // TestCase at load time itself. |
175 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); | 131 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); |
176 static MessageLoop* message_loop_; | 132 static MessageLoop* message_loop_; |
177 | 133 |
178 // Path to named channel id. | 134 // Path to named channel id. |
179 std::string named_channel_id_; | 135 std::string named_channel_id_; |
180 }; | 136 }; |
181 | 137 |
182 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 138 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
OLD | NEW |