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 #include <vector> |
9 | 10 |
10 #include "base/task.h" | 11 #include "base/task.h" |
11 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
12 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
13 #include "chrome/common/automation_constants.h" | 14 #include "chrome/common/automation_constants.h" |
14 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
15 #include "ui/base/keycodes/keyboard_codes.h" | 16 #include "ui/base/keycodes/keyboard_codes.h" |
16 | 17 |
| 18 class TabProxy; |
| 19 |
17 namespace webdriver { | 20 namespace webdriver { |
18 | 21 |
19 struct WebKeyEvent { | 22 struct WebKeyEvent { |
20 WebKeyEvent(automation::KeyEventTypes type, | 23 WebKeyEvent(automation::KeyEventTypes type, |
21 ui::KeyboardCode key_code, | 24 ui::KeyboardCode key_code, |
22 const std::string& unmodified_text, | 25 const std::string& unmodified_text, |
23 const std::string& modified_text, | 26 const std::string& modified_text, |
24 int modifiers) | 27 int modifiers) |
25 : type(type), | 28 : type(type), |
26 key_code(key_code), | 29 key_code(key_code), |
(...skipping 19 matching lines...) Expand all Loading... |
46 | 49 |
47 // Creates a browser. | 50 // Creates a browser. |
48 void Init(bool* success); | 51 void Init(bool* success); |
49 | 52 |
50 // Terminates this session and disconnects its automation proxy. After | 53 // Terminates this session and disconnects its automation proxy. After |
51 // invoking this method, the Automation can safely be deleted. | 54 // invoking this method, the Automation can safely be deleted. |
52 void Terminate(); | 55 void Terminate(); |
53 | 56 |
54 // Executes the given |script| in the specified frame of the current | 57 // Executes the given |script| in the specified frame of the current |
55 // tab. |result| will be set to the JSON result. Returns true on success. | 58 // tab. |result| will be set to the JSON result. Returns true on success. |
56 void ExecuteScript(const std::string& frame_xpath, | 59 void ExecuteScript(int tab_id, |
| 60 const std::string& frame_xpath, |
57 const std::string& script, | 61 const std::string& script, |
58 std::string* result, | 62 std::string* result, |
59 bool* success); | 63 bool* success); |
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(int tab_id, const WebKeyEvent& key_event, bool* success); |
64 | 68 |
65 void NavigateToURL(const std::string& url, bool* success); | 69 void NavigateToURL(int tab_id, const std::string& url, bool* success); |
66 void GoForward(bool* success); | 70 void GoForward(int tab_id, bool* success); |
67 void GoBack(bool* success); | 71 void GoBack(int tab_id, bool* success); |
68 void Reload(bool* success); | 72 void Reload(int tab_id, bool* success); |
69 void GetURL(std::string* url, bool* success); | 73 void GetURL(int tab_id, std::string* url, bool* success); |
70 void GetTabTitle(std::string* tab_title, bool* success); | 74 void GetTabTitle(int tab_id, std::string* tab_title, bool* success); |
| 75 void GetTabIds(std::vector<int>* tab_ids, bool* success); |
| 76 void CloseTab(int tab_id, bool* success); |
71 | 77 |
72 private: | 78 private: |
73 scoped_refptr<BrowserProxy> browser_; | 79 bool GetTab(int tab_id, TabProxy** tab, bool* success); |
74 scoped_refptr<TabProxy> tab_; | 80 std::vector<scoped_refptr<TabProxy> > tabs_; |
75 | 81 |
76 ScopedTempDir profile_dir_; | 82 ScopedTempDir profile_dir_; |
77 | 83 |
78 DISALLOW_COPY_AND_ASSIGN(Automation); | 84 DISALLOW_COPY_AND_ASSIGN(Automation); |
79 }; | 85 }; |
80 | 86 |
81 } // namespace webdriver | 87 } // namespace webdriver |
82 | 88 |
83 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); | 89 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
84 | 90 |
85 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ | 91 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
OLD | NEW |