| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/string16.h" |
| 12 #include "base/values.h" |
| 11 #include "chrome/test/webdriver/automation.h" | 13 #include "chrome/test/webdriver/automation.h" |
| 12 #include "chrome/test/webdriver/error_codes.h" | 14 #include "chrome/test/webdriver/error_codes.h" |
| 13 | 15 |
| 14 namespace base { | 16 namespace base { |
| 15 class WaitableEvent; | 17 class WaitableEvent; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace webdriver { | 20 namespace webdriver { |
| 19 | 21 |
| 20 // Every connection made by WebDriver maps to a session object. | 22 // Every connection made by WebDriver maps to a session object. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 | 37 |
| 36 // Executes the given |script| in the context of the frame that is currently | 38 // Executes the given |script| in the context of the frame that is currently |
| 37 // the focus of this session. The |script| should be in the form of a | 39 // the focus of this session. The |script| should be in the form of a |
| 38 // function body (e.g. "return arguments[0]"), where \args| is the list of | 40 // function body (e.g. "return arguments[0]"), where \args| is the list of |
| 39 // arguments to pass to the function. The caller is responsible for the | 41 // arguments to pass to the function. The caller is responsible for the |
| 40 // script result |value|. | 42 // script result |value|. |
| 41 ErrorCode ExecuteScript(const std::string& script, | 43 ErrorCode ExecuteScript(const std::string& script, |
| 42 const ListValue* const args, | 44 const ListValue* const args, |
| 43 Value** value); | 45 Value** value); |
| 44 | 46 |
| 47 // Send the given keys to the given element dictionary. This function takes |
| 48 // ownership of |element|. |
| 49 ErrorCode SendKeys(DictionaryValue* element, const string16& keys); |
| 45 | 50 |
| 46 bool NavigateToURL(const std::string& url); | 51 bool NavigateToURL(const std::string& url); |
| 47 bool GoForward(); | 52 bool GoForward(); |
| 48 bool GoBack(); | 53 bool GoBack(); |
| 49 bool Reload(); | 54 bool Reload(); |
| 50 bool GetURL(std::string* url); | 55 bool GetURL(std::string* url); |
| 51 bool GetTabTitle(std::string* tab_title); | 56 bool GetTabTitle(std::string* tab_title); |
| 52 | 57 |
| 53 inline const std::string& id() const { return id_; } | 58 inline const std::string& id() const { return id_; } |
| 54 | 59 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 current_frame_xpath_ = xpath; | 76 current_frame_xpath_ = xpath; |
| 72 } | 77 } |
| 73 | 78 |
| 74 private: | 79 private: |
| 75 void RunSessionTask(Task* task); | 80 void RunSessionTask(Task* task); |
| 76 void RunSessionTaskOnSessionThread( | 81 void RunSessionTaskOnSessionThread( |
| 77 Task* task, | 82 Task* task, |
| 78 base::WaitableEvent* done_event); | 83 base::WaitableEvent* done_event); |
| 79 void InitOnSessionThread(bool* success); | 84 void InitOnSessionThread(bool* success); |
| 80 void TerminateOnSessionThread(); | 85 void TerminateOnSessionThread(); |
| 86 void SendKeysOnSessionThread(const string16& keys, bool* success); |
| 81 | 87 |
| 82 scoped_ptr<Automation> automation_; | 88 scoped_ptr<Automation> automation_; |
| 83 base::Thread thread_; | 89 base::Thread thread_; |
| 84 | 90 |
| 85 const std::string id_; | 91 const std::string id_; |
| 86 | 92 |
| 87 int window_num_; | 93 int window_num_; |
| 88 | 94 |
| 89 int implicit_wait_; | 95 int implicit_wait_; |
| 90 Speed speed_; | 96 Speed speed_; |
| 91 | 97 |
| 92 // The XPath to the frame within this session's active tab which all | 98 // The XPath to the frame within this session's active tab which all |
| 93 // commands should be directed to. XPath strings can represent a frame deep | 99 // commands should be directed to. XPath strings can represent a frame deep |
| 94 // down the tree (across multiple frame DOMs). | 100 // down the tree (across multiple frame DOMs). |
| 95 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[1] | 101 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[1] |
| 96 // should break into 2 xpaths | 102 // should break into 2 xpaths |
| 97 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[1]. | 103 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[1]. |
| 98 std::string current_frame_xpath_; | 104 std::string current_frame_xpath_; |
| 99 | 105 |
| 100 DISALLOW_COPY_AND_ASSIGN(Session); | 106 DISALLOW_COPY_AND_ASSIGN(Session); |
| 101 }; | 107 }; |
| 102 | 108 |
| 103 } // namespace webdriver | 109 } // namespace webdriver |
| 104 | 110 |
| 105 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); | 111 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); |
| 106 | 112 |
| 107 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ | 113 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ |
| OLD | NEW |