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