| Index: chromeos/dbus/shill_device_client.cc | 
| diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc | 
| index b2cc011991a85b2cb2db28ca95cbadbf47f7c8b6..6f86e28cb7286dde5db5ff50c892190cd15e5658 100644 | 
| --- a/chromeos/dbus/shill_device_client.cc | 
| +++ b/chromeos/dbus/shill_device_client.cc | 
| @@ -188,6 +188,10 @@ class ShillDeviceClientImpl : public ShillDeviceClient { | 
| &method_call, callback, error_callback); | 
| } | 
|  | 
| +  virtual TestInterface* GetTestInterface() OVERRIDE { | 
| +    return NULL; | 
| +  } | 
| + | 
| private: | 
| typedef std::map<std::string, ShillClientHelper*> HelperMap; | 
|  | 
| @@ -215,52 +219,28 @@ class ShillDeviceClientImpl : public ShillDeviceClient { | 
|  | 
| // A stub implementation of ShillDeviceClient. | 
| // Implemented: Stub cellular device for SMS testing. | 
| -class ShillDeviceClientStubImpl : public ShillDeviceClient { | 
| +class ShillDeviceClientStubImpl : public ShillDeviceClient, | 
| +                                  public ShillDeviceClient::TestInterface { | 
| public: | 
| ShillDeviceClientStubImpl() : weak_ptr_factory_(this) { | 
| -    // Add a cellular device for SMS. Note: name matches Manager entry. | 
| -    const char kStubCellular1[] = "stub_cellular1"; | 
| -    base::DictionaryValue* cellular_properties = new base::DictionaryValue; | 
| -    cellular_properties->SetWithoutPathExpansion( | 
| -        flimflam::kTypeProperty, | 
| -        base::Value::CreateStringValue(flimflam::kTypeCellular)); | 
| -    cellular_properties->SetWithoutPathExpansion( | 
| -        flimflam::kDBusConnectionProperty, | 
| -        base::Value::CreateStringValue("/stub")); | 
| -    cellular_properties->SetWithoutPathExpansion( | 
| -        flimflam::kDBusObjectProperty, | 
| -        base::Value::CreateStringValue("/device/cellular1")); | 
| -    stub_devices_.Set(kStubCellular1, cellular_properties); | 
| - | 
| -    // Create a second device stubbing a modem managed by | 
| -    // ModemManager1 interfaces. | 
| -    // Note: name matches Manager entry. | 
| -    const char kStubCellular2[] = "stub_cellular2"; | 
| -    cellular_properties = new base::DictionaryValue; | 
| -    cellular_properties->SetWithoutPathExpansion( | 
| -        flimflam::kTypeProperty, | 
| -        base::Value::CreateStringValue(flimflam::kTypeCellular)); | 
| -    cellular_properties->SetWithoutPathExpansion( | 
| -        flimflam::kDBusConnectionProperty, | 
| -        base::Value::CreateStringValue(":stub.0")); | 
| -    cellular_properties->SetWithoutPathExpansion( | 
| -        flimflam::kDBusObjectProperty, | 
| -        base::Value::CreateStringValue( | 
| -                "/org/freedesktop/ModemManager1/stub/0")); | 
| -    stub_devices_.Set(kStubCellular2, cellular_properties); | 
| +    SetDefaultProperties(); | 
| } | 
|  | 
| virtual ~ShillDeviceClientStubImpl() {} | 
|  | 
| -  /////////////////////////////////// | 
| // ShillDeviceClient overrides. | 
| + | 
| virtual void AddPropertyChangedObserver( | 
| const dbus::ObjectPath& device_path, | 
| -      ShillPropertyChangedObserver* observer) OVERRIDE {} | 
| +      ShillPropertyChangedObserver* observer) OVERRIDE { | 
| +    observer_list_.AddObserver(observer); | 
| +  } | 
|  | 
| virtual void RemovePropertyChangedObserver( | 
| const dbus::ObjectPath& device_path, | 
| -      ShillPropertyChangedObserver* observer) OVERRIDE {} | 
| +      ShillPropertyChangedObserver* observer) OVERRIDE { | 
| +    observer_list_.RemoveObserver(observer); | 
| +  } | 
|  | 
| virtual void GetProperties(const dbus::ObjectPath& device_path, | 
| const DictionaryValueCallback& callback) OVERRIDE { | 
| @@ -298,6 +278,10 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient { | 
| } | 
| device_properties->Set(name, value.DeepCopy()); | 
| MessageLoop::current()->PostTask(FROM_HERE, callback); | 
| +    MessageLoop::current()->PostTask( | 
| +        FROM_HERE, | 
| +        base::Bind(&ShillDeviceClientStubImpl::NotifyObserversPropertyChanged, | 
| +                   weak_ptr_factory_.GetWeakPtr(), device_path, name)); | 
| } | 
|  | 
| virtual void ClearProperty(const dbus::ObjectPath& device_path, | 
| @@ -366,7 +350,6 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient { | 
| MessageLoop::current()->PostTask(FROM_HERE, callback); | 
| } | 
|  | 
| -  // ShillDeviceClient override. | 
| virtual void SetCarrier(const dbus::ObjectPath& device_path, | 
| const std::string& carrier, | 
| const base::Closure& callback, | 
| @@ -374,11 +357,53 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient { | 
| MessageLoop::current()->PostTask(FROM_HERE, callback); | 
| } | 
|  | 
| +  virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE { | 
| +    return this; | 
| +  } | 
| + | 
| +  // ShillDeviceClient::TestInterface overrides. | 
| + | 
| +  virtual void AddDevice(const std::string& device_path, | 
| +                         const std::string& type, | 
| +                         const std::string& object_path, | 
| +                         const std::string& connection_path) OVERRIDE { | 
| +    base::DictionaryValue* properties = GetDeviceProperties(device_path); | 
| +    properties->SetWithoutPathExpansion( | 
| +        flimflam::kTypeProperty, | 
| +        base::Value::CreateStringValue(type)); | 
| +    properties->SetWithoutPathExpansion( | 
| +        flimflam::kDBusObjectProperty, | 
| +        base::Value::CreateStringValue(object_path)); | 
| +    properties->SetWithoutPathExpansion( | 
| +        flimflam::kDBusConnectionProperty, | 
| +        base::Value::CreateStringValue(connection_path)); | 
| +  } | 
| + | 
| +  virtual void RemoveDevice(const std::string& device_path) OVERRIDE { | 
| +    stub_devices_.RemoveWithoutPathExpansion(device_path, NULL); | 
| +  } | 
| + | 
| +  virtual void ClearDevices() OVERRIDE { | 
| +    stub_devices_.Clear(); | 
| +  } | 
| + | 
| private: | 
| +  void SetDefaultProperties() { | 
| +    // Add a wifi device. Note: path matches Manager entry. | 
| +    AddDevice("stub_wifi_device1", flimflam::kTypeWifi, | 
| +              "/device/wifi1", "/stub"); | 
| + | 
| +    // Add a cellular device. Used in SMS stub. Note: path matches | 
| +    // Manager entry. | 
| +    AddDevice("stub_cellular_device1", flimflam::kTypeCellular, | 
| +              "/device/cellular1", "/stub"); | 
| +  } | 
| + | 
| void PassStubDeviceProperties(const dbus::ObjectPath& device_path, | 
| -                               const DictionaryValueCallback& callback) const { | 
| +                                const DictionaryValueCallback& callback) const { | 
| const base::DictionaryValue* device_properties = NULL; | 
| -    if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { | 
| +    if (!stub_devices_.GetDictionaryWithoutPathExpansion( | 
| +            device_path.value(), &device_properties)) { | 
| base::DictionaryValue empty_dictionary; | 
| callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); | 
| return; | 
| @@ -393,8 +418,38 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient { | 
| base::Bind(callback, status)); | 
| } | 
|  | 
| +  void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path, | 
| +                                      const std::string& property) { | 
| +    base::DictionaryValue* dict = NULL; | 
| +    std::string path = device_path.value(); | 
| +    if (!stub_devices_.GetDictionaryWithoutPathExpansion(path, &dict)) { | 
| +      LOG(ERROR) << "Notify for unknown service: " << path; | 
| +      return; | 
| +    } | 
| +    base::Value* value = NULL; | 
| +    if (!dict->GetWithoutPathExpansion(property, &value)) { | 
| +      LOG(ERROR) << "Notify for unknown property: " | 
| +                 << path << " : " << property; | 
| +      return; | 
| +    } | 
| +    FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 
| +                      observer_list_, | 
| +                      OnPropertyChanged(property, *value)); | 
| +  } | 
| + | 
| +  base::DictionaryValue* GetDeviceProperties(const std::string& device_path) { | 
| +    base::DictionaryValue* properties = NULL; | 
| +    if (!stub_devices_.GetDictionaryWithoutPathExpansion( | 
| +            device_path, &properties)) { | 
| +      properties = new base::DictionaryValue; | 
| +      stub_devices_.Set(device_path, properties); | 
| +    } | 
| +    return properties; | 
| +  } | 
| + | 
| // Dictionary of <device_name, Dictionary>. | 
| base::DictionaryValue stub_devices_; | 
| +  ObserverList<ShillPropertyChangedObserver> observer_list_; | 
|  | 
| // Note: This should remain the last member so it'll be destroyed and | 
| // invalidate its weak pointers before any other members are destroyed. | 
|  |