Upstream version 7.36.149.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/geoposition.h"
18
19 namespace base {
20 class DictionaryValue;
21 }
22
23 class Chrome;
24 class Status;
25 class WebDriverLog;
26 class WebView;
27
28 struct FrameInfo {
29   FrameInfo(const std::string& parent_frame_id,
30             const std::string& frame_id,
31             const std::string& chromedriver_frame_id);
32
33   std::string parent_frame_id;
34   std::string frame_id;
35   std::string chromedriver_frame_id;
36 };
37
38 struct Session {
39   static const base::TimeDelta kDefaultPageLoadTimeout;
40
41   explicit Session(const std::string& id);
42   Session(const std::string& id, scoped_ptr<Chrome> chrome);
43   ~Session();
44
45   Status GetTargetWindow(WebView** web_view);
46
47   void SwitchToTopFrame();
48   void SwitchToParentFrame();
49   void SwitchToSubFrame(const std::string& frame_id,
50                         const std::string& chromedriver_frame_id);
51   std::string GetCurrentFrameId() const;
52   std::vector<WebDriverLog*> GetAllLogs() const;
53   std::string GetFirstBrowserError() const;
54
55   const std::string id;
56   bool quit;
57   bool detach;
58   bool force_devtools_screenshot;
59   scoped_ptr<Chrome> chrome;
60   std::string window;
61   int sticky_modifiers;
62   // List of |FrameInfo|s for each frame to the current target frame from the
63   // first frame element in the root document. If target frame is window.top,
64   // this list will be empty.
65   std::list<FrameInfo> frames;
66   WebPoint mouse_position;
67   base::TimeDelta implicit_wait;
68   base::TimeDelta page_load_timeout;
69   base::TimeDelta script_timeout;
70   scoped_ptr<std::string> prompt_text;
71   scoped_ptr<Geoposition> overridden_geoposition;
72   // Logs that populate from DevTools events.
73   ScopedVector<WebDriverLog> devtools_logs;
74   scoped_ptr<WebDriverLog> driver_log;
75   base::ScopedTempDir temp_dir;
76   scoped_ptr<base::DictionaryValue> capabilities;
77   bool auto_reporting_enabled;
78 };
79
80 Session* GetThreadLocalSession();
81
82 void SetThreadLocalSession(scoped_ptr<Session> session);
83
84 #endif  // CHROME_TEST_CHROMEDRIVER_SESSION_H_