Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/test/webdriver/automation.h

Issue 6614023: Convert ChromeDriver to use only the JSON automation interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Pawel's additional comments Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/automation/automation_json_requests.cc ('k') | chrome/test/webdriver/automation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/task.h" 12 #include "base/task.h"
13 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
14 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
15 #include "chrome/common/automation_constants.h" 15 #include "chrome/common/automation_constants.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
17 17
18 class AutomationProxy; 18 class AutomationProxy;
19 class DictionaryValue; 19 class DictionaryValue;
20 class FilePath; 20 class FilePath;
21 class GURL; 21 class GURL;
22 class ProxyLauncher; 22 class ProxyLauncher;
23 class TabProxy; 23 struct WebKeyEvent;
24 24
25 namespace gfx { 25 namespace gfx {
26 class Point; 26 class Point;
27 } 27 }
28 28
29 namespace webdriver { 29 namespace webdriver {
30 30
31 struct WebKeyEvent {
32 WebKeyEvent(automation::KeyEventTypes type,
33 ui::KeyboardCode key_code,
34 const std::string& unmodified_text,
35 const std::string& modified_text,
36 int modifiers);
37
38 automation::KeyEventTypes type;
39 ui::KeyboardCode key_code;
40 std::string unmodified_text;
41 std::string modified_text;
42 int modifiers;
43 };
44
45 // Creates and controls the Chrome instance. 31 // Creates and controls the Chrome instance.
46 // This class should be created and accessed on a single thread. 32 // This class should be created and accessed on a single thread.
47 // Note: All member functions are void because they are invoked 33 // Note: All member functions are void because they are invoked
48 // by posting a task from NewRunnableMethod. 34 // by posting a task from NewRunnableMethod.
49 class Automation { 35 class Automation {
50 public: 36 public:
51 Automation(); 37 Automation();
52 virtual ~Automation(); 38 virtual ~Automation();
53 39
54 // Creates a browser, using the exe found in |browser_dir|. If |browser_dir| 40 // Creates a browser, using the exe found in |browser_dir|. If |browser_dir|
(...skipping 18 matching lines...) Expand all
73 59
74 void NavigateToURL(int tab_id, const std::string& url, bool* success); 60 void NavigateToURL(int tab_id, const std::string& url, bool* success);
75 void GoForward(int tab_id, bool* success); 61 void GoForward(int tab_id, bool* success);
76 void GoBack(int tab_id, bool* success); 62 void GoBack(int tab_id, bool* success);
77 void Reload(int tab_id, bool* success); 63 void Reload(int tab_id, bool* success);
78 void GetURL(int tab_id, std::string* url, bool* success); 64 void GetURL(int tab_id, std::string* url, bool* success);
79 void GetGURL(int tab_id, GURL* gurl, bool* success); 65 void GetGURL(int tab_id, GURL* gurl, bool* success);
80 void GetTabTitle(int tab_id, std::string* tab_title, bool* success); 66 void GetTabTitle(int tab_id, std::string* tab_title, bool* success);
81 void GetCookies( 67 void GetCookies(
82 int tab_id, const GURL& gurl, std::string* cookies, bool* success); 68 int tab_id, const GURL& gurl, std::string* cookies, bool* success);
83 void GetCookieByName(int tab_id,
84 const GURL& gurl,
85 const std::string& cookie_name,
86 std::string* cookie,
87 bool* success);
88 void DeleteCookie(int tab_id, 69 void DeleteCookie(int tab_id,
89 const GURL& gurl, 70 const GURL& gurl,
90 const std::string& cookie_name, 71 const std::string& cookie_name,
91 bool* success); 72 bool* success);
92 void SetCookie( 73 void SetCookie(
93 int tab_id, const GURL& gurl, const std::string& cookie, bool* success); 74 int tab_id, const GURL& gurl, const std::string& cookie, bool* success);
94 void MouseMove(int tab_id, const gfx::Point& p, bool* success); 75 void MouseMove(int tab_id, const gfx::Point& p, bool* success);
95 void MouseClick(int tab_id, const gfx::Point& p, int flag, bool* success); 76 void MouseClick(int tab_id,
77 const gfx::Point& p,
78 automation::MouseButton button,
79 bool* success);
96 void MouseDrag(int tab_id, 80 void MouseDrag(int tab_id,
97 const gfx::Point& start, 81 const gfx::Point& start,
98 const gfx::Point& end, 82 const gfx::Point& end,
99 bool* success); 83 bool* success);
100 84
101 // Get persistent IDs for all the tabs currently open. These IDs can be used 85 // Get persistent IDs for all the tabs currently open. These IDs can be used
102 // to identify the tab as long as the tab exists. 86 // to identify the tab as long as the tab exists.
103 void GetTabIds(std::vector<int>* tab_ids, bool* success); 87 void GetTabIds(std::vector<int>* tab_ids, bool* success);
104 88
105 // Check if the given tab exists currently. 89 // Check if the given tab exists currently.
106 void DoesTabExist(int tab_id, bool* does_exist); 90 void DoesTabExist(int tab_id, bool* does_exist, bool* success);
107 91
108 void CloseTab(int tab_id, bool* success); 92 void CloseTab(int tab_id, bool* success);
109 93
110 // Gets the version of the runing browser. 94 // Gets the version of the runing browser.
111 void GetVersion(std::string* version); 95 void GetVersion(std::string* version);
112 96
113 // Waits for all tabs to stop loading. 97 // Waits for all tabs to stop loading.
114 void WaitForAllTabsToStopLoading(bool* success); 98 void WaitForAllTabsToStopLoading(bool* success);
115 99
116 private: 100 private:
117 typedef std::map<int, scoped_refptr<TabProxy> > TabIdMap;
118
119 TabProxy* GetTabById(int tab_id);
120 AutomationProxy* automation() const; 101 AutomationProxy* automation() const;
102 bool GetIndicesForTab(int tab_id, int* browser_index, int* tab_index);
121 103
122 scoped_ptr<ProxyLauncher> launcher_; 104 scoped_ptr<ProxyLauncher> launcher_;
123 // Map from tab ID to |TabProxy|. The tab ID is simply the |AutomationHandle|
124 // for the proxy.
125 TabIdMap tab_id_map_;
126
127 bool SendJSONRequest(
128 int tab_id, const DictionaryValue& dict, std::string* reply);
129
130 bool GetIndicesForTab(int tab_id, int* browser_index, int* tab_index);
131 105
132 DISALLOW_COPY_AND_ASSIGN(Automation); 106 DISALLOW_COPY_AND_ASSIGN(Automation);
133 }; 107 };
134 108
135 } // namespace webdriver 109 } // namespace webdriver
136 110
137 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); 111 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation);
138 112
139 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ 113 #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_json_requests.cc ('k') | chrome/test/webdriver/automation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698