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_PROFILE_CLIENT_H_
      6 #define CHROMEOS_DBUS_FAKE_SHILL_PROFILE_CLIENT_H_
      7 
      8 #include <map>
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "chromeos/chromeos_export.h"
     13 #include "chromeos/dbus/shill_manager_client.h"
     14 #include "chromeos/dbus/shill_profile_client.h"
     15 
     16 namespace chromeos {
     17 
     18 // A stub implementation of ShillProfileClient.
     19 class CHROMEOS_EXPORT FakeShillProfileClient :
     20       public ShillProfileClient,
     21       public ShillProfileClient::TestInterface {
     22  public:
     23   FakeShillProfileClient();
     24   virtual ~FakeShillProfileClient();
     25 
     26   // ShillProfileClient overrides
     27   virtual void Init(dbus::Bus* bus) OVERRIDE;
     28   virtual void AddPropertyChangedObserver(
     29       const dbus::ObjectPath& profile_path,
     30       ShillPropertyChangedObserver* observer) OVERRIDE;
     31   virtual void RemovePropertyChangedObserver(
     32       const dbus::ObjectPath& profile_path,
     33       ShillPropertyChangedObserver* observer) OVERRIDE;
     34   virtual void GetProperties(
     35       const dbus::ObjectPath& profile_path,
     36       const DictionaryValueCallbackWithoutStatus& callback,
     37       const ErrorCallback& error_callback) OVERRIDE;
     38   virtual void GetEntry(const dbus::ObjectPath& profile_path,
     39                         const std::string& entry_path,
     40                         const DictionaryValueCallbackWithoutStatus& callback,
     41                         const ErrorCallback& error_callback) OVERRIDE;
     42   virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
     43                            const std::string& entry_path,
     44                            const base::Closure& callback,
     45                            const ErrorCallback& error_callback) OVERRIDE;
     46   virtual ShillProfileClient::TestInterface* GetTestInterface() OVERRIDE;
     47 
     48   // ShillProfileClient::TestInterface overrides.
     49   virtual void AddProfile(const std::string& profile_path,
     50                           const std::string& userhash) OVERRIDE;
     51   virtual void AddEntry(const std::string& profile_path,
     52                         const std::string& entry_path,
     53                         const base::DictionaryValue& properties) OVERRIDE;
     54   virtual bool AddService(const std::string& profile_path,
     55                           const std::string& service_path) OVERRIDE;
     56   virtual bool UpdateService(const std::string& profile_path,
     57                              const std::string& service_path) OVERRIDE;
     58   virtual void GetProfilePaths(std::vector<std::string>* profiles) OVERRIDE;
     59   virtual bool GetService(const std::string& service_path,
     60                           std::string* profile_path,
     61                           base::DictionaryValue* properties) OVERRIDE;
     62   virtual void ClearProfiles() OVERRIDE;
     63 
     64  private:
     65   struct ProfileProperties;
     66   typedef std::map<std::string, ProfileProperties*> ProfileMap;
     67 
     68   bool AddOrUpdateServiceImpl(const std::string& profile_path,
     69                               const std::string& service_path,
     70                               ProfileProperties* profile);
     71 
     72   ProfileProperties* GetProfile(const dbus::ObjectPath& profile_path,
     73                                 const ErrorCallback& error_callback);
     74 
     75   // The values are owned by this class and are explicitly destroyed where
     76   // necessary.
     77   ProfileMap profiles_;
     78 
     79   DISALLOW_COPY_AND_ASSIGN(FakeShillProfileClient);
     80 };
     81 
     82 }  // namespace chromeos
     83 
     84 #endif  // CHROMEOS_DBUS_FAKE_SHILL_PROFILE_CLIENT_H_
     85