| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_NFC_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_NFC_MANAGER_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_NFC_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_NFC_MANAGER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 #include "chromeos/dbus/nfc_manager_client.h" | 13 #include "chromeos/dbus/nfc_manager_client.h" |
| 14 #include "dbus/property.h" | 14 #include "dbus/property.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 // FakeNfcManagerClient simulates the behavior of the NFC Daemon manager object | 18 // FakeNfcManagerClient simulates the behavior of the NFC Daemon manager object |
| 19 // and is used both in test cases in place of a mock and on the Linux desktop. | 19 // and is used both in test cases in place of a mock and on the Linux desktop. |
| 20 class CHROMEOS_EXPORT FakeNfcManagerClient : public NfcManagerClient { | 20 class CHROMEOS_EXPORT FakeNfcManagerClient : public NfcManagerClient { |
| 21 public: | 21 public: |
| 22 struct Properties : public NfcManagerClient::Properties { | 22 struct Properties : public NfcManagerClient::Properties { |
| 23 explicit Properties(const PropertyChangedCallback& callback); | 23 explicit Properties(const PropertyChangedCallback& callback); |
| 24 virtual ~Properties(); | 24 virtual ~Properties(); |
| 25 | 25 |
| 26 // dbus::PropertySet overrides. | 26 // dbus::PropertySet overrides. |
| 27 virtual void Get(dbus::PropertyBase* property, | 27 virtual void Get(dbus::PropertyBase* property, |
| 28 dbus::PropertySet::GetCallback callback) OVERRIDE; | 28 dbus::PropertySet::GetCallback callback) override; |
| 29 virtual void GetAll() OVERRIDE; | 29 virtual void GetAll() override; |
| 30 virtual void Set(dbus::PropertyBase* property, | 30 virtual void Set(dbus::PropertyBase* property, |
| 31 dbus::PropertySet::SetCallback callback) OVERRIDE; | 31 dbus::PropertySet::SetCallback callback) override; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 FakeNfcManagerClient(); | 34 FakeNfcManagerClient(); |
| 35 virtual ~FakeNfcManagerClient(); | 35 virtual ~FakeNfcManagerClient(); |
| 36 | 36 |
| 37 // NfcManagerClient overrides. | 37 // NfcManagerClient overrides. |
| 38 virtual void Init(dbus::Bus* bus) OVERRIDE; | 38 virtual void Init(dbus::Bus* bus) override; |
| 39 virtual void AddObserver(Observer* observer) OVERRIDE; | 39 virtual void AddObserver(Observer* observer) override; |
| 40 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 40 virtual void RemoveObserver(Observer* observer) override; |
| 41 virtual Properties* GetProperties() OVERRIDE; | 41 virtual Properties* GetProperties() override; |
| 42 | 42 |
| 43 // Methods to simulate adapters getting added and removed. | 43 // Methods to simulate adapters getting added and removed. |
| 44 void AddAdapter(const std::string& adapter_path); | 44 void AddAdapter(const std::string& adapter_path); |
| 45 void RemoveAdapter(const std::string& adapter_path); | 45 void RemoveAdapter(const std::string& adapter_path); |
| 46 | 46 |
| 47 // Default path of an adapter that is simulated for testing. | 47 // Default path of an adapter that is simulated for testing. |
| 48 static const char kDefaultAdapterPath[]; | 48 static const char kDefaultAdapterPath[]; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // Property callback passed when we create Properties* structures. | 51 // Property callback passed when we create Properties* structures. |
| 52 void OnPropertyChanged(const std::string& property_name); | 52 void OnPropertyChanged(const std::string& property_name); |
| 53 | 53 |
| 54 // List of observers interested in event notifications. | 54 // List of observers interested in event notifications. |
| 55 ObserverList<Observer> observers_; | 55 ObserverList<Observer> observers_; |
| 56 | 56 |
| 57 // Set containing the currently simulated adapters. | 57 // Set containing the currently simulated adapters. |
| 58 std::set<dbus::ObjectPath> adapters_; | 58 std::set<dbus::ObjectPath> adapters_; |
| 59 | 59 |
| 60 // Fake properties object. This gets updated whenever AddAdapter or | 60 // Fake properties object. This gets updated whenever AddAdapter or |
| 61 // RemoveAdapter gets called. | 61 // RemoveAdapter gets called. |
| 62 scoped_ptr<Properties> properties_; | 62 scoped_ptr<Properties> properties_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(FakeNfcManagerClient); | 64 DISALLOW_COPY_AND_ASSIGN(FakeNfcManagerClient); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace chromeos | 67 } // namespace chromeos |
| 68 | 68 |
| 69 #endif // CHROMEOS_DBUS_FAKE_NFC_MANAGER_CLIENT_H_ | 69 #endif // CHROMEOS_DBUS_FAKE_NFC_MANAGER_CLIENT_H_ |
| OLD | NEW |