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