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/command_listener.h"
22 class DictionaryValue
;
31 FrameInfo(const std::string
& parent_frame_id
,
32 const std::string
& frame_id
,
33 const std::string
& chromedriver_frame_id
);
35 std::string parent_frame_id
;
37 std::string chromedriver_frame_id
;
41 static const base::TimeDelta kDefaultPageLoadTimeout
;
43 explicit Session(const std::string
& id
);
44 Session(const std::string
& id
, scoped_ptr
<Chrome
> chrome
);
47 Status
GetTargetWindow(WebView
** web_view
);
49 void SwitchToTopFrame();
50 void SwitchToParentFrame();
51 void SwitchToSubFrame(const std::string
& frame_id
,
52 const std::string
& chromedriver_frame_id
);
53 std::string
GetCurrentFrameId() const;
54 std::vector
<WebDriverLog
*> GetAllLogs() const;
55 std::string
GetFirstBrowserError() const;
60 bool force_devtools_screenshot
;
61 scoped_ptr
<Chrome
> chrome
;
64 // List of |FrameInfo|s for each frame to the current target frame from the
65 // first frame element in the root document. If target frame is window.top,
66 // this list will be empty.
67 std::list
<FrameInfo
> frames
;
68 WebPoint mouse_position
;
69 base::TimeDelta implicit_wait
;
70 base::TimeDelta page_load_timeout
;
71 base::TimeDelta script_timeout
;
72 scoped_ptr
<std::string
> prompt_text
;
73 scoped_ptr
<Geoposition
> overridden_geoposition
;
74 scoped_ptr
<DeviceMetrics
> overridden_device_metrics
;
75 // Logs that populate from DevTools events.
76 ScopedVector
<WebDriverLog
> devtools_logs
;
77 scoped_ptr
<WebDriverLog
> driver_log
;
78 base::ScopedTempDir temp_dir
;
79 scoped_ptr
<base::DictionaryValue
> capabilities
;
80 bool auto_reporting_enabled
;
81 // |command_listeners| should be declared after |chrome|. When the |Session|
82 // is destroyed, |command_listeners| should be freed first, since some
83 // |CommandListener|s might be |CommandListenerProxy|s that forward to
84 // |DevToolsEventListener|s owned by |chrome|.
85 ScopedVector
<CommandListener
> command_listeners
;
88 Session
* GetThreadLocalSession();
90 void SetThreadLocalSession(scoped_ptr
<Session
> session
);
92 #endif // CHROME_TEST_CHROMEDRIVER_SESSION_H_