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