| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_SHILL_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 #include "chromeos/dbus/shill_manager_client.h" | 13 #include "chromeos/dbus/shill_manager_client.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 // A fake implementation of ShillManagerClient. This works in close coordination | 17 // A fake implementation of ShillManagerClient. This works in close coordination |
| 18 // with FakeShillServiceClient. FakeShillDeviceClient, and | 18 // with FakeShillServiceClient. FakeShillDeviceClient, and |
| 19 // FakeShillProfileClient, and is not intended to be used independently. | 19 // FakeShillProfileClient, and is not intended to be used independently. |
| 20 class CHROMEOS_EXPORT FakeShillManagerClient : | 20 class CHROMEOS_EXPORT FakeShillManagerClient |
| 21 public ShillManagerClient, | 21 : public ShillManagerClient, |
| 22 public ShillManagerClient::TestInterface { | 22 public ShillManagerClient::TestInterface { |
| 23 public: | 23 public: |
| 24 FakeShillManagerClient(); | 24 FakeShillManagerClient(); |
| 25 virtual ~FakeShillManagerClient(); | 25 virtual ~FakeShillManagerClient(); |
| 26 | 26 |
| 27 // ShillManagerClient overrides | 27 // ShillManagerClient overrides |
| 28 virtual void Init(dbus::Bus* bus) OVERRIDE; | 28 virtual void Init(dbus::Bus* bus) OVERRIDE; |
| 29 virtual void AddPropertyChangedObserver( | 29 virtual void AddPropertyChangedObserver( |
| 30 ShillPropertyChangedObserver* observer) OVERRIDE; | 30 ShillPropertyChangedObserver* observer) OVERRIDE; |
| 31 virtual void RemovePropertyChangedObserver( | 31 virtual void RemovePropertyChangedObserver( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 virtual void AddGeoNetwork(const std::string& technology, | 90 virtual void AddGeoNetwork(const std::string& technology, |
| 91 const base::DictionaryValue& network) OVERRIDE; | 91 const base::DictionaryValue& network) OVERRIDE; |
| 92 virtual void AddProfile(const std::string& profile_path) OVERRIDE; | 92 virtual void AddProfile(const std::string& profile_path) OVERRIDE; |
| 93 virtual void ClearProperties() OVERRIDE; | 93 virtual void ClearProperties() OVERRIDE; |
| 94 virtual void AddManagerService(const std::string& service_path, | 94 virtual void AddManagerService(const std::string& service_path, |
| 95 bool add_to_visible_list, | 95 bool add_to_visible_list, |
| 96 bool add_to_watch_list) OVERRIDE; | 96 bool add_to_watch_list) OVERRIDE; |
| 97 virtual void RemoveManagerService(const std::string& service_path) OVERRIDE; | 97 virtual void RemoveManagerService(const std::string& service_path) OVERRIDE; |
| 98 virtual void ClearManagerServices() OVERRIDE; | 98 virtual void ClearManagerServices() OVERRIDE; |
| 99 virtual void SortManagerServices() OVERRIDE; | 99 virtual void SortManagerServices() OVERRIDE; |
| 100 virtual int GetInteractiveDelay() const OVERRIDE; |
| 101 virtual std::string GetInitialState(const std::string& type) const OVERRIDE; |
| 100 | 102 |
| 101 private: | 103 private: |
| 102 void AddServiceToWatchList(const std::string& service_path); | 104 void AddServiceToWatchList(const std::string& service_path); |
| 103 void SetDefaultProperties(); | 105 void SetDefaultProperties(); |
| 104 void PassStubProperties(const DictionaryValueCallback& callback) const; | 106 void PassStubProperties(const DictionaryValueCallback& callback) const; |
| 105 void PassStubGeoNetworks(const DictionaryValueCallback& callback) const; | 107 void PassStubGeoNetworks(const DictionaryValueCallback& callback) const; |
| 106 void CallNotifyObserversPropertyChanged(const std::string& property, | 108 void CallNotifyObserversPropertyChanged(const std::string& property); |
| 107 int delay_ms); | |
| 108 void NotifyObserversPropertyChanged(const std::string& property); | 109 void NotifyObserversPropertyChanged(const std::string& property); |
| 109 base::ListValue* GetListProperty(const std::string& property); | 110 base::ListValue* GetListProperty(const std::string& property); |
| 110 bool TechnologyEnabled(const std::string& type) const; | 111 bool TechnologyEnabled(const std::string& type) const; |
| 111 void SetTechnologyEnabled(const std::string& type, | 112 void SetTechnologyEnabled(const std::string& type, |
| 112 const base::Closure& callback, | 113 const base::Closure& callback, |
| 113 bool enabled); | 114 bool enabled); |
| 114 base::ListValue* GetEnabledServiceList(const std::string& property) const; | 115 base::ListValue* GetEnabledServiceList(const std::string& property) const; |
| 115 void ScanCompleted(const std::string& device_path, | 116 void ScanCompleted(const std::string& device_path, |
| 116 const base::Closure& callback); | 117 const base::Closure& callback); |
| 117 | 118 |
| 119 // Parses the command line for Shill stub switches and sets initial states. |
| 120 void ParseCommandLineSwitch(); |
| 121 bool ParseOption(const std::string& arg0, const std::string& arg1); |
| 122 bool SetInitialNetworkState(std::string type_arg, std::string state_arg); |
| 123 |
| 124 // Sets up the default fake environment based on default initial states |
| 125 // or states provided by the command line (see ParseCommandLineSwitch). |
| 126 void SetupDefaultEnvironment(); |
| 127 std::string ParseInitialState(const std::string& type, |
| 128 bool* enabled, |
| 129 bool* portaled); |
| 130 |
| 118 // Dictionary of property name -> property value | 131 // Dictionary of property name -> property value |
| 119 base::DictionaryValue stub_properties_; | 132 base::DictionaryValue stub_properties_; |
| 133 |
| 120 // Dictionary of technology -> list of property dictionaries | 134 // Dictionary of technology -> list of property dictionaries |
| 121 base::DictionaryValue stub_geo_networks_; | 135 base::DictionaryValue stub_geo_networks_; |
| 122 | 136 |
| 137 // Seconds to delay interactive actions |
| 138 int interactive_delay_; |
| 139 |
| 140 // Initial state for fake services. |
| 141 std::map<std::string, std::string> shill_initial_state_map_; |
| 142 |
| 123 ObserverList<ShillPropertyChangedObserver> observer_list_; | 143 ObserverList<ShillPropertyChangedObserver> observer_list_; |
| 124 | 144 |
| 125 // Note: This should remain the last member so it'll be destroyed and | 145 // Note: This should remain the last member so it'll be destroyed and |
| 126 // invalidate its weak pointers before any other members are destroyed. | 146 // invalidate its weak pointers before any other members are destroyed. |
| 127 base::WeakPtrFactory<FakeShillManagerClient> weak_ptr_factory_; | 147 base::WeakPtrFactory<FakeShillManagerClient> weak_ptr_factory_; |
| 128 | 148 |
| 129 DISALLOW_COPY_AND_ASSIGN(FakeShillManagerClient); | 149 DISALLOW_COPY_AND_ASSIGN(FakeShillManagerClient); |
| 130 }; | 150 }; |
| 131 | 151 |
| 132 } // namespace chromeos | 152 } // namespace chromeos |
| 133 | 153 |
| 134 #endif // CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ | 154 #endif // CHROMEOS_DBUS_FAKE_SHILL_MANAGER_CLIENT_H_ |
| OLD | NEW |