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
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_CHROMEDRIVER_SESSION_H_
6 #define CHROME_TEST_CHROMEDRIVER_SESSION_H_
11 #include "base/basictypes.h"
12 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/time/time.h"
16 #include "chrome/test/chromedriver/basic_types.h"
17 #include "chrome/test/chromedriver/chrome/device_metrics.h"
18 #include "chrome/test/chromedriver/chrome/geoposition.h"
19 #include "chrome/test/chromedriver/chrome/network_conditions.h"
20 #include "chrome/test/chromedriver/command_listener.h"
23 class DictionaryValue
;
32 FrameInfo(const std::string
& parent_frame_id
,
33 const std::string
& frame_id
,
34 const std::string
& chromedriver_frame_id
);
36 std::string parent_frame_id
;
38 std::string chromedriver_frame_id
;
42 static const base::TimeDelta kDefaultPageLoadTimeout
;
44 explicit Session(const std::string
& id
);
45 Session(const std::string
& id
, scoped_ptr
<Chrome
> chrome
);
48 Status
GetTargetWindow(WebView
** web_view
);
50 void SwitchToTopFrame();
51 void SwitchToParentFrame();
52 void SwitchToSubFrame(const std::string
& frame_id
,
53 const std::string
& chromedriver_frame_id
);
54 std::string
GetCurrentFrameId() const;
55 std::vector
<WebDriverLog
*> GetAllLogs() const;
56 std::string
GetFirstBrowserError() const;
61 bool force_devtools_screenshot
;
62 scoped_ptr
<Chrome
> chrome
;
65 // List of |FrameInfo|s for each frame to the current target frame from the
66 // first frame element in the root document. If target frame is window.top,
67 // this list will be empty.
68 std::list
<FrameInfo
> frames
;
69 WebPoint mouse_position
;
70 base::TimeDelta implicit_wait
;
71 base::TimeDelta page_load_timeout
;
72 base::TimeDelta script_timeout
;
73 scoped_ptr
<std::string
> prompt_text
;
74 scoped_ptr
<Geoposition
> overridden_geoposition
;
75 scoped_ptr
<DeviceMetrics
> overridden_device_metrics
;
76 scoped_ptr
<NetworkConditions
> overridden_network_conditions
;
77 // Logs that populate from DevTools events.
78 ScopedVector
<WebDriverLog
> devtools_logs
;
79 scoped_ptr
<WebDriverLog
> driver_log
;
80 base::ScopedTempDir temp_dir
;
81 scoped_ptr
<base::DictionaryValue
> capabilities
;
82 bool auto_reporting_enabled
;
83 // |command_listeners| should be declared after |chrome|. When the |Session|
84 // is destroyed, |command_listeners| should be freed first, since some
85 // |CommandListener|s might be |CommandListenerProxy|s that forward to
86 // |DevToolsEventListener|s owned by |chrome|.
87 ScopedVector
<CommandListener
> command_listeners
;
90 Session
* GetThreadLocalSession();
92 void SetThreadLocalSession(scoped_ptr
<Session
> session
);
94 #endif // CHROME_TEST_CHROMEDRIVER_SESSION_H_