Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / chromeos / dbus / shill_manager_client_stub.h
blobeebea3681a82c0a3cefd41e92c85863557db8c76
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 CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_STUB_H_
6 #define CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_STUB_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/dbus/shill_manager_client.h"
14 namespace chromeos {
16 // A stub implementation of ShillManagerClient.
17 // Implemented: Stub devices and services for NetworkStateManager tests.
18 // Implemented: Stub cellular device entry for SMS tests.
19 class ShillManagerClientStub : public ShillManagerClient,
20 public ShillManagerClient::TestInterface {
21 public:
22 ShillManagerClientStub();
23 virtual ~ShillManagerClientStub();
25 // ShillManagerClient overrides.
26 virtual void AddPropertyChangedObserver(
27 ShillPropertyChangedObserver* observer) OVERRIDE;
28 virtual void RemovePropertyChangedObserver(
29 ShillPropertyChangedObserver* observer) OVERRIDE;
30 virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE;
31 virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE;
32 virtual void GetNetworksForGeolocation(
33 const DictionaryValueCallback& callback) OVERRIDE;
34 virtual void SetProperty(const std::string& name,
35 const base::Value& value,
36 const base::Closure& callback,
37 const ErrorCallback& error_callback) OVERRIDE;
38 virtual void RequestScan(const std::string& type,
39 const base::Closure& callback,
40 const ErrorCallback& error_callback) OVERRIDE;
41 virtual void EnableTechnology(
42 const std::string& type,
43 const base::Closure& callback,
44 const ErrorCallback& error_callback) OVERRIDE;
45 virtual void DisableTechnology(
46 const std::string& type,
47 const base::Closure& callback,
48 const ErrorCallback& error_callback) OVERRIDE;
49 virtual void ConfigureService(
50 const base::DictionaryValue& properties,
51 const ObjectPathCallback& callback,
52 const ErrorCallback& error_callback) OVERRIDE;
53 virtual void GetService(
54 const base::DictionaryValue& properties,
55 const ObjectPathCallback& callback,
56 const ErrorCallback& error_callback) OVERRIDE;
57 virtual void VerifyDestination(const std::string& certificate,
58 const std::string& public_key,
59 const std::string& nonce,
60 const std::string& signed_data,
61 const std::string& device_serial,
62 const BooleanCallback& callback,
63 const ErrorCallback& error_callback) OVERRIDE;
64 virtual void VerifyAndEncryptCredentials(
65 const std::string& certificate,
66 const std::string& public_key,
67 const std::string& nonce,
68 const std::string& signed_data,
69 const std::string& device_serial,
70 const std::string& service_path,
71 const StringCallback& callback,
72 const ErrorCallback& error_callback) OVERRIDE;
73 virtual void VerifyAndEncryptData(
74 const std::string& certificate,
75 const std::string& public_key,
76 const std::string& nonce,
77 const std::string& signed_data,
78 const std::string& device_serial,
79 const std::string& data,
80 const StringCallback& callback,
81 const ErrorCallback& error_callback) OVERRIDE;
82 virtual void ConnectToBestServices(
83 const base::Closure& callback,
84 const ErrorCallback& error_callback) OVERRIDE;
85 virtual ShillManagerClient::TestInterface* GetTestInterface() OVERRIDE;
87 // ShillManagerClient::TestInterface overrides.
89 virtual void AddDevice(const std::string& device_path) OVERRIDE;
90 virtual void RemoveDevice(const std::string& device_path) OVERRIDE;
91 virtual void ClearDevices() OVERRIDE;
92 virtual void ClearServices() OVERRIDE;
93 virtual void AddService(const std::string& service_path,
94 bool add_to_watch_list) OVERRIDE;
95 virtual void AddServiceAtIndex(const std::string& service_path,
96 size_t index,
97 bool add_to_watch_list) OVERRIDE;
98 virtual void RemoveService(const std::string& service_path) OVERRIDE;
99 virtual void AddTechnology(const std::string& type, bool enabled) OVERRIDE;
100 virtual void RemoveTechnology(const std::string& type) OVERRIDE;
101 virtual void AddGeoNetwork(const std::string& technology,
102 const base::DictionaryValue& network) OVERRIDE;
103 virtual void ClearProperties() OVERRIDE;
105 private:
106 void AddServiceToWatchList(const std::string& service_path);
107 void SetDefaultProperties();
108 void PassStubProperties(const DictionaryValueCallback& callback) const;
109 void PassStubGeoNetworks(const DictionaryValueCallback& callback) const;
110 void CallNotifyObserversPropertyChanged(const std::string& property,
111 int delay_ms);
112 void NotifyObserversPropertyChanged(const std::string& property);
113 base::ListValue* GetListProperty(const std::string& property);
114 bool TechnologyEnabled(const std::string& type) const;
115 base::ListValue* GetEnabledServiceList(const std::string& property) const;
117 // Dictionary of property name -> property value
118 base::DictionaryValue stub_properties_;
119 // Dictionary of technology -> list of property dictionaries
120 base::DictionaryValue stub_geo_networks_;
122 ObserverList<ShillPropertyChangedObserver> observer_list_;
124 // Note: This should remain the last member so it'll be destroyed and
125 // invalidate its weak pointers before any other members are destroyed.
126 base::WeakPtrFactory<ShillManagerClientStub> weak_ptr_factory_;
128 DISALLOW_COPY_AND_ASSIGN(ShillManagerClientStub);
131 } // namespace chromeos
133 #endif // CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_STUB_H_