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_WEBDRIVER_SESSION_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_H_ |
6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_H_ | 6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_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/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "chrome/common/automation_constants.h" | 17 #include "chrome/common/automation_constants.h" |
| 18 #include "chrome/test/automation/automation_json_requests.h" |
18 #include "chrome/test/webdriver/frame_path.h" | 19 #include "chrome/test/webdriver/frame_path.h" |
19 #include "chrome/test/webdriver/webdriver_automation.h" | 20 #include "chrome/test/webdriver/webdriver_automation.h" |
20 #include "chrome/test/webdriver/webdriver_basic_types.h" | 21 #include "chrome/test/webdriver/webdriver_basic_types.h" |
21 #include "chrome/test/webdriver/webdriver_element_id.h" | 22 #include "chrome/test/webdriver/webdriver_element_id.h" |
22 | 23 |
23 class FilePath; | 24 class FilePath; |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class DictionaryValue; | 27 class DictionaryValue; |
27 class ListValue; | 28 class ListValue; |
28 class Value; | 29 class Value; |
29 class WaitableEvent; | 30 class WaitableEvent; |
30 } | 31 } |
31 | 32 |
32 namespace webdriver { | 33 namespace webdriver { |
33 | 34 |
34 class Error; | 35 class Error; |
35 class ValueParser; | 36 class ValueParser; |
36 | 37 |
37 // A window ID and frame path combination that uniquely identifies a specific | 38 // A view ID and frame path combination that uniquely identifies a specific |
38 // frame within a session. | 39 // frame within a session. |
39 struct FrameId { | 40 struct FrameId { |
40 FrameId(int window_id, const FramePath& frame_path); | 41 FrameId(); |
41 FrameId& operator=(const FrameId& other); | 42 FrameId(const WebViewId& view_id, const FramePath& frame_path); |
42 int window_id; | 43 // FrameId& operator=(const FrameId& other); |
| 44 WebViewId view_id; |
43 FramePath frame_path; | 45 FramePath frame_path; |
44 }; | 46 }; |
45 | 47 |
46 // Every connection made by WebDriver maps to a session object. | 48 // Every connection made by WebDriver maps to a session object. |
47 // This object creates the chrome instance and keeps track of the | 49 // This object creates the chrome instance and keeps track of the |
48 // state necessary to control the chrome browser created. | 50 // state necessary to control the chrome browser created. |
49 // A session manages its own lifetime. | 51 // A session manages its own lifetime. |
50 class Session { | 52 class Session { |
51 public: | 53 public: |
52 struct Options { | 54 struct Options { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 Error* GoForward(); | 145 Error* GoForward(); |
144 Error* GoBack(); | 146 Error* GoBack(); |
145 Error* Reload(); | 147 Error* Reload(); |
146 Error* GetURL(std::string* url); | 148 Error* GetURL(std::string* url); |
147 Error* GetTitle(std::string* tab_title); | 149 Error* GetTitle(std::string* tab_title); |
148 Error* GetScreenShot(std::string* png); | 150 Error* GetScreenShot(std::string* png); |
149 Error* GetCookies(const std::string& url, base::ListValue** cookies); | 151 Error* GetCookies(const std::string& url, base::ListValue** cookies); |
150 Error* DeleteCookie(const std::string& url, const std::string& cookie_name); | 152 Error* DeleteCookie(const std::string& url, const std::string& cookie_name); |
151 Error* SetCookie(const std::string& url, base::DictionaryValue* cookie_dict); | 153 Error* SetCookie(const std::string& url, base::DictionaryValue* cookie_dict); |
152 | 154 |
153 // Gets all the currently existing window IDs. Returns true on success. | 155 // Gets all the currently existing views. |
154 Error* GetWindowIds(std::vector<int>* window_ids); | 156 Error* GetViews(std::vector<WebViewInfo>* views); |
155 | 157 |
156 // Switches the window used by default. |name| is either an ID returned by | 158 // Switches the view used by default. |id_or_name| is either a view ID |
157 // |GetWindowIds| or the name attribute of a DOM window. | 159 // returned by |GetViews| or the name attribute of a DOM window. |
158 Error* SwitchToWindow(const std::string& name); | 160 // Only tabs are considered when searching by name. |
| 161 Error* SwitchToView(const std::string& id_or_name); |
159 | 162 |
160 // Switches the frame used by default. |name_or_id| is either the name or id | 163 // Switches the frame used by default. |name_or_id| is either the name or id |
161 // of a frame element. | 164 // of a frame element. |
162 Error* SwitchToFrameWithNameOrId(const std::string& name_or_id); | 165 Error* SwitchToFrameWithNameOrId(const std::string& name_or_id); |
163 | 166 |
164 // Switches the frame used by default. |index| is the zero-based frame index. | 167 // Switches the frame used by default. |index| is the zero-based frame index. |
165 Error* SwitchToFrameWithIndex(int index); | 168 Error* SwitchToFrameWithIndex(int index); |
166 | 169 |
167 // Switches to the frame identified by the given |element|. The element must | 170 // Switches to the frame identified by the given |element|. The element must |
168 // be either an IFRAME or FRAME element. | 171 // be either an IFRAME or FRAME element. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 Options options_; | 419 Options options_; |
417 | 420 |
418 DISALLOW_COPY_AND_ASSIGN(Session); | 421 DISALLOW_COPY_AND_ASSIGN(Session); |
419 }; | 422 }; |
420 | 423 |
421 } // namespace webdriver | 424 } // namespace webdriver |
422 | 425 |
423 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); | 426 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); |
424 | 427 |
425 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_H_ | 428 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_SESSION_H_ |
OLD | NEW |