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

Side by Side Diff: chrome/test/chromedriver/session.h

Issue 331943003: [ChromeDriver] Added CommandListener interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHROMEDRIVER_SESSION_H_ 5 #ifndef CHROME_TEST_CHROMEDRIVER_SESSION_H_
6 #define CHROME_TEST_CHROMEDRIVER_SESSION_H_ 6 #define CHROME_TEST_CHROMEDRIVER_SESSION_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/test/chromedriver/basic_types.h" 16 #include "chrome/test/chromedriver/basic_types.h"
17 #include "chrome/test/chromedriver/chrome/device_metrics.h" 17 #include "chrome/test/chromedriver/chrome/device_metrics.h"
18 #include "chrome/test/chromedriver/chrome/geoposition.h" 18 #include "chrome/test/chromedriver/chrome/geoposition.h"
19 #include "chrome/test/chromedriver/command_listener.h"
19 20
20 namespace base { 21 namespace base {
21 class DictionaryValue; 22 class DictionaryValue;
22 } 23 }
23 24
24 class Chrome; 25 class Chrome;
25 class Status; 26 class Status;
26 class WebDriverLog; 27 class WebDriverLog;
27 class WebView; 28 class WebView;
28 29
29 struct FrameInfo { 30 struct FrameInfo {
30 FrameInfo(const std::string& parent_frame_id, 31 FrameInfo(const std::string& parent_frame_id,
31 const std::string& frame_id, 32 const std::string& frame_id,
32 const std::string& chromedriver_frame_id); 33 const std::string& chromedriver_frame_id);
33 34
34 std::string parent_frame_id; 35 std::string parent_frame_id;
35 std::string frame_id; 36 std::string frame_id;
36 std::string chromedriver_frame_id; 37 std::string chromedriver_frame_id;
37 }; 38 };
38 39
39 struct Session { 40 struct Session : public CommandListener {
stgao 2014/06/15 23:54:40 Composite pattern might not be good here. We'd bet
40 static const base::TimeDelta kDefaultPageLoadTimeout; 41 static const base::TimeDelta kDefaultPageLoadTimeout;
41 42
42 explicit Session(const std::string& id); 43 explicit Session(const std::string& id);
43 Session(const std::string& id, scoped_ptr<Chrome> chrome); 44 Session(const std::string& id, scoped_ptr<Chrome> chrome);
44 ~Session(); 45 ~Session();
45 46
46 Status GetTargetWindow(WebView** web_view); 47 Status GetTargetWindow(WebView** web_view);
48 virtual Status OnCommand(const std::string& command_name) OVERRIDE;
47 49
48 void SwitchToTopFrame(); 50 void SwitchToTopFrame();
49 void SwitchToParentFrame(); 51 void SwitchToParentFrame();
50 void SwitchToSubFrame(const std::string& frame_id, 52 void SwitchToSubFrame(const std::string& frame_id,
51 const std::string& chromedriver_frame_id); 53 const std::string& chromedriver_frame_id);
54 void AddListener(CommandListener* listener);
52 std::string GetCurrentFrameId() const; 55 std::string GetCurrentFrameId() const;
53 std::vector<WebDriverLog*> GetAllLogs() const; 56 std::vector<WebDriverLog*> GetAllLogs() const;
54 std::string GetFirstBrowserError() const; 57 std::string GetFirstBrowserError() const;
55 58
56 const std::string id; 59 const std::string id;
57 bool quit; 60 bool quit;
58 bool detach; 61 bool detach;
59 bool force_devtools_screenshot; 62 bool force_devtools_screenshot;
60 scoped_ptr<Chrome> chrome; 63 scoped_ptr<Chrome> chrome;
61 std::string window; 64 std::string window;
62 int sticky_modifiers; 65 int sticky_modifiers;
63 // List of |FrameInfo|s for each frame to the current target frame from the 66 // List of |FrameInfo|s for each frame to the current target frame from the
64 // first frame element in the root document. If target frame is window.top, 67 // first frame element in the root document. If target frame is window.top,
65 // this list will be empty. 68 // this list will be empty.
66 std::list<FrameInfo> frames; 69 std::list<FrameInfo> frames;
67 WebPoint mouse_position; 70 WebPoint mouse_position;
68 base::TimeDelta implicit_wait; 71 base::TimeDelta implicit_wait;
69 base::TimeDelta page_load_timeout; 72 base::TimeDelta page_load_timeout;
70 base::TimeDelta script_timeout; 73 base::TimeDelta script_timeout;
71 scoped_ptr<std::string> prompt_text; 74 scoped_ptr<std::string> prompt_text;
72 scoped_ptr<Geoposition> overridden_geoposition; 75 scoped_ptr<Geoposition> overridden_geoposition;
73 scoped_ptr<DeviceMetrics> overridden_device_metrics; 76 scoped_ptr<DeviceMetrics> overridden_device_metrics;
74 // Logs that populate from DevTools events. 77 // Logs that populate from DevTools events.
75 ScopedVector<WebDriverLog> devtools_logs; 78 ScopedVector<WebDriverLog> devtools_logs;
76 scoped_ptr<WebDriverLog> driver_log; 79 scoped_ptr<WebDriverLog> driver_log;
77 base::ScopedTempDir temp_dir; 80 base::ScopedTempDir temp_dir;
78 scoped_ptr<base::DictionaryValue> capabilities; 81 scoped_ptr<base::DictionaryValue> capabilities;
79 bool auto_reporting_enabled; 82 bool auto_reporting_enabled;
83 ScopedVector<CommandListener> command_listeners_;
80 }; 84 };
81 85
82 Session* GetThreadLocalSession(); 86 Session* GetThreadLocalSession();
83 87
84 void SetThreadLocalSession(scoped_ptr<Session> session); 88 void SetThreadLocalSession(scoped_ptr<Session> session);
85 89
86 #endif // CHROME_TEST_CHROMEDRIVER_SESSION_H_ 90 #endif // CHROME_TEST_CHROMEDRIVER_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698