Home | History | Annotate | Download | only in dbus
      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.
      4 
      5 #ifndef CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
      6 #define CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "chromeos/chromeos_export.h"
     12 #include "chromeos/dbus/shill_ipconfig_client.h"
     13 
     14 namespace chromeos {
     15 
     16 // A fake implementation of ShillIPConfigClient.
     17 class CHROMEOS_EXPORT FakeShillIPConfigClient
     18     : public ShillIPConfigClient,
     19       public ShillIPConfigClient::TestInterface {
     20  public:
     21   FakeShillIPConfigClient();
     22   virtual ~FakeShillIPConfigClient();
     23 
     24   // ShillIPConfigClient overrides
     25   virtual void Init(dbus::Bus* bus) OVERRIDE;
     26   virtual void AddPropertyChangedObserver(
     27       const dbus::ObjectPath& ipconfig_path,
     28       ShillPropertyChangedObserver* observer) OVERRIDE;
     29   virtual void RemovePropertyChangedObserver(
     30       const dbus::ObjectPath& ipconfig_path,
     31       ShillPropertyChangedObserver* observer) OVERRIDE;
     32   virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
     33                        const VoidDBusMethodCallback& callback) OVERRIDE;
     34   virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
     35                              const DictionaryValueCallback& callback) OVERRIDE;
     36   virtual void SetProperty(const dbus::ObjectPath& ipconfig_path,
     37                            const std::string& name,
     38                            const base::Value& value,
     39                            const VoidDBusMethodCallback& callback) OVERRIDE;
     40   virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path,
     41                              const std::string& name,
     42                              const VoidDBusMethodCallback& callback) OVERRIDE;
     43   virtual void Remove(const dbus::ObjectPath& ipconfig_path,
     44                       const VoidDBusMethodCallback& callback) OVERRIDE;
     45   virtual ShillIPConfigClient::TestInterface* GetTestInterface() OVERRIDE;
     46 
     47   // ShillIPConfigClient::TestInterface overrides.
     48   virtual void AddIPConfig(const std::string& ip_config_path,
     49                            const base::DictionaryValue& properties) OVERRIDE;
     50 
     51  private:
     52   // Runs callback with |values|.
     53   void PassProperties(const base::DictionaryValue* values,
     54                       const DictionaryValueCallback& callback) const;
     55 
     56   // Dictionary of <ipconfig_path, property dictionaries>
     57   base::DictionaryValue ipconfigs_;
     58 
     59   // Note: This should remain the last member so it'll be destroyed and
     60   // invalidate its weak pointers before any other members are destroyed.
     61   base::WeakPtrFactory<FakeShillIPConfigClient> weak_ptr_factory_;
     62 
     63   DISALLOW_COPY_AND_ASSIGN(FakeShillIPConfigClient);
     64 };
     65 
     66 }  // namespace chromeos
     67 
     68 #endif  // CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
     69