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