OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
13 #include "chromeos/dbus/shill_manager_client.h" | 13 #include "chromeos/dbus/shill_manager_client.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 // A fake implementation of ShillManagerClient. This works in close coordination | 17 // A fake implementation of ShillManagerClient. This works in close coordination |
18 // with FakeShillServiceClient. FakeShillDeviceClient, and | 18 // with FakeShillServiceClient. FakeShillDeviceClient, and |
19 // FakeShillProfileClient, and is not intended to be used independently. | 19 // FakeShillProfileClient, and is not intended to be used independently. |
20 class CHROMEOS_EXPORT FakeShillManagerClient : | 20 class CHROMEOS_EXPORT FakeShillManagerClient |
21 public ShillManagerClient, | 21 : public ShillManagerClient, |
22 public ShillManagerClient::TestInterface { | 22 public ShillManagerClient::TestInterface { |
23 public: | 23 public: |
24 FakeShillManagerClient(); | 24 FakeShillManagerClient(); |
25 virtual ~FakeShillManagerClient(); | 25 virtual ~FakeShillManagerClient(); |
26 | 26 |
27 // ShillManagerClient overrides | 27 // ShillManagerClient overrides |
28 virtual void Init(dbus::Bus* bus) OVERRIDE; | 28 virtual void Init(dbus::Bus* bus) OVERRIDE; |
29 virtual void AddPropertyChangedObserver( | 29 virtual void AddPropertyChangedObserver( |
30 ShillPropertyChangedObserver* observer) OVERRIDE; | 30 ShillPropertyChangedObserver* observer) OVERRIDE; |
31 virtual void RemovePropertyChangedObserver( | 31 virtual void RemovePropertyChangedObserver( |
32 ShillPropertyChangedObserver* observer) OVERRIDE; | 32 ShillPropertyChangedObserver* observer) OVERRIDE; |
33 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE; | 33 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE; |
34 virtual void GetNetworksForGeolocation( | 34 virtual void GetNetworksForGeolocation( |
35 const DictionaryValueCallback& callback) OVERRIDE; | 35 const DictionaryValueCallback& callback) OVERRIDE; |
36 virtual void SetProperty(const std::string& name, | 36 virtual void SetProperty(const std::string& name, |
37 const base::Value& value, | 37 const base::Value& value, |
38 const base::Closure& callback, | 38 const base::Closure& callback, |
39 const ErrorCallback& error_callback) OVERRIDE; | 39 const ErrorCallback& error_callback) OVERRIDE; |
40 virtual void RequestScan(const std::string& type, | 40 virtual void RequestScan(const std::string& type, |
41 const base::Closure& callback, | 41 const base::Closure& callback, |
42 const ErrorCallback& error_callback) OVERRIDE; | 42 const ErrorCallback& error_callback) OVERRIDE; |
43 virtual void EnableTechnology( | 43 virtual void EnableTechnology(const std::string& type, |
44 const std::string& type, | 44 const base::Closure& callback, |
45 const base::Closure& callback, | 45 const ErrorCallback& error_callback) OVERRIDE; |
46 const ErrorCallback& error_callback) OVERRIDE; | 46 virtual void DisableTechnology(const std::string& type, |
47 virtual void DisableTechnology( | 47 const base::Closure& callback, |
48 const std::string& type, | 48 const ErrorCallback& error_callback) OVERRIDE; |
49 const base::Closure& callback, | 49 virtual void ConfigureService(const base::DictionaryValue& properties, |
50 const ErrorCallback& error_callback) OVERRIDE; | 50 const ObjectPathCallback& callback, |
51 virtual void ConfigureService( | 51 const ErrorCallback& error_callback) OVERRIDE; |
52 const base::DictionaryValue& properties, | |
53 const ObjectPathCallback& callback, | |
54 const ErrorCallback& error_callback) OVERRIDE; | |
55 virtual void ConfigureServiceForProfile( | 52 virtual void ConfigureServiceForProfile( |
56 const dbus::ObjectPath& profile_path, | 53 const dbus::ObjectPath& profile_path, |
57 const base::DictionaryValue& properties, | 54 const base::DictionaryValue& properties, |
58 const ObjectPathCallback& callback, | 55 const ObjectPathCallback& callback, |
59 const ErrorCallback& error_callback) OVERRIDE; | 56 const ErrorCallback& error_callback) OVERRIDE; |
60 virtual void GetService( | 57 virtual void GetService(const base::DictionaryValue& properties, |
61 const base::DictionaryValue& properties, | 58 const ObjectPathCallback& callback, |
62 const ObjectPathCallback& callback, | 59 const ErrorCallback& error_callback) OVERRIDE; |
63 const ErrorCallback& error_callback) OVERRIDE; | |
64 virtual void VerifyDestination(const VerificationProperties& properties, | 60 virtual void VerifyDestination(const VerificationProperties& properties, |
65 const BooleanCallback& callback, | 61 const BooleanCallback& callback, |
66 const ErrorCallback& error_callback) OVERRIDE; | 62 const ErrorCallback& error_callback) OVERRIDE; |
67 virtual void VerifyAndEncryptCredentials( | 63 virtual void VerifyAndEncryptCredentials( |
68 const VerificationProperties& properties, | 64 const VerificationProperties& properties, |
69 const std::string& service_path, | 65 const std::string& service_path, |
70 const StringCallback& callback, | 66 const StringCallback& callback, |
71 const ErrorCallback& error_callback) OVERRIDE; | 67 const ErrorCallback& error_callback) OVERRIDE; |
72 virtual void VerifyAndEncryptData( | 68 virtual void VerifyAndEncryptData(const VerificationProperties& properties, |
73 const VerificationProperties& properties, | 69 const std::string& data, |
74 const std::string& data, | 70 const StringCallback& callback, |
75 const StringCallback& callback, | 71 const ErrorCallback& error_callback) |
76 const ErrorCallback& error_callback) OVERRIDE; | 72 OVERRIDE; |
77 virtual void ConnectToBestServices( | 73 virtual void ConnectToBestServices(const base::Closure& callback, |
78 const base::Closure& callback, | 74 const ErrorCallback& error_callback) |
79 const ErrorCallback& error_callback) OVERRIDE; | 75 OVERRIDE; |
80 virtual ShillManagerClient::TestInterface* GetTestInterface() OVERRIDE; | 76 virtual ShillManagerClient::TestInterface* GetTestInterface() OVERRIDE; |
81 | 77 |
82 // ShillManagerClient::TestInterface overrides. | 78 // ShillManagerClient::TestInterface overrides. |
83 virtual void AddDevice(const std::string& device_path) OVERRIDE; | 79 virtual void AddDevice(const std::string& device_path) OVERRIDE; |
84 virtual void RemoveDevice(const std::string& device_path) OVERRIDE; | 80 virtual void RemoveDevice(const std::string& device_path) OVERRIDE; |
85 virtual void ClearDevices() OVERRIDE; | 81 virtual void ClearDevices() OVERRIDE; |
86 virtual void AddTechnology(const std::string& type, bool enabled) OVERRIDE; | 82 virtual void AddTechnology(const std::string& type, bool enabled) OVERRIDE; |
87 virtual void RemoveTechnology(const std::string& type) OVERRIDE; | 83 virtual void RemoveTechnology(const std::string& type) OVERRIDE; |
88 virtual void SetTechnologyInitializing(const std::string& type, | 84 virtual void SetTechnologyInitializing(const std::string& type, |
89 bool initializing) OVERRIDE; | 85 bool initializing) OVERRIDE; |
90 virtual void AddGeoNetwork(const std::string& technology, | 86 virtual void AddGeoNetwork(const std::string& technology, |
91 const base::DictionaryValue& network) OVERRIDE; | 87 const base::DictionaryValue& network) OVERRIDE; |
92 virtual void AddProfile(const std::string& profile_path) OVERRIDE; | 88 virtual void AddProfile(const std::string& profile_path) OVERRIDE; |
93 virtual void ClearProperties() OVERRIDE; | 89 virtual void ClearProperties() OVERRIDE; |
94 virtual void AddManagerService(const std::string& service_path, | 90 virtual void AddManagerService(const std::string& service_path, |
95 bool add_to_visible_list, | 91 bool add_to_visible_list, |
96 bool add_to_watch_list) OVERRIDE; | 92 bool add_to_watch_list) OVERRIDE; |
97 virtual void RemoveManagerService(const std::string& service_path) OVERRIDE; | 93 virtual void RemoveManagerService(const std::string& service_path) OVERRIDE; |
98 virtual void ClearManagerServices() OVERRIDE; | 94 virtual void ClearManagerServices() OVERRIDE; |
99 virtual void SortManagerServices() OVERRIDE; | 95 virtual void SortManagerServices() OVERRIDE; |
100 | 96 |
101 private: | 97 private: |
102 void AddServiceToWatchList(const std::string& service_path); | 98 void AddServiceToWatchList(const std::string& service_path); |
103 void SetDefaultProperties(); | 99 void SetDefaultProperties(); |
104 void PassStubProperties(const DictionaryValueCallback& callback) const; | 100 void PassStubProperties(const DictionaryValueCallback& callback) const; |
105 void PassStubGeoNetworks(const DictionaryValueCallback& callback) const; | 101 void PassStubGeoNetworks(const DictionaryValueCallback& callback) const; |
106 void CallNotifyObserversPropertyChanged(const std::string& property, | 102 void CallNotifyObserversPropertyChanged(const std::string& property); |
107 int delay_ms); | |
108 void NotifyObserversPropertyChanged(const std::string& property); | 103 void NotifyObserversPropertyChanged(const std::string& property); |
109 base::ListValue* GetListProperty(const std::string& property); | 104 base::ListValue* GetListProperty(const std::string& property); |
110 bool TechnologyEnabled(const std::string& type) const; | 105 bool TechnologyEnabled(const std::string& type) const; |
111 void SetTechnologyEnabled(const std::string& type, | 106 void SetTechnologyEnabled(const std::string& type, |
112 const base::Closure& callback, | 107 const base::Closure& callback, |
113 bool enabled); | 108 bool enabled); |
114 base::ListValue* GetEnabledServiceList(const std::string& property) const; | 109 base::ListValue* GetEnabledServiceList(const std::string& property) const; |
115 void ScanCompleted(const std::string& device_path, | 110 void ScanCompleted(const std::string& device_path, |
116 const base::Closure& callback); | 111 const base::Closure& callback); |
117 | 112 |
118 // Dictionary of property name -> property value | 113 // Dictionary of property name -> property value |
119 base::DictionaryValue stub_properties_; | 114 base::DictionaryValue stub_properties_; |
120 // Dictionary of technology -> list of property dictionaries | 115 // Dictionary of technology -> list of property dictionaries |
121 base::DictionaryValue stub_geo_networks_; | 116 base::DictionaryValue stub_geo_networks_; |
122 | 117 |
123 ObserverList<ShillPropertyChangedObserver> observer_list_; | 118 ObserverList<ShillPropertyChangedObserver> observer_list_; |
124 | 119 |
125 // Note: This should remain the last member so it'll be destroyed and | 120 // Note: This should remain the last member so it'll be destroyed and |
126 // invalidate its weak pointers before any other members are destroyed. | 121 // invalidate its weak pointers before any other members are destroyed. |
127 base::WeakPtrFactory<FakeShillManagerClient> weak_ptr_factory_; | 122 base::WeakPtrFactory<FakeShillManagerClient> weak_ptr_factory_; |
128 | 123 |
129 DISALLOW_COPY_AND_ASSIGN(FakeShillManagerClient); | 124 DISALLOW_COPY_AND_ASSIGN(FakeShillManagerClient); |
130 }; | 125 }; |
131 | 126 |
132 } // namespace chromeos | 127 } // namespace chromeos |
133 | 128 |
134 #endif // CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ | 129 #endif // CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ |
OLD | NEW |