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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/command_line.h" |
12 #include "base/file_path.h" | 13 #include "base/file_path.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/task.h" | 16 #include "base/task.h" |
16 #include "chrome/common/automation_constants.h" | 17 #include "chrome/common/automation_constants.h" |
17 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
18 | 19 |
19 class AutomationProxy; | 20 class AutomationProxy; |
20 class CommandLine; | |
21 class FilePath; | 21 class FilePath; |
22 class ProxyLauncher; | 22 class ProxyLauncher; |
23 struct WebKeyEvent; | 23 struct WebKeyEvent; |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class DictionaryValue; | 26 class DictionaryValue; |
27 class ListValue; | 27 class ListValue; |
28 } | 28 } |
29 | 29 |
30 namespace gfx { | 30 namespace gfx { |
31 class Point; | 31 class Point; |
32 } | 32 } |
33 | 33 |
34 namespace webdriver { | 34 namespace webdriver { |
35 | 35 |
36 class Error; | 36 class Error; |
37 class FramePath; | 37 class FramePath; |
38 | 38 |
39 // Creates and controls the Chrome instance. | 39 // Creates and controls the Chrome instance. |
40 // This class should be created and accessed on a single thread. | 40 // This class should be created and accessed on a single thread. |
41 // Note: All member functions are void because they are invoked | 41 // Note: All member functions are void because they are invoked |
42 // by posting a task from NewRunnableMethod. | 42 // by posting a task from NewRunnableMethod. |
43 class Automation { | 43 class Automation { |
44 public: | 44 public: |
| 45 struct InitOptions { |
| 46 InitOptions(); |
| 47 ~InitOptions(); |
| 48 |
| 49 CommandLine cmdline; |
| 50 FilePath user_data_dir; |
| 51 std::string channel_id; |
| 52 }; |
| 53 |
45 Automation(); | 54 Automation(); |
46 virtual ~Automation(); | 55 virtual ~Automation(); |
47 | 56 |
48 // Creates a browser, using the specified |browser_exe| and |user_data_dir|. | |
49 void InitWithBrowserPath(const FilePath& browser_exe, | |
50 const FilePath& user_data_dir, | |
51 const CommandLine& options, | |
52 Error** error); | |
53 | |
54 // Start the system's default Chrome binary. | 57 // Start the system's default Chrome binary. |
55 void Init(const CommandLine& options, | 58 void Init(const InitOptions& options, Error** error); |
56 const FilePath& user_data_dir, | |
57 Error** error); | |
58 | 59 |
59 // Terminates this session and disconnects its automation proxy. After | 60 // Terminates this session and disconnects its automation proxy. After |
60 // invoking this method, the Automation can safely be deleted. | 61 // invoking this method, the Automation can safely be deleted. |
61 void Terminate(); | 62 void Terminate(); |
62 | 63 |
63 // Executes the given |script| in the specified frame of the current | 64 // Executes the given |script| in the specified frame of the current |
64 // tab. |result| will be set to the JSON result. Returns true on success. | 65 // tab. |result| will be set to the JSON result. Returns true on success. |
65 void ExecuteScript(int tab_id, | 66 void ExecuteScript(int tab_id, |
66 const FramePath& frame_path, | 67 const FramePath& frame_path, |
67 const std::string& script, | 68 const std::string& script, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 scoped_ptr<ProxyLauncher> launcher_; | 166 scoped_ptr<ProxyLauncher> launcher_; |
166 | 167 |
167 DISALLOW_COPY_AND_ASSIGN(Automation); | 168 DISALLOW_COPY_AND_ASSIGN(Automation); |
168 }; | 169 }; |
169 | 170 |
170 } // namespace webdriver | 171 } // namespace webdriver |
171 | 172 |
172 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); | 173 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
173 | 174 |
174 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ | 175 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
OLD | NEW |