| 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/common/automation_constants.h" |
| 14 #include "chrome/test/ui/ui_test.h" | 14 #include "chrome/test/ui/ui_test.h" |
| 15 #include "ui/base/keycodes/keyboard_codes.h" | 15 #include "ui/base/keycodes/keyboard_codes.h" |
| 16 | 16 |
| 17 class GURL; |
| 18 |
| 17 namespace webdriver { | 19 namespace webdriver { |
| 18 | 20 |
| 19 struct WebKeyEvent { | 21 struct WebKeyEvent { |
| 20 WebKeyEvent(automation::KeyEventTypes type, | 22 WebKeyEvent(automation::KeyEventTypes type, |
| 21 ui::KeyboardCode key_code, | 23 ui::KeyboardCode key_code, |
| 22 const std::string& unmodified_text, | 24 const std::string& unmodified_text, |
| 23 const std::string& modified_text, | 25 const std::string& modified_text, |
| 24 int modifiers) | 26 int modifiers) |
| 25 : type(type), | 27 : type(type), |
| 26 key_code(key_code), | 28 key_code(key_code), |
| 27 unmodified_text(unmodified_text), | 29 unmodified_text(unmodified_text), |
| 28 modified_text(modified_text), | 30 modified_text(modified_text), |
| 29 modifiers(modifiers) {} | 31 modifiers(modifiers) {} |
| 30 | 32 |
| 31 automation::KeyEventTypes type; | 33 automation::KeyEventTypes type; |
| 32 ui::KeyboardCode key_code; | 34 ui::KeyboardCode key_code; |
| 33 std::string unmodified_text; | 35 std::string unmodified_text; |
| 34 std::string modified_text; | 36 std::string modified_text; |
| 35 int modifiers; | 37 int modifiers; |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 // Creates and controls the Chrome instance. | 40 // Creates and controls the Chrome instance. |
| 39 // This class should be created and accessed on a single thread. | 41 // This class should be created and accessed on a single thread. |
| 42 // Note: All member functions are void because they are invoked |
| 43 // by posting a task from NewRunnableMethod. |
| 40 // TODO(phajdan.jr): Abstract UITestBase classes, see: | 44 // TODO(phajdan.jr): Abstract UITestBase classes, see: |
| 41 // http://code.google.com/p/chromium/issues/detail?id=56865 | 45 // http://code.google.com/p/chromium/issues/detail?id=56865 |
| 42 class Automation : private UITestBase { | 46 class Automation : private UITestBase { |
| 43 public: | 47 public: |
| 44 Automation(); | 48 Automation(); |
| 45 virtual ~Automation(); | 49 virtual ~Automation(); |
| 46 | 50 |
| 47 // Creates a browser. | 51 // Creates a browser. |
| 48 void Init(bool* success); | 52 void Init(bool* success); |
| 49 | 53 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 | 64 |
| 61 // Sends a key event to the current browser. Waits until the key has | 65 // Sends a key event to the current browser. Waits until the key has |
| 62 // been processed by the web page. | 66 // been processed by the web page. |
| 63 void SendWebKeyEvent(const WebKeyEvent& key_event, bool* success); | 67 void SendWebKeyEvent(const WebKeyEvent& key_event, bool* success); |
| 64 | 68 |
| 65 void NavigateToURL(const std::string& url, bool* success); | 69 void NavigateToURL(const std::string& url, bool* success); |
| 66 void GoForward(bool* success); | 70 void GoForward(bool* success); |
| 67 void GoBack(bool* success); | 71 void GoBack(bool* success); |
| 68 void Reload(bool* success); | 72 void Reload(bool* success); |
| 69 void GetURL(std::string* url, bool* success); | 73 void GetURL(std::string* url, bool* success); |
| 74 void GetGURL(GURL* gurl, bool* success); |
| 70 void GetTabTitle(std::string* tab_title, bool* success); | 75 void GetTabTitle(std::string* tab_title, bool* success); |
| 76 void GetCookies(const GURL& gurl, std::string* cookies, bool* success); |
| 77 void GetCookieByName(const GURL& gurl, const std::string& cookie_name, |
| 78 std::string* cookie, bool* success); |
| 79 void DeleteCookie(const GURL& gurl, const std::string& cookie_name, |
| 80 bool* success); |
| 81 void SetCookie(const GURL& gurl, const std::string& cookie, bool* success); |
| 71 | 82 |
| 72 private: | 83 private: |
| 73 scoped_refptr<BrowserProxy> browser_; | 84 scoped_refptr<BrowserProxy> browser_; |
| 74 scoped_refptr<TabProxy> tab_; | 85 scoped_refptr<TabProxy> tab_; |
| 75 | 86 |
| 76 ScopedTempDir profile_dir_; | 87 ScopedTempDir profile_dir_; |
| 77 | 88 |
| 78 DISALLOW_COPY_AND_ASSIGN(Automation); | 89 DISALLOW_COPY_AND_ASSIGN(Automation); |
| 79 }; | 90 }; |
| 80 | 91 |
| 81 } // namespace webdriver | 92 } // namespace webdriver |
| 82 | 93 |
| 83 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); | 94 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
| 84 | 95 |
| 85 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ | 96 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
| OLD | NEW |