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.
5 #ifndef CHROME_TEST_CHROMEDRIVER_CAPABILITIES_H_
6 #define CHROME_TEST_CHROMEDRIVER_CAPABILITIES_H_
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"
23 class DictionaryValue
;
30 typedef base::FilePath::StringType NativeString
;
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
);
39 // In case of same key, |switches| will override.
40 void SetFromSwitches(const Switches
& switches
);
42 // Sets a switch from the capabilities, of the form [--]name[=value].
43 void SetUnparsedSwitch(const std::string
& unparsed_switch
);
45 void RemoveSwitch(const std::string
& name
);
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;
51 size_t GetSize() const;
53 void AppendToCommandLine(base::CommandLine
* command
) const;
54 std::string
ToString() const;
57 typedef std::map
<std::string
, NativeString
> SwitchMap
;
58 SwitchMap switch_map_
;
61 typedef std::map
<std::string
, Log::Level
> LoggingPrefs
;
63 struct PerfLoggingPrefs
{
67 // We must distinguish between a log domain being set by default and being
68 // explicitly set. Otherwise, |PerformanceLogger| could only handle 3 of 4
69 // possible combinations (tracing enabled/disabled + Timeline on/off).
70 enum InspectorDomainStatus
{
77 InspectorDomainStatus network
;
78 InspectorDomainStatus page
;
79 // TODO(samuong): Timeline was removed in blink 189656 (chromium commit
80 // position 315092) so remove this option once we stop supporting M41.
81 InspectorDomainStatus timeline
;
83 std::string trace_categories
; // Non-empty string enables tracing.
84 int buffer_usage_reporting_interval
; // ms between trace buffer usage events.
91 // Return true if remote host:port session is to be used.
92 bool IsRemoteBrowser() const;
94 // Return true if android package is specified.
95 bool IsAndroid() const;
97 Status
Parse(const base::DictionaryValue
& desired_caps
);
99 std::string android_activity
;
101 std::string android_device_serial
;
103 std::string android_package
;
105 std::string android_process
;
107 bool android_use_running_app
;
109 base::FilePath binary
;
111 // If provided, the remote debugging address to connect to.
112 NetAddress debugger_address
;
114 // Whether the lifetime of the started Chrome browser process should be
115 // bound to ChromeDriver's process. If true, Chrome will not quit if
116 // ChromeDriver dies.
119 // Device metrics for use in Device Emulation.
120 scoped_ptr
<DeviceMetrics
> device_metrics
;
122 // Set of switches which should be removed from default list when launching
124 std::set
<std::string
> exclude_switches
;
126 std::vector
<std::string
> extensions
;
128 // True if should always use DevTools for taking screenshots.
129 // This is experimental and may be removed at a later point.
130 bool force_devtools_screenshot
;
132 scoped_ptr
<base::DictionaryValue
> local_state
;
134 std::string log_path
;
136 LoggingPrefs logging_prefs
;
138 // If set, enable minidump for chrome crashes and save to this directory.
139 std::string minidump_path
;
141 PerfLoggingPrefs perf_logging_prefs
;
143 scoped_ptr
<base::DictionaryValue
> prefs
;
148 #endif // CHROME_TEST_CHROMEDRIVER_CAPABILITIES_H_