Home | History | Annotate | Download | only in chromedriver
      1 // Copyright (c) 2013 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_CAPABILITIES_H_
      6 #define CHROME_TEST_CHROMEDRIVER_CAPABILITIES_H_
      7 
      8 #include <map>
      9 #include <set>
     10 #include <string>
     11 #include <vector>
     12 
     13 #include "base/command_line.h"
     14 #include "base/files/file_path.h"
     15 #include "base/memory/scoped_ptr.h"
     16 #include "base/strings/string16.h"
     17 #include "chrome/test/chromedriver/chrome/device_metrics.h"
     18 #include "chrome/test/chromedriver/chrome/log.h"
     19 #include "chrome/test/chromedriver/net/net_util.h"
     20 
     21 namespace base {
     22 class CommandLine;
     23 class DictionaryValue;
     24 }
     25 
     26 class Status;
     27 
     28 class Switches {
     29  public:
     30   typedef base::FilePath::StringType NativeString;
     31   Switches();
     32   ~Switches();
     33 
     34   void SetSwitch(const std::string& name);
     35   void SetSwitch(const std::string& name, const std::string& value);
     36   void SetSwitch(const std::string& name, const base::string16& value);
     37   void SetSwitch(const std::string& name, const base::FilePath& value);
     38 
     39   // In case of same key, |switches| will override.
     40   void SetFromSwitches(const Switches& switches);
     41 
     42   // Sets a switch from the capabilities, of the form [--]name[=value].
     43   void SetUnparsedSwitch(const std::string& unparsed_switch);
     44 
     45   void RemoveSwitch(const std::string& name);
     46 
     47   bool HasSwitch(const std::string& name) const;
     48   std::string GetSwitchValue(const std::string& name) const;
     49   NativeString GetSwitchValueNative(const std::string& name) const;
     50 
     51   size_t GetSize() const;
     52 
     53   void AppendToCommandLine(base::CommandLine* command) const;
     54   std::string ToString() const;
     55 
     56  private:
     57   typedef std::map<std::string, NativeString> SwitchMap;
     58   SwitchMap switch_map_;
     59 };
     60 
     61 typedef std::map<std::string, Log::Level> LoggingPrefs;
     62 
     63 struct Capabilities {
     64   Capabilities();
     65   ~Capabilities();
     66 
     67   // Return true if remote host:port session is to be used.
     68   bool IsRemoteBrowser() const;
     69 
     70   // Return true if android package is specified.
     71   bool IsAndroid() const;
     72 
     73   Status Parse(const base::DictionaryValue& desired_caps);
     74 
     75   std::string android_activity;
     76 
     77   std::string android_device_serial;
     78 
     79   std::string android_package;
     80 
     81   std::string android_process;
     82 
     83   bool android_use_running_app;
     84 
     85   base::FilePath binary;
     86 
     87   // If provided, the remote debugging address to connect to.
     88   NetAddress debugger_address;
     89 
     90   // Whether the lifetime of the started Chrome browser process should be
     91   // bound to ChromeDriver's process. If true, Chrome will not quit if
     92   // ChromeDriver dies.
     93   bool detach;
     94 
     95   // Device metrics for use in Device Emulation.
     96   scoped_ptr<DeviceMetrics> device_metrics;
     97 
     98   // Set of switches which should be removed from default list when launching
     99   // Chrome.
    100   std::set<std::string> exclude_switches;
    101 
    102   std::vector<std::string> extensions;
    103 
    104   // True if should always use DevTools for taking screenshots.
    105   // This is experimental and may be removed at a later point.
    106   bool force_devtools_screenshot;
    107 
    108   scoped_ptr<base::DictionaryValue> local_state;
    109 
    110   std::string log_path;
    111 
    112   LoggingPrefs logging_prefs;
    113 
    114   // If set, enable minidump for chrome crashes and save to this directory.
    115   std::string minidump_path;
    116 
    117   scoped_ptr<base::DictionaryValue> prefs;
    118 
    119   Switches switches;
    120 };
    121 
    122 #endif  // CHROME_TEST_CHROMEDRIVER_CAPABILITIES_H_
    123