Chromium Code Reviews| 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_SESSION_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_SESSION_H_ | 6 #define CHROME_TEST_WEBDRIVER_SESSION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 // Send the given keys to the given element dictionary. This function takes | 73 // Send the given keys to the given element dictionary. This function takes |
| 74 // ownership of |element|. | 74 // ownership of |element|. |
| 75 ErrorCode SendKeys(const WebElementId& element, const string16& keys); | 75 ErrorCode SendKeys(const WebElementId& element, const string16& keys); |
| 76 | 76 |
| 77 // Click events with the mouse should use the values found in: | 77 // Click events with the mouse should use the values found in: |
| 78 // views/events/event.h. In the Webdriver JSON spec the MouseMove | 78 // views/events/event.h. In the Webdriver JSON spec the MouseMove |
| 79 // function directly maps to the hover command. | 79 // function directly maps to the hover command. |
| 80 void MouseClick(const gfx::Point& click, int flags); | 80 void MouseClick(const gfx::Point& click, int flags); |
| 81 bool MouseMove(const gfx::Point& location); | 81 bool MouseMove(const gfx::Point& location); |
| 82 bool MouseDrag(const gfx::Point& start, const gfx::Point& end); | 82 bool MouseDrag(const gfx::Point& start, const gfx::Point& end); |
| 83 | |
| 84 bool NavigateToURL(const std::string& url); | 83 bool NavigateToURL(const std::string& url); |
| 85 bool GoForward(); | 84 bool GoForward(); |
| 86 bool GoBack(); | 85 bool GoBack(); |
| 87 bool Reload(); | 86 bool Reload(); |
| 88 bool GetURL(GURL* url); | 87 bool GetURL(GURL* url); |
| 89 bool GetURL(std::string* url); | 88 bool GetURL(std::string* url); |
| 90 bool GetTabTitle(std::string* tab_title); | 89 bool GetTabTitle(std::string* tab_title); |
| 91 bool GetCookies(const GURL& url, std::string* cookies); | 90 bool GetCookies(const GURL& url, std::string* cookies); |
| 92 bool GetCookieByName(const GURL& url, const std::string& cookie_name, | 91 bool GetCookieByName(const GURL& url, const std::string& cookie_name, |
| 93 std::string* cookie); | 92 std::string* cookie); |
| 94 bool DeleteCookie(const GURL& url, const std::string& cookie_name); | 93 bool DeleteCookie(const GURL& url, const std::string& cookie_name); |
| 95 bool SetCookie(const GURL& url, const std::string& cookie); | 94 bool SetCookie(const GURL& url, const std::string& cookie); |
| 95 bool CaptureEntirePageAsPNG(const FilePath& path); | |
| 96 bool ScreenshotAsBase64(std::string* screenshot); | |
| 96 | 97 |
| 97 // Gets all the currently existing window IDs. Returns true on success. | 98 // Gets all the currently existing window IDs. Returns true on success. |
| 98 bool GetWindowIds(std::vector<int>* window_ids); | 99 bool GetWindowIds(std::vector<int>* window_ids); |
| 99 | 100 |
| 100 // Switches the window used by default. |name| is either an ID returned by | 101 // Switches the window used by default. |name| is either an ID returned by |
| 101 // |GetWindowIds| or the name attribute of a DOM window. | 102 // |GetWindowIds| or the name attribute of a DOM window. |
| 102 ErrorCode SwitchToWindow(const std::string& name); | 103 ErrorCode SwitchToWindow(const std::string& name); |
| 103 | 104 |
| 104 // Switches the frame used by default. |name_or_id| is either the name or id | 105 // Switches the frame used by default. |name_or_id| is either the name or id |
| 105 // of a frame element. | 106 // of a frame element. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 std::vector<WebElementId>* elements); | 141 std::vector<WebElementId>* elements); |
| 141 | 142 |
| 142 // Scroll the element into view and get its location relative to the client's | 143 // Scroll the element into view and get its location relative to the client's |
| 143 // viewport. | 144 // viewport. |
| 144 ErrorCode GetElementLocationInView( | 145 ErrorCode GetElementLocationInView( |
| 145 const WebElementId& element, int* x, int* y); | 146 const WebElementId& element, int* x, int* y); |
| 146 | 147 |
| 147 // Waits for all tabs to stop loading. Returns true on success. | 148 // Waits for all tabs to stop loading. Returns true on success. |
| 148 bool WaitForAllTabsToStopLoading(); | 149 bool WaitForAllTabsToStopLoading(); |
| 149 | 150 |
| 150 inline const std::string& id() const { return id_; } | 151 std::string Id() const; |
| 151 | 152 |
| 152 inline int implicit_wait() const { return implicit_wait_; } | 153 int ImplicitWait() const; |
| 153 inline void set_implicit_wait(const int& timeout) { | 154 void SetImplicitWait(const int& timeout); |
|
Paweł Hajdan Jr.
2011/03/03 14:43:42
nit: Just int timeout.
| |
| 154 implicit_wait_ = timeout > 0 ? timeout : 0; | |
| 155 } | |
| 156 | 155 |
| 157 enum Speed { kSlow, kMedium, kFast, kUnknown }; | 156 enum InputSpeed { kSlow, kMedium, kFast, kUnknown }; |
| 158 inline Speed speed() { return speed_; } | 157 Session::InputSpeed Speed() const; |
| 159 inline void set_speed(Speed speed) { | 158 void SetSpeed(const InputSpeed& speed); |
| 160 speed_ = speed; | |
| 161 } | |
| 162 | 159 |
| 163 inline const std::string& current_frame_xpath() const { | 160 std::string CurrentFrameXPath() const; |
| 164 return current_frame_xpath_; | 161 void SetCurrentFrameXPath(const std::string& xpath); |
| 165 } | |
| 166 | 162 |
| 167 inline void set_current_frame_xpath(const std::string& xpath) { | 163 int CurrentWindowId() const; |
| 168 current_frame_xpath_ = xpath; | |
| 169 } | |
| 170 | |
| 171 inline int current_window_id() const { return current_window_id_; } | |
| 172 | 164 |
| 173 private: | 165 private: |
| 174 void RunSessionTask(Task* task); | 166 void RunSessionTask(Task* task); |
| 175 void RunSessionTaskOnSessionThread( | 167 void RunSessionTaskOnSessionThread( |
| 176 Task* task, | 168 Task* task, |
| 177 base::WaitableEvent* done_event); | 169 base::WaitableEvent* done_event); |
| 178 void InitOnSessionThread(const FilePath& browser_dir, bool* success); | 170 void InitOnSessionThread(const FilePath& browser_dir, bool* success); |
| 179 void TerminateOnSessionThread(); | 171 void TerminateOnSessionThread(); |
| 180 void SendKeysOnSessionThread(const string16& keys, bool* success); | 172 void SendKeysOnSessionThread(const string16& keys, bool* success); |
| 181 ErrorCode SwitchToFrameWithJavaScriptLocatedFrame( | 173 ErrorCode SwitchToFrameWithJavaScriptLocatedFrame( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 193 const WebElementId& element, | 185 const WebElementId& element, |
| 194 int* offset_x, | 186 int* offset_x, |
| 195 int* offset_y); | 187 int* offset_y); |
| 196 | 188 |
| 197 const std::string id_; | 189 const std::string id_; |
| 198 | 190 |
| 199 scoped_ptr<Automation> automation_; | 191 scoped_ptr<Automation> automation_; |
| 200 base::Thread thread_; | 192 base::Thread thread_; |
| 201 | 193 |
| 202 int implicit_wait_; | 194 int implicit_wait_; |
| 203 Speed speed_; | 195 InputSpeed speed_; |
| 204 | 196 |
| 205 // The XPath to the frame within this session's active tab which all | 197 // The XPath to the frame within this session's active tab which all |
| 206 // commands should be directed to. XPath strings can represent a frame deep | 198 // commands should be directed to. XPath strings can represent a frame deep |
| 207 // down the tree (across multiple frame DOMs). | 199 // down the tree (across multiple frame DOMs). |
| 208 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[1] | 200 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[1] |
| 209 // should break into 2 xpaths | 201 // should break into 2 xpaths |
| 210 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[1]. | 202 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[1]. |
| 211 std::string current_frame_xpath_; | 203 std::string current_frame_xpath_; |
| 212 int current_window_id_; | 204 int current_window_id_; |
| 213 | 205 |
| 214 DISALLOW_COPY_AND_ASSIGN(Session); | 206 DISALLOW_COPY_AND_ASSIGN(Session); |
| 215 }; | 207 }; |
| 216 | 208 |
| 217 } // namespace webdriver | 209 } // namespace webdriver |
| 218 | 210 |
| 219 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); | 211 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); |
| 220 | 212 |
| 221 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ | 213 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ |
| OLD | NEW |