[telemetry] - Change default benchmark list to use chartjson output.
[chromium-blink-merge.git] / chromeos / dbus / fake_shill_manager_client.h
blobac4a9d140eb5e68a6a040be6debfc21c54eabbb9
1 // Copyright 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 CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/shill_manager_client.h"
15 namespace net {
16 class IPEndPoint;
19 namespace chromeos {
21 // A fake implementation of ShillManagerClient. This works in close coordination
22 // with FakeShillServiceClient. FakeShillDeviceClient, and
23 // FakeShillProfileClient, and is not intended to be used independently.
24 class CHROMEOS_EXPORT FakeShillManagerClient
25 : public ShillManagerClient,
26 public ShillManagerClient::TestInterface {
27 public:
28 FakeShillManagerClient();
29 virtual ~FakeShillManagerClient();
31 // ShillManagerClient overrides
32 virtual void Init(dbus::Bus* bus) override;
33 virtual void AddPropertyChangedObserver(
34 ShillPropertyChangedObserver* observer) override;
35 virtual void RemovePropertyChangedObserver(
36 ShillPropertyChangedObserver* observer) override;
37 virtual void GetProperties(const DictionaryValueCallback& callback) override;
38 virtual void GetNetworksForGeolocation(
39 const DictionaryValueCallback& callback) override;
40 virtual void SetProperty(const std::string& name,
41 const base::Value& value,
42 const base::Closure& callback,
43 const ErrorCallback& error_callback) override;
44 virtual void RequestScan(const std::string& type,
45 const base::Closure& callback,
46 const ErrorCallback& error_callback) override;
47 virtual void EnableTechnology(
48 const std::string& type,
49 const base::Closure& callback,
50 const ErrorCallback& error_callback) override;
51 virtual void DisableTechnology(
52 const std::string& type,
53 const base::Closure& callback,
54 const ErrorCallback& error_callback) override;
55 virtual void ConfigureService(
56 const base::DictionaryValue& properties,
57 const ObjectPathCallback& callback,
58 const ErrorCallback& error_callback) override;
59 virtual void ConfigureServiceForProfile(
60 const dbus::ObjectPath& profile_path,
61 const base::DictionaryValue& properties,
62 const ObjectPathCallback& callback,
63 const ErrorCallback& error_callback) override;
64 virtual void GetService(
65 const base::DictionaryValue& properties,
66 const ObjectPathCallback& callback,
67 const ErrorCallback& error_callback) override;
68 virtual void VerifyDestination(const VerificationProperties& properties,
69 const BooleanCallback& callback,
70 const ErrorCallback& error_callback) override;
71 virtual void VerifyAndEncryptCredentials(
72 const VerificationProperties& properties,
73 const std::string& service_path,
74 const StringCallback& callback,
75 const ErrorCallback& error_callback) override;
76 virtual void VerifyAndEncryptData(
77 const VerificationProperties& properties,
78 const std::string& data,
79 const StringCallback& callback,
80 const ErrorCallback& error_callback) override;
81 virtual void ConnectToBestServices(
82 const base::Closure& callback,
83 const ErrorCallback& error_callback) override;
85 virtual ShillManagerClient::TestInterface* GetTestInterface() override;
87 // ShillManagerClient::TestInterface overrides.
88 virtual void AddDevice(const std::string& device_path) override;
89 virtual void RemoveDevice(const std::string& device_path) override;
90 virtual void ClearDevices() override;
91 virtual void AddTechnology(const std::string& type, bool enabled) override;
92 virtual void RemoveTechnology(const std::string& type) override;
93 virtual void SetTechnologyInitializing(const std::string& type,
94 bool initializing) override;
95 virtual void AddGeoNetwork(const std::string& technology,
96 const base::DictionaryValue& network) override;
97 virtual void AddProfile(const std::string& profile_path) override;
98 virtual void ClearProperties() override;
99 virtual void SetManagerProperty(const std::string& key,
100 const base::Value& value) override;
101 virtual void AddManagerService(const std::string& service_path,
102 bool notify_observers) override;
103 virtual void RemoveManagerService(const std::string& service_path) override;
104 virtual void ClearManagerServices() override;
105 virtual void ServiceStateChanged(const std::string& service_path,
106 const std::string& state) override;
107 virtual void SortManagerServices(bool notify) override;
108 virtual void SetupDefaultEnvironment() override;
109 virtual int GetInteractiveDelay() const override;
110 virtual void SetBestServiceToConnect(
111 const std::string& service_path) override;
113 // Constants used for testing.
114 static const char kFakeEthernetNetworkGuid[];
116 private:
117 void SetDefaultProperties();
118 void PassStubProperties(const DictionaryValueCallback& callback) const;
119 void PassStubGeoNetworks(const DictionaryValueCallback& callback) const;
120 void CallNotifyObserversPropertyChanged(const std::string& property);
121 void NotifyObserversPropertyChanged(const std::string& property);
122 base::ListValue* GetListProperty(const std::string& property);
123 bool TechnologyEnabled(const std::string& type) const;
124 void SetTechnologyEnabled(const std::string& type,
125 const base::Closure& callback,
126 bool enabled);
127 base::ListValue* GetEnabledServiceList(const std::string& property) const;
128 void ScanCompleted(const std::string& device_path,
129 const base::Closure& callback);
131 // Parses the command line for Shill stub switches and sets initial states.
132 // Uses comma-separated name-value pairs (see SplitStringIntoKeyValuePairs):
133 // interactive={delay} - sets delay in seconds for interactive UI
134 // {wifi,cellular,etc}={on,off,disabled,none} - sets initial state for type
135 void ParseCommandLineSwitch();
136 bool ParseOption(const std::string& arg0, const std::string& arg1);
137 bool SetInitialNetworkState(std::string type_arg, std::string state_arg);
138 std::string GetInitialStateForType(const std::string& type,
139 bool* enabled);
141 // Dictionary of property name -> property value
142 base::DictionaryValue stub_properties_;
144 // Dictionary of technology -> list of property dictionaries
145 base::DictionaryValue stub_geo_networks_;
147 // Seconds to delay interactive actions
148 int interactive_delay_;
150 // Initial state for fake services.
151 std::map<std::string, std::string> shill_initial_state_map_;
152 typedef std::map<std::string, base::Value*> ShillPropertyMap;
153 typedef std::map<std::string, ShillPropertyMap> DevicePropertyMap;
154 DevicePropertyMap shill_device_property_map_;
156 ObserverList<ShillPropertyChangedObserver> observer_list_;
158 // Note: This should remain the last member so it'll be destroyed and
159 // invalidate its weak pointers before any other members are destroyed.
160 base::WeakPtrFactory<FakeShillManagerClient> weak_ptr_factory_;
162 // Track the default service for signaling Manager.DefaultService.
163 std::string default_service_;
165 // 'Best' service to connect to on ConnectToBestServices() calls.
166 std::string best_service_;
168 DISALLOW_COPY_AND_ASSIGN(FakeShillManagerClient);
171 } // namespace chromeos
173 #endif // CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_