blob: 824aa2a4b4c9527033e814fde8b2cbf7a4f52a85 [file] [log] [blame]
[email protected]4a5ddd2052013-02-14 23:54:001// 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.
4
5#ifndef CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_STUB_H_
6#define CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_STUB_H_
7
8#include <map>
9#include <string>
10
11#include "base/basictypes.h"
12#include "base/callback.h"
13#include "base/memory/weak_ptr.h"
[email protected]6b3328b2013-08-12 22:30:2414#include "chromeos/chromeos_export.h"
[email protected]4a5ddd2052013-02-14 23:54:0015#include "chromeos/dbus/shill_service_client.h"
16
17namespace chromeos {
18
[email protected]53419052013-05-14 04:37:5619// A stub implementation of ShillServiceClient. This works in close coordination
20// with ShillManagerClientStub and is not intended to be used independently.
[email protected]4a5ddd2052013-02-14 23:54:0021class ShillServiceClientStub : public ShillServiceClient,
22 public ShillServiceClient::TestInterface {
23 public:
24 ShillServiceClientStub();
25 virtual ~ShillServiceClientStub();
26
[email protected]6b3328b2013-08-12 22:30:2427 // Returns true when stub portalled wifi is enabled and it's service
28 // path equals to |path|.
29 CHROMEOS_EXPORT static bool IsStubPortalledWifiEnabled(
30 const std::string& path);
31
[email protected]4a5ddd2052013-02-14 23:54:0032 // ShillServiceClient overrides.
33 virtual void AddPropertyChangedObserver(
34 const dbus::ObjectPath& service_path,
35 ShillPropertyChangedObserver* observer) OVERRIDE;
36 virtual void RemovePropertyChangedObserver(
37 const dbus::ObjectPath& service_path,
38 ShillPropertyChangedObserver* observer) OVERRIDE;
39 virtual void GetProperties(const dbus::ObjectPath& service_path,
40 const DictionaryValueCallback& callback) OVERRIDE;
41 virtual void SetProperty(const dbus::ObjectPath& service_path,
42 const std::string& name,
43 const base::Value& value,
44 const base::Closure& callback,
45 const ErrorCallback& error_callback) OVERRIDE;
[email protected]e499e672013-07-10 18:51:2446 virtual void SetProperties(const dbus::ObjectPath& service_path,
47 const base::DictionaryValue& properties,
48 const base::Closure& callback,
49 const ErrorCallback& error_callback) OVERRIDE;
[email protected]4a5ddd2052013-02-14 23:54:0050 virtual void ClearProperty(const dbus::ObjectPath& service_path,
51 const std::string& name,
52 const base::Closure& callback,
53 const ErrorCallback& error_callback) OVERRIDE;
54 virtual void ClearProperties(const dbus::ObjectPath& service_path,
55 const std::vector<std::string>& names,
56 const ListValueCallback& callback,
57 const ErrorCallback& error_callback) OVERRIDE;
58 virtual void Connect(const dbus::ObjectPath& service_path,
59 const base::Closure& callback,
60 const ErrorCallback& error_callback) OVERRIDE;
61 virtual void Disconnect(const dbus::ObjectPath& service_path,
62 const base::Closure& callback,
63 const ErrorCallback& error_callback) OVERRIDE;
64 virtual void Remove(const dbus::ObjectPath& service_path,
65 const base::Closure& callback,
66 const ErrorCallback& error_callback) OVERRIDE;
67 virtual void ActivateCellularModem(
68 const dbus::ObjectPath& service_path,
69 const std::string& carrier,
70 const base::Closure& callback,
71 const ErrorCallback& error_callback) OVERRIDE;
[email protected]4cd38192013-02-16 07:54:1872 virtual void CompleteCellularActivation(
73 const dbus::ObjectPath& service_path,
74 const base::Closure& callback,
75 const ErrorCallback& error_callback) OVERRIDE;
[email protected]4a5ddd2052013-02-14 23:54:0076 virtual bool CallActivateCellularModemAndBlock(
77 const dbus::ObjectPath& service_path,
78 const std::string& carrier) OVERRIDE;
[email protected]7c8fd5642013-07-02 22:24:3079 virtual void GetLoadableProfileEntries(
80 const dbus::ObjectPath& service_path,
81 const DictionaryValueCallback& callback) OVERRIDE;
[email protected]4a5ddd2052013-02-14 23:54:0082 virtual ShillServiceClient::TestInterface* GetTestInterface() OVERRIDE;
83
84 // ShillServiceClient::TestInterface overrides.
[email protected]783aa24d2013-08-06 23:54:3885 virtual void AddDefaultServices() OVERRIDE;
[email protected]4a5ddd2052013-02-14 23:54:0086 virtual void AddService(const std::string& service_path,
87 const std::string& name,
88 const std::string& type,
[email protected]fde8b322013-02-28 17:44:2489 const std::string& state,
[email protected]ce21fc62013-07-03 10:45:5890 bool add_to_visible_list,
[email protected]fde8b322013-02-28 17:44:2491 bool add_to_watch_list) OVERRIDE;
[email protected]362fb222013-04-02 23:24:2892 virtual void AddServiceWithIPConfig(const std::string& service_path,
93 const std::string& name,
94 const std::string& type,
95 const std::string& state,
96 const std::string& ipconfig_path,
[email protected]ce21fc62013-07-03 10:45:5897 bool add_to_visible_list,
[email protected]362fb222013-04-02 23:24:2898 bool add_to_watch_list) OVERRIDE;
[email protected]4a5ddd2052013-02-14 23:54:0099 virtual void RemoveService(const std::string& service_path) OVERRIDE;
[email protected]e499e672013-07-10 18:51:24100 virtual bool SetServiceProperty(const std::string& service_path,
[email protected]4a5ddd2052013-02-14 23:54:00101 const std::string& property,
102 const base::Value& value) OVERRIDE;
[email protected]fde8b322013-02-28 17:44:24103 virtual const base::DictionaryValue* GetServiceProperties(
104 const std::string& service_path) const OVERRIDE;
[email protected]4a5ddd2052013-02-14 23:54:00105 virtual void ClearServices() OVERRIDE;
106
107 private:
108 typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
109
[email protected]4a5ddd2052013-02-14 23:54:00110 void NotifyObserversPropertyChanged(const dbus::ObjectPath& service_path,
111 const std::string& property);
[email protected]fde8b322013-02-28 17:44:24112 base::DictionaryValue* GetModifiableServiceProperties(
113 const std::string& service_path);
[email protected]4a5ddd2052013-02-14 23:54:00114 PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
[email protected]783aa24d2013-08-06 23:54:38115 void SetOtherServicesOffline(const std::string& service_path);
[email protected]5fd84cc92013-08-14 02:35:50116 void SetCellularActivated(const dbus::ObjectPath& service_path,
117 const ErrorCallback& error_callback);
[email protected]4a5ddd2052013-02-14 23:54:00118
119 base::DictionaryValue stub_services_;
120 // Observer list for each service.
121 std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
122
123 // Note: This should remain the last member so it'll be destroyed and
124 // invalidate its weak pointers before any other members are destroyed.
125 base::WeakPtrFactory<ShillServiceClientStub> weak_ptr_factory_;
126
127 DISALLOW_COPY_AND_ASSIGN(ShillServiceClientStub);
128};
129
130} // namespace chromeos
131
132#endif // CHROMEOS_DBUS_SHILL_SERVICE_CLIENT_STUB_H_