Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / test / chromedriver / session.h
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.
4
5 #ifndef CHROME_TEST_CHROMEDRIVER_SESSION_H_
6 #define CHROME_TEST_CHROMEDRIVER_SESSION_H_
7
8 #include <list>
9 #include <string>
10
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"
20
21 namespace base {
22 class DictionaryValue;
23 }
24
25 class Chrome;
26 class Status;
27 class WebDriverLog;
28 class WebView;
29
30 struct FrameInfo {
31   FrameInfo(const std::string& parent_frame_id,
32             const std::string& frame_id,
33             const std::string& chromedriver_frame_id);
34
35   std::string parent_frame_id;
36   std::string frame_id;
37   std::string chromedriver_frame_id;
38 };
39
40 struct Session {
41   static const base::TimeDelta kDefaultPageLoadTimeout;
42
43   explicit Session(const std::string& id);
44   Session(const std::string& id, scoped_ptr<Chrome> chrome);
45   ~Session();
46
47   Status GetTargetWindow(WebView** web_view);
48
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;
56
57   const std::string id;
58   bool quit;
59   bool detach;
60   bool force_devtools_screenshot;
61   scoped_ptr<Chrome> chrome;
62   std::string window;
63   int sticky_modifiers;
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;
86 };
87
88 Session* GetThreadLocalSession();
89
90 void SetThreadLocalSession(scoped_ptr<Session> session);
91
92 #endif  // CHROME_TEST_CHROMEDRIVER_SESSION_H_