Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / dbus / fake_shill_service_client.h
bloba9af512ced529af7942e08e289d2405234653158
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_SERVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_SHILL_SERVICE_CLIENT_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/shill_service_client.h"
17 namespace chromeos {
19 // A fake implementation of ShillServiceClient. This works in close coordination
20 // with FakeShillManagerClient and is not intended to be used independently.
21 class CHROMEOS_EXPORT FakeShillServiceClient
22 : public ShillServiceClient,
23 public ShillServiceClient::TestInterface {
24 public:
25 FakeShillServiceClient();
26 ~FakeShillServiceClient() override;
28 // ShillServiceClient overrides
29 void Init(dbus::Bus* bus) override;
30 void AddPropertyChangedObserver(
31 const dbus::ObjectPath& service_path,
32 ShillPropertyChangedObserver* observer) override;
33 void RemovePropertyChangedObserver(
34 const dbus::ObjectPath& service_path,
35 ShillPropertyChangedObserver* observer) override;
36 void GetProperties(const dbus::ObjectPath& service_path,
37 const DictionaryValueCallback& callback) override;
38 void SetProperty(const dbus::ObjectPath& service_path,
39 const std::string& name,
40 const base::Value& value,
41 const base::Closure& callback,
42 const ErrorCallback& error_callback) override;
43 void SetProperties(const dbus::ObjectPath& service_path,
44 const base::DictionaryValue& properties,
45 const base::Closure& callback,
46 const ErrorCallback& error_callback) override;
47 void ClearProperty(const dbus::ObjectPath& service_path,
48 const std::string& name,
49 const base::Closure& callback,
50 const ErrorCallback& error_callback) override;
51 void ClearProperties(const dbus::ObjectPath& service_path,
52 const std::vector<std::string>& names,
53 const ListValueCallback& callback,
54 const ErrorCallback& error_callback) override;
55 void Connect(const dbus::ObjectPath& service_path,
56 const base::Closure& callback,
57 const ErrorCallback& error_callback) override;
58 void Disconnect(const dbus::ObjectPath& service_path,
59 const base::Closure& callback,
60 const ErrorCallback& error_callback) override;
61 void Remove(const dbus::ObjectPath& service_path,
62 const base::Closure& callback,
63 const ErrorCallback& error_callback) override;
64 void ActivateCellularModem(const dbus::ObjectPath& service_path,
65 const std::string& carrier,
66 const base::Closure& callback,
67 const ErrorCallback& error_callback) override;
68 void CompleteCellularActivation(const dbus::ObjectPath& service_path,
69 const base::Closure& callback,
70 const ErrorCallback& error_callback) override;
71 void GetLoadableProfileEntries(
72 const dbus::ObjectPath& service_path,
73 const DictionaryValueCallback& callback) override;
74 ShillServiceClient::TestInterface* GetTestInterface() override;
76 // ShillServiceClient::TestInterface overrides.
77 void AddService(const std::string& service_path,
78 const std::string& guid,
79 const std::string& name,
80 const std::string& type,
81 const std::string& state,
82 bool visible) override;
83 void AddServiceWithIPConfig(const std::string& service_path,
84 const std::string& guid,
85 const std::string& name,
86 const std::string& type,
87 const std::string& state,
88 const std::string& ipconfig_path,
89 bool visible) override;
90 base::DictionaryValue* SetServiceProperties(const std::string& service_path,
91 const std::string& guid,
92 const std::string& name,
93 const std::string& type,
94 const std::string& state,
95 bool visible) override;
96 void RemoveService(const std::string& service_path) override;
97 bool SetServiceProperty(const std::string& service_path,
98 const std::string& property,
99 const base::Value& value) override;
100 const base::DictionaryValue* GetServiceProperties(
101 const std::string& service_path) const override;
102 void ClearServices() override;
103 void SetConnectBehavior(const std::string& service_path,
104 const base::Closure& behavior) override;
106 private:
107 typedef base::ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
109 void NotifyObserversPropertyChanged(const dbus::ObjectPath& service_path,
110 const std::string& property);
111 base::DictionaryValue* GetModifiableServiceProperties(
112 const std::string& service_path,
113 bool create_if_missing);
114 PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
115 void SetOtherServicesOffline(const std::string& service_path);
116 void SetCellularActivated(const dbus::ObjectPath& service_path,
117 const ErrorCallback& error_callback);
118 void ContinueConnect(const std::string& service_path);
120 base::DictionaryValue stub_services_;
122 // Per network service, stores a closure that is executed on each connection
123 // attempt. The callback can for example modify the services properties in
124 // order to simulate a connection failure.
125 std::map<std::string, base::Closure> connect_behavior_;
127 // Observer list for each service.
128 std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
130 // Note: This should remain the last member so it'll be destroyed and
131 // invalidate its weak pointers before any other members are destroyed.
132 base::WeakPtrFactory<FakeShillServiceClient> weak_ptr_factory_;
134 DISALLOW_COPY_AND_ASSIGN(FakeShillServiceClient);
137 } // namespace chromeos
139 #endif // CHROMEOS_DBUS_FAKE_SHILL_SERVICE_CLIENT_H_