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_AUTOMATION_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_AUTOMATION_H_ | 6 #define CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
| 13 #include "chrome/common/automation_constants.h" | |
| 13 #include "chrome/test/automation/browser_proxy.h" | 14 #include "chrome/test/automation/browser_proxy.h" |
| 14 #include "chrome/test/automation/tab_proxy.h" | 15 #include "chrome/test/automation/tab_proxy.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 16 #include "chrome/test/ui/ui_test.h" |
| 17 #include "ui/base/keycodes/keyboard_codes.h" | |
| 16 | 18 |
| 17 namespace webdriver { | 19 namespace webdriver { |
| 18 | 20 |
| 21 struct WebKeyEvent { | |
| 22 WebKeyEvent(automation::KeyEventTypes type, | |
| 23 ui::KeyboardCode key_code, | |
| 24 const std::string& unmodified_text, | |
| 25 const std::string& modified_text, | |
| 26 int modifiers) | |
| 27 : type(type), | |
| 28 key_code(key_code), | |
| 29 unmodified_text(unmodified_text), | |
| 30 modified_text(modified_text), | |
| 31 modifiers(modifiers) {} | |
| 32 | |
| 33 automation::KeyEventTypes type; | |
|
jleyba
2011/02/10 05:52:19
Should these be const?
kkania
2011/02/10 18:17:48
they could be, but I don't see any compelling reas
| |
| 34 ui::KeyboardCode key_code; | |
| 35 std::string unmodified_text; | |
| 36 std::string modified_text; | |
| 37 int modifiers; | |
| 38 }; | |
| 39 | |
| 19 // Creates and controls the Chrome instance. | 40 // Creates and controls the Chrome instance. |
| 20 // This class should be created and accessed on a single thread. | 41 // This class should be created and accessed on a single thread. |
| 21 // TODO(phajdan.jr): Abstract UITestBase classes, see: | 42 // TODO(phajdan.jr): Abstract UITestBase classes, see: |
| 22 // http://code.google.com/p/chromium/issues/detail?id=56865 | 43 // http://code.google.com/p/chromium/issues/detail?id=56865 |
| 23 class Automation : private UITestBase { | 44 class Automation : private UITestBase { |
| 24 public: | 45 public: |
| 25 Automation() {} | 46 Automation() {} |
| 26 | 47 |
| 27 // Creates a browser. | 48 // Creates a browser. |
| 28 void Init(bool* success); | 49 void Init(bool* success); |
| 29 | 50 |
| 30 // Terminates this session and disconnects its automation proxy. After | 51 // Terminates this session and disconnects its automation proxy. After |
| 31 // invoking this method, the Automation can safely be deleted. | 52 // invoking this method, the Automation can safely be deleted. |
| 32 void Terminate(); | 53 void Terminate(); |
| 33 | 54 |
| 34 // Executes the given |script| in the specified frame of the current | 55 // Executes the given |script| in the specified frame of the current |
| 35 // tab. |result| will be set to the JSON result. Returns true on success. | 56 // tab. |result| will be set to the JSON result. Returns true on success. |
| 36 void ExecuteScript(const std::string& frame_xpath, | 57 void ExecuteScript(const std::string& frame_xpath, |
| 37 const std::string& script, | 58 const std::string& script, |
| 38 std::string* result, | 59 std::string* result, |
| 39 bool* success); | 60 bool* success); |
| 40 | 61 |
| 62 // Sends a key event to the current browser. Waits until the key has | |
| 63 // been processed by the web page. | |
| 64 void SendWebKeyEvent(const WebKeyEvent& key_event, bool* success); | |
| 65 | |
| 41 void NavigateToURL(const std::string& url, bool* success); | 66 void NavigateToURL(const std::string& url, bool* success); |
| 42 void GoForward(bool* success); | 67 void GoForward(bool* success); |
| 43 void GoBack(bool* success); | 68 void GoBack(bool* success); |
| 44 void Reload(bool* success); | 69 void Reload(bool* success); |
| 45 void GetURL(std::string* url, bool* success); | 70 void GetURL(std::string* url, bool* success); |
| 46 void GetTabTitle(std::string* tab_title, bool* success); | 71 void GetTabTitle(std::string* tab_title, bool* success); |
| 47 | 72 |
| 48 private: | 73 private: |
| 49 scoped_refptr<BrowserProxy> browser_; | 74 scoped_refptr<BrowserProxy> browser_; |
| 50 scoped_refptr<TabProxy> tab_; | 75 scoped_refptr<TabProxy> tab_; |
| 51 | 76 |
| 52 ScopedTempDir profile_dir_; | 77 ScopedTempDir profile_dir_; |
| 53 | 78 |
| 54 DISALLOW_COPY_AND_ASSIGN(Automation); | 79 DISALLOW_COPY_AND_ASSIGN(Automation); |
| 55 }; | 80 }; |
| 56 | 81 |
| 57 } // namespace webdriver | 82 } // namespace webdriver |
| 58 | 83 |
| 59 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); | 84 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
| 60 | 85 |
| 61 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ | 86 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
| OLD | NEW |