summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 05:41:00 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 05:41:00 +0000
commita84a69d4fcafc42f4a23fbc97b60dd80dc59c749 (patch)
tree9f872b497c1d1eff8901901c9a1cfc0ee8ec59f3 /chromeos/dbus
parent09f0c3ba70b30e465d9ba3ffefdd03667a56a4b4 (diff)
downloadchromium_src-a84a69d4fcafc42f4a23fbc97b60dd80dc59c749.zip
chromium_src-a84a69d4fcafc42f4a23fbc97b60dd80dc59c749.tar.gz
chromium_src-a84a69d4fcafc42f4a23fbc97b60dd80dc59c749.tar.bz2
dbus: Remove MockShillDeviceClient and MockShillIPConfigClient
These are not in use. Along the way rename ShillDeviceClientStub to FakeShillDeviceClient and ShillIPConfigClient to FakeShillIPConfigClient respectively. BUG=234463,309506 TEST=none R=hashimoto@chromium.org Review URL: https://codereview.chromium.org/31513002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229744 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/fake_shill_device_client.cc207
-rw-r--r--chromeos/dbus/fake_shill_device_client.h51
-rw-r--r--chromeos/dbus/fake_shill_ipconfig_client.cc (renamed from chromeos/dbus/shill_ipconfig_client_stub.cc)28
-rw-r--r--chromeos/dbus/fake_shill_ipconfig_client.h (renamed from chromeos/dbus/shill_ipconfig_client_stub.h)21
-rw-r--r--chromeos/dbus/mock_dbus_thread_manager.cc12
-rw-r--r--chromeos/dbus/mock_dbus_thread_manager.h24
-rw-r--r--chromeos/dbus/mock_shill_device_client.cc13
-rw-r--r--chromeos/dbus/mock_shill_device_client.h78
-rw-r--r--chromeos/dbus/mock_shill_ipconfig_client.cc13
-rw-r--r--chromeos/dbus/mock_shill_ipconfig_client.h45
-rw-r--r--chromeos/dbus/shill_device_client.cc4
-rw-r--r--chromeos/dbus/shill_device_client_stub.cc300
-rw-r--r--chromeos/dbus/shill_device_client_stub.h121
-rw-r--r--chromeos/dbus/shill_ipconfig_client.cc4
14 files changed, 293 insertions, 628 deletions
diff --git a/chromeos/dbus/fake_shill_device_client.cc b/chromeos/dbus/fake_shill_device_client.cc
index 2bf0b65..1e121ad 100644
--- a/chromeos/dbus/fake_shill_device_client.cc
+++ b/chromeos/dbus/fake_shill_device_client.cc
@@ -4,35 +4,71 @@
#include "chromeos/dbus/fake_shill_device_client.h"
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
+#include "base/values.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/shill_manager_client.h"
+#include "chromeos/dbus/shill_property_changed_observer.h"
+#include "dbus/bus.h"
+#include "dbus/message.h"
+#include "dbus/object_path.h"
+#include "dbus/object_proxy.h"
+#include "dbus/values_util.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
+
namespace chromeos {
-FakeShillDeviceClient::FakeShillDeviceClient() {
+namespace {
+
+void ErrorFunction(const std::string& device_path,
+ const std::string& error_name,
+ const std::string& error_message) {
+ LOG(ERROR) << "Shill Error for: " << device_path
+ << ": " << error_name << " : " << error_message;
}
-FakeShillDeviceClient::~FakeShillDeviceClient() {
+} // namespace
+
+FakeShillDeviceClient::FakeShillDeviceClient() : weak_ptr_factory_(this) {
}
-void FakeShillDeviceClient::Init(dbus::Bus* bus) {
+FakeShillDeviceClient::~FakeShillDeviceClient() {
+ STLDeleteContainerPairSecondPointers(
+ observer_list_.begin(), observer_list_.end());
}
+// ShillDeviceClient overrides.
+
+void FakeShillDeviceClient::Init(dbus::Bus* bus) {}
+
void FakeShillDeviceClient::AddPropertyChangedObserver(
const dbus::ObjectPath& device_path,
ShillPropertyChangedObserver* observer) {
+ GetObserverList(device_path).AddObserver(observer);
}
void FakeShillDeviceClient::RemovePropertyChangedObserver(
const dbus::ObjectPath& device_path,
ShillPropertyChangedObserver* observer) {
+ GetObserverList(device_path).RemoveObserver(observer);
}
void FakeShillDeviceClient::GetProperties(
const dbus::ObjectPath& device_path,
const DictionaryValueCallback& callback) {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&FakeShillDeviceClient::PassStubDeviceProperties,
+ weak_ptr_factory_.GetWeakPtr(),
+ device_path, callback));
}
void FakeShillDeviceClient::ProposeScan(
const dbus::ObjectPath& device_path,
const VoidDBusMethodCallback& callback) {
+ PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
}
void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path,
@@ -40,18 +76,47 @@ void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path,
const base::Value& value,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::DictionaryValue* device_properties = NULL;
+ if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
+ &device_properties)) {
+ std::string error_name("org.chromium.flimflam.Error.Failure");
+ std::string error_message("Failed");
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(error_callback,
+ error_name,
+ error_message));
+ return;
+ }
+ device_properties->SetWithoutPathExpansion(name, value.DeepCopy());
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged,
+ weak_ptr_factory_.GetWeakPtr(), device_path, name));
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::ClearProperty(
const dbus::ObjectPath& device_path,
const std::string& name,
const VoidDBusMethodCallback& callback) {
+ base::DictionaryValue* device_properties = NULL;
+ if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
+ &device_properties)) {
+ PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE);
+ return;
+ }
+ device_properties->RemoveWithoutPathExpansion(name, NULL);
+ PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
}
void FakeShillDeviceClient::AddIPConfig(
const dbus::ObjectPath& device_path,
const std::string& method,
const ObjectPathDBusMethodCallback& callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback,
+ DBUS_METHOD_CALL_SUCCESS,
+ dbus::ObjectPath()));
}
void FakeShillDeviceClient::RequirePin(const dbus::ObjectPath& device_path,
@@ -59,12 +124,14 @@ void FakeShillDeviceClient::RequirePin(const dbus::ObjectPath& device_path,
bool require,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::EnterPin(const dbus::ObjectPath& device_path,
const std::string& pin,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::UnblockPin(const dbus::ObjectPath& device_path,
@@ -72,6 +139,7 @@ void FakeShillDeviceClient::UnblockPin(const dbus::ObjectPath& device_path,
const std::string& pin,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::ChangePin(const dbus::ObjectPath& device_path,
@@ -79,28 +147,155 @@ void FakeShillDeviceClient::ChangePin(const dbus::ObjectPath& device_path,
const std::string& new_pin,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::Register(const dbus::ObjectPath& device_path,
const std::string& network_id,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::SetCarrier(const dbus::ObjectPath& device_path,
const std::string& carrier,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback);
+}
+
+ShillDeviceClient::TestInterface* FakeShillDeviceClient::GetTestInterface() {
+ return this;
+}
+
+// ShillDeviceClient::TestInterface overrides.
+
+void FakeShillDeviceClient::AddDevice(const std::string& device_path,
+ const std::string& type,
+ const std::string& object_path) {
+ DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
+ AddDevice(device_path);
+
+ base::DictionaryValue* properties = GetDeviceProperties(device_path);
+ properties->SetWithoutPathExpansion(
+ shill::kTypeProperty,
+ base::Value::CreateStringValue(type));
+ properties->SetWithoutPathExpansion(
+ shill::kDBusObjectProperty,
+ base::Value::CreateStringValue(object_path));
+ properties->SetWithoutPathExpansion(
+ shill::kDBusConnectionProperty,
+ base::Value::CreateStringValue("/stub"));
+}
+
+void FakeShillDeviceClient::RemoveDevice(const std::string& device_path) {
+ DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
+ RemoveDevice(device_path);
+
+ stub_devices_.RemoveWithoutPathExpansion(device_path, NULL);
+}
+
+void FakeShillDeviceClient::ClearDevices() {
+ DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
+ ClearDevices();
+
+ stub_devices_.Clear();
+}
+
+void FakeShillDeviceClient::SetDeviceProperty(const std::string& device_path,
+ const std::string& name,
+ const base::Value& value) {
+ VLOG(1) << "SetDeviceProperty: " << device_path
+ << ": " << name << " = " << value;
+ SetProperty(dbus::ObjectPath(device_path), name, value,
+ base::Bind(&base::DoNothing),
+ base::Bind(&ErrorFunction, device_path));
+}
+
+std::string FakeShillDeviceClient::GetDevicePathForType(
+ const std::string& type) {
+ for (base::DictionaryValue::Iterator iter(stub_devices_);
+ !iter.IsAtEnd(); iter.Advance()) {
+ const base::DictionaryValue* properties = NULL;
+ if (!iter.value().GetAsDictionary(&properties))
+ continue;
+ std::string prop_type;
+ if (!properties->GetStringWithoutPathExpansion(
+ shill::kTypeProperty, &prop_type) ||
+ prop_type != type)
+ continue;
+ return iter.key();
+ }
+ return std::string();
+}
+
+void FakeShillDeviceClient::PassStubDeviceProperties(
+ const dbus::ObjectPath& device_path,
+ const DictionaryValueCallback& callback) const {
+ const base::DictionaryValue* device_properties = NULL;
+ if (!stub_devices_.GetDictionaryWithoutPathExpansion(
+ device_path.value(), &device_properties)) {
+ base::DictionaryValue empty_dictionary;
+ callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary);
+ return;
+ }
+ callback.Run(DBUS_METHOD_CALL_SUCCESS, *device_properties);
+}
+
+// Posts a task to run a void callback with status code |status|.
+void FakeShillDeviceClient::PostVoidCallback(
+ const VoidDBusMethodCallback& callback,
+ DBusMethodCallStatus status) {
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback, status));
+}
+
+void FakeShillDeviceClient::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,
+ GetObserverList(device_path),
+ OnPropertyChanged(property, *value));
+}
+
+base::DictionaryValue* FakeShillDeviceClient::GetDeviceProperties(
+ const std::string& device_path) {
+ base::DictionaryValue* properties = NULL;
+ if (!stub_devices_.GetDictionaryWithoutPathExpansion(
+ device_path, &properties)) {
+ properties = new base::DictionaryValue;
+ stub_devices_.SetWithoutPathExpansion(device_path, properties);
+ }
+ return properties;
}
-FakeShillDeviceClient::TestInterface*
-FakeShillDeviceClient::GetTestInterface() {
- return NULL;
+FakeShillDeviceClient::PropertyObserverList&
+FakeShillDeviceClient::GetObserverList(const dbus::ObjectPath& device_path) {
+ std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
+ observer_list_.find(device_path);
+ if (iter != observer_list_.end())
+ return *(iter->second);
+ PropertyObserverList* observer_list = new PropertyObserverList();
+ observer_list_[device_path] = observer_list;
+ return *observer_list;
}
} // namespace chromeos
diff --git a/chromeos/dbus/fake_shill_device_client.h b/chromeos/dbus/fake_shill_device_client.h
index c97bae1..cb5b859 100644
--- a/chromeos/dbus/fake_shill_device_client.h
+++ b/chromeos/dbus/fake_shill_device_client.h
@@ -5,15 +5,19 @@
#ifndef CHROMEOS_DBUS_FAKE_SHILL_DEVICE_CLIENT_H_
#define CHROMEOS_DBUS_FAKE_SHILL_DEVICE_CLIENT_H_
-#include "base/callback_forward.h"
-#include "base/values.h"
+#include <string>
+
+#include "base/basictypes.h"
+#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/shill_device_client.h"
-#include "chromeos/dbus/shill_property_changed_observer.h"
namespace chromeos {
-// A fake implementation of ShillDeviceClient. This class does nothing.
-class FakeShillDeviceClient : public ShillDeviceClient {
+// A fake implementation of ShillDeviceClient.
+// Implemented: Stub cellular device for SMS testing.
+class CHROMEOS_EXPORT FakeShillDeviceClient
+ : public ShillDeviceClient,
+ public ShillDeviceClient::TestInterface {
public:
FakeShillDeviceClient();
virtual ~FakeShillDeviceClient();
@@ -72,9 +76,44 @@ class FakeShillDeviceClient : public ShillDeviceClient {
virtual void Reset(const dbus::ObjectPath& device_path,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE;
- virtual TestInterface* GetTestInterface() OVERRIDE;
+ virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE;
+
+ // ShillDeviceClient::TestInterface overrides.
+ virtual void AddDevice(const std::string& device_path,
+ const std::string& type,
+ const std::string& object_path) OVERRIDE;
+ virtual void RemoveDevice(const std::string& device_path) OVERRIDE;
+ virtual void ClearDevices() OVERRIDE;
+ virtual void SetDeviceProperty(const std::string& device_path,
+ const std::string& name,
+ const base::Value& value) OVERRIDE;
+ virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE;
private:
+ typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
+
+ void SetDefaultProperties();
+ void PassStubDeviceProperties(const dbus::ObjectPath& device_path,
+ const DictionaryValueCallback& callback) const;
+
+ // Posts a task to run a void callback with status code |status|.
+ void PostVoidCallback(const VoidDBusMethodCallback& callback,
+ DBusMethodCallStatus status);
+
+ void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path,
+ const std::string& property);
+ base::DictionaryValue* GetDeviceProperties(const std::string& device_path);
+ PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
+
+ // Dictionary of <device_name, Dictionary>.
+ base::DictionaryValue stub_devices_;
+ // Observer list for each device.
+ std::map<dbus::ObjectPath, PropertyObserverList*> 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.
+ base::WeakPtrFactory<FakeShillDeviceClient> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(FakeShillDeviceClient);
};
diff --git a/chromeos/dbus/shill_ipconfig_client_stub.cc b/chromeos/dbus/fake_shill_ipconfig_client.cc
index 1907e15..625d7b4 100644
--- a/chromeos/dbus/shill_ipconfig_client_stub.cc
+++ b/chromeos/dbus/fake_shill_ipconfig_client.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chromeos/dbus/shill_ipconfig_client_stub.h"
+#include "chromeos/dbus/fake_shill_ipconfig_client.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
@@ -18,30 +18,30 @@
namespace chromeos {
-ShillIPConfigClientStub::ShillIPConfigClientStub() : weak_ptr_factory_(this) {
+FakeShillIPConfigClient::FakeShillIPConfigClient() : weak_ptr_factory_(this) {
}
-ShillIPConfigClientStub::~ShillIPConfigClientStub() {
+FakeShillIPConfigClient::~FakeShillIPConfigClient() {
}
-void ShillIPConfigClientStub::Init(dbus::Bus* bus) {
+void FakeShillIPConfigClient::Init(dbus::Bus* bus) {
}
-void ShillIPConfigClientStub::AddPropertyChangedObserver(
+void FakeShillIPConfigClient::AddPropertyChangedObserver(
const dbus::ObjectPath& ipconfig_path,
ShillPropertyChangedObserver* observer) {
}
-void ShillIPConfigClientStub::RemovePropertyChangedObserver(
+void FakeShillIPConfigClient::RemovePropertyChangedObserver(
const dbus::ObjectPath& ipconfig_path,
ShillPropertyChangedObserver* observer) {
}
-void ShillIPConfigClientStub::Refresh(const dbus::ObjectPath& ipconfig_path,
+void FakeShillIPConfigClient::Refresh(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) {
}
-void ShillIPConfigClientStub::GetProperties(
+void FakeShillIPConfigClient::GetProperties(
const dbus::ObjectPath& ipconfig_path,
const DictionaryValueCallback& callback) {
const base::DictionaryValue* dict = NULL;
@@ -49,13 +49,13 @@ void ShillIPConfigClientStub::GetProperties(
&dict))
return;
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ShillIPConfigClientStub::PassProperties,
+ FROM_HERE, base::Bind(&FakeShillIPConfigClient::PassProperties,
weak_ptr_factory_.GetWeakPtr(),
dict,
callback));
}
-void ShillIPConfigClientStub::SetProperty(
+void FakeShillIPConfigClient::SetProperty(
const dbus::ObjectPath& ipconfig_path,
const std::string& name,
const base::Value& value,
@@ -76,7 +76,7 @@ void ShillIPConfigClientStub::SetProperty(
FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
}
-void ShillIPConfigClientStub::ClearProperty(
+void FakeShillIPConfigClient::ClearProperty(
const dbus::ObjectPath& ipconfig_path,
const std::string& name,
const VoidDBusMethodCallback& callback) {
@@ -84,13 +84,13 @@ void ShillIPConfigClientStub::ClearProperty(
FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
}
-void ShillIPConfigClientStub::Remove(const dbus::ObjectPath& ipconfig_path,
+void FakeShillIPConfigClient::Remove(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
}
-void ShillIPConfigClientStub::PassProperties(
+void FakeShillIPConfigClient::PassProperties(
const base::DictionaryValue* values,
const DictionaryValueCallback& callback) const {
callback.Run(DBUS_METHOD_CALL_SUCCESS, *values);
diff --git a/chromeos/dbus/shill_ipconfig_client_stub.h b/chromeos/dbus/fake_shill_ipconfig_client.h
index 28faca1..ec5dee2 100644
--- a/chromeos/dbus/shill_ipconfig_client_stub.h
+++ b/chromeos/dbus/fake_shill_ipconfig_client.h
@@ -1,22 +1,23 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_STUB_H_
-#define CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_STUB_H_
+#ifndef CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
+#define CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
#include <string>
#include "base/basictypes.h"
+#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/shill_ipconfig_client.h"
namespace chromeos {
-// A stub implementation of ShillIPConfigClient.
-class ShillIPConfigClientStub : public ShillIPConfigClient {
+// A fake implementation of ShillIPConfigClient.
+class CHROMEOS_EXPORT FakeShillIPConfigClient : public ShillIPConfigClient {
public:
- ShillIPConfigClientStub();
- virtual ~ShillIPConfigClientStub();
+ FakeShillIPConfigClient();
+ virtual ~FakeShillIPConfigClient();
// ShillIPConfigClient overrides
virtual void Init(dbus::Bus* bus) OVERRIDE;
@@ -50,11 +51,11 @@ class ShillIPConfigClientStub : public ShillIPConfigClient {
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
- base::WeakPtrFactory<ShillIPConfigClientStub> weak_ptr_factory_;
+ base::WeakPtrFactory<FakeShillIPConfigClient> weak_ptr_factory_;
- DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientStub);
+ DISALLOW_COPY_AND_ASSIGN(FakeShillIPConfigClient);
};
} // namespace chromeos
-#endif // CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_STUB_H_
+#endif // CHROMEOS_DBUS_FAKE_SHILL_IPCONFIG_CLIENT_H_
diff --git a/chromeos/dbus/mock_dbus_thread_manager.cc b/chromeos/dbus/mock_dbus_thread_manager.cc
index 11b97f6..a6eb16b 100644
--- a/chromeos/dbus/mock_dbus_thread_manager.cc
+++ b/chromeos/dbus/mock_dbus_thread_manager.cc
@@ -11,12 +11,12 @@
#include "chromeos/dbus/fake_bluetooth_input_client.h"
#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
#include "chromeos/dbus/fake_gsm_sms_client.h"
+#include "chromeos/dbus/fake_shill_device_client.h"
+#include "chromeos/dbus/fake_shill_ipconfig_client.h"
#include "chromeos/dbus/ibus/mock_ibus_client.h"
#include "chromeos/dbus/ibus/mock_ibus_engine_factory_service.h"
#include "chromeos/dbus/ibus/mock_ibus_engine_service.h"
#include "chromeos/dbus/mock_cryptohome_client.h"
-#include "chromeos/dbus/mock_shill_device_client.h"
-#include "chromeos/dbus/mock_shill_ipconfig_client.h"
#include "chromeos/dbus/mock_shill_manager_client.h"
#include "chromeos/dbus/mock_shill_profile_client.h"
#include "chromeos/dbus/mock_shill_service_client.h"
@@ -55,9 +55,9 @@ MockDBusThreadManager::MockDBusThreadManager()
fake_bluetooth_profile_manager_client_(
new FakeBluetoothProfileManagerClient),
fake_gsm_sms_client_(new FakeGsmSMSClient),
+ fake_shill_device_client_(new FakeShillDeviceClient),
+ fake_shill_ipconfig_client_(new FakeShillIPConfigClient),
mock_cryptohome_client_(new MockCryptohomeClient),
- mock_shill_device_client_(new MockShillDeviceClient),
- mock_shill_ipconfig_client_(new MockShillIPConfigClient),
mock_shill_manager_client_(new MockShillManagerClient),
mock_shill_profile_client_(new MockShillProfileClient),
mock_shill_service_client_(new MockShillServiceClient),
@@ -75,9 +75,9 @@ MockDBusThreadManager::MockDBusThreadManager()
EXPECT_CALL(*this, GetBluetoothProfileManagerClient())
.WillRepeatedly(Return(fake_bluetooth_profile_manager_client()));
EXPECT_CALL(*this, GetShillDeviceClient())
- .WillRepeatedly(Return(mock_shill_device_client()));
+ .WillRepeatedly(Return(fake_shill_device_client()));
EXPECT_CALL(*this, GetShillIPConfigClient())
- .WillRepeatedly(Return(mock_shill_ipconfig_client()));
+ .WillRepeatedly(Return(fake_shill_ipconfig_client()));
EXPECT_CALL(*this, GetShillManagerClient())
.WillRepeatedly(Return(mock_shill_manager_client()));
EXPECT_CALL(*this, GetShillProfileClient())
diff --git a/chromeos/dbus/mock_dbus_thread_manager.h b/chromeos/dbus/mock_dbus_thread_manager.h
index 23bca2e..80ea9cf 100644
--- a/chromeos/dbus/mock_dbus_thread_manager.h
+++ b/chromeos/dbus/mock_dbus_thread_manager.h
@@ -26,14 +26,14 @@ class FakeBluetoothDeviceClient;
class FakeBluetoothInputClient;
class FakeBluetoothProfileManagerClient;
class FakeGsmSMSClient;
+class FakeShillDeviceClient;
+class FakeShillIPConfigClient;
class MockCryptohomeClient;
-class MockShillDeviceClient;
-class MockShillIPConfigClient;
+class MockPowerManagerClient;
+class MockSessionManagerClient;
class MockShillManagerClient;
class MockShillProfileClient;
class MockShillServiceClient;
-class MockPowerManagerClient;
-class MockSessionManagerClient;
// This class provides a mock DBusThreadManager with mock clients
// installed. You can customize the behaviors of mock clients with
@@ -103,14 +103,14 @@ class MockDBusThreadManager : public DBusThreadManager {
FakeGsmSMSClient* fake_gsm_sms_client() {
return fake_gsm_sms_client_.get();
}
- MockCryptohomeClient* mock_cryptohome_client() {
- return mock_cryptohome_client_.get();
+ FakeShillDeviceClient* fake_shill_device_client() {
+ return fake_shill_device_client_.get();
}
- MockShillDeviceClient* mock_shill_device_client() {
- return mock_shill_device_client_.get();
+ FakeShillIPConfigClient* fake_shill_ipconfig_client() {
+ return fake_shill_ipconfig_client_.get();
}
- MockShillIPConfigClient* mock_shill_ipconfig_client() {
- return mock_shill_ipconfig_client_.get();
+ MockCryptohomeClient* mock_cryptohome_client() {
+ return mock_cryptohome_client_.get();
}
MockShillManagerClient* mock_shill_manager_client() {
return mock_shill_manager_client_.get();
@@ -138,9 +138,9 @@ class MockDBusThreadManager : public DBusThreadManager {
scoped_ptr<FakeBluetoothProfileManagerClient>
fake_bluetooth_profile_manager_client_;
scoped_ptr<FakeGsmSMSClient> fake_gsm_sms_client_;
+ scoped_ptr<FakeShillDeviceClient> fake_shill_device_client_;
+ scoped_ptr<FakeShillIPConfigClient> fake_shill_ipconfig_client_;
scoped_ptr<MockCryptohomeClient> mock_cryptohome_client_;
- scoped_ptr<MockShillDeviceClient> mock_shill_device_client_;
- scoped_ptr<MockShillIPConfigClient> mock_shill_ipconfig_client_;
scoped_ptr<MockShillManagerClient> mock_shill_manager_client_;
scoped_ptr<MockShillProfileClient> mock_shill_profile_client_;
scoped_ptr<MockShillServiceClient> mock_shill_service_client_;
diff --git a/chromeos/dbus/mock_shill_device_client.cc b/chromeos/dbus/mock_shill_device_client.cc
deleted file mode 100644
index d1f3a96..0000000
--- a/chromeos/dbus/mock_shill_device_client.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromeos/dbus/mock_shill_device_client.h"
-
-namespace chromeos {
-
-MockShillDeviceClient::MockShillDeviceClient() {}
-
-MockShillDeviceClient::~MockShillDeviceClient() {}
-
-} // namespace chromeos
diff --git a/chromeos/dbus/mock_shill_device_client.h b/chromeos/dbus/mock_shill_device_client.h
deleted file mode 100644
index 6a19aae..0000000
--- a/chromeos/dbus/mock_shill_device_client.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMEOS_DBUS_MOCK_SHILL_DEVICE_CLIENT_H_
-#define CHROMEOS_DBUS_MOCK_SHILL_DEVICE_CLIENT_H_
-
-#include "base/values.h"
-#include "chromeos/dbus/shill_device_client.h"
-#include "chromeos/dbus/shill_property_changed_observer.h"
-#include "dbus/object_path.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-namespace chromeos {
-
-class MockShillDeviceClient : public ShillDeviceClient {
- public:
- MockShillDeviceClient();
- virtual ~MockShillDeviceClient();
-
- MOCK_METHOD1(Init, void(dbus::Bus* bus));
- MOCK_METHOD2(AddPropertyChangedObserver,
- void(const dbus::ObjectPath& device_path,
- ShillPropertyChangedObserver* observer));
- MOCK_METHOD2(RemovePropertyChangedObserver,
- void(const dbus::ObjectPath& device_path,
- ShillPropertyChangedObserver* observer));
- MOCK_METHOD2(GetProperties, void(const dbus::ObjectPath& device_path,
- const DictionaryValueCallback& callback));
- MOCK_METHOD2(ProposeScan, void(const dbus::ObjectPath& device_path,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD5(SetProperty, void(const dbus::ObjectPath& device_path,
- const std::string& name,
- const base::Value& value,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD3(ClearProperty, void(const dbus::ObjectPath& device_path,
- const std::string& name,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD3(AddIPConfig, void(const dbus::ObjectPath& device_path,
- const std::string& method,
- const ObjectPathDBusMethodCallback& callback));
- MOCK_METHOD5(RequirePin, void(const dbus::ObjectPath& device_path,
- const std::string& pin,
- bool require,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD4(EnterPin, void(const dbus::ObjectPath& device_path,
- const std::string& pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD5(UnblockPin, void(const dbus::ObjectPath& device_path,
- const std::string& puk,
- const std::string& pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD5(ChangePin, void(const dbus::ObjectPath& device_path,
- const std::string& old_pin,
- const std::string& new_pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD4(Register, void(const dbus::ObjectPath& device_path,
- const std::string& network_id,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD4(SetCarrier, void(const dbus::ObjectPath& device_path,
- const std::string& carrier,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD3(Reset, void(const dbus::ObjectPath& device_path,
- const base::Closure& callback,
- const ErrorCallback& error_callback));
- MOCK_METHOD0(GetTestInterface, TestInterface*());
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_DBUS_MOCK_SHILL_DEVICE_CLIENT_H_
diff --git a/chromeos/dbus/mock_shill_ipconfig_client.cc b/chromeos/dbus/mock_shill_ipconfig_client.cc
deleted file mode 100644
index 00053eb..0000000
--- a/chromeos/dbus/mock_shill_ipconfig_client.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromeos/dbus/mock_shill_ipconfig_client.h"
-
-namespace chromeos {
-
-MockShillIPConfigClient::MockShillIPConfigClient() {}
-
-MockShillIPConfigClient::~MockShillIPConfigClient() {}
-
-} // namespace chromeos
diff --git a/chromeos/dbus/mock_shill_ipconfig_client.h b/chromeos/dbus/mock_shill_ipconfig_client.h
deleted file mode 100644
index 0d531c8..0000000
--- a/chromeos/dbus/mock_shill_ipconfig_client.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMEOS_DBUS_MOCK_SHILL_IPCONFIG_CLIENT_H_
-#define CHROMEOS_DBUS_MOCK_SHILL_IPCONFIG_CLIENT_H_
-
-#include "base/values.h"
-#include "chromeos/dbus/shill_ipconfig_client.h"
-#include "chromeos/dbus/shill_property_changed_observer.h"
-#include "dbus/object_path.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-namespace chromeos {
-
-class MockShillIPConfigClient : public ShillIPConfigClient {
- public:
- MockShillIPConfigClient();
- virtual ~MockShillIPConfigClient();
-
- MOCK_METHOD1(Init, void(dbus::Bus* bus));
- MOCK_METHOD2(AddPropertyChangedObserver,
- void(const dbus::ObjectPath& ipconfig_path,
- ShillPropertyChangedObserver* observer));
- MOCK_METHOD2(RemovePropertyChangedObserver,
- void(const dbus::ObjectPath& ipconfig_path,
- ShillPropertyChangedObserver* observer));
- MOCK_METHOD2(Refresh, void(const dbus::ObjectPath& ipconfig_path,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(GetProperties, void(const dbus::ObjectPath& ipconfig_path,
- const DictionaryValueCallback& callback));
- MOCK_METHOD4(SetProperty, void(const dbus::ObjectPath& ipconfig_path,
- const std::string& name,
- const base::Value& value,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD3(ClearProperty, void(const dbus::ObjectPath& ipconfig_path,
- const std::string& name,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(Remove, void(const dbus::ObjectPath& ipconfig_path,
- const VoidDBusMethodCallback& callback));
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_DBUS_MOCK_SHILL_IPCONFIG_CLIENT_H_
diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc
index 5aa4332..e9ad998 100644
--- a/chromeos/dbus/shill_device_client.cc
+++ b/chromeos/dbus/shill_device_client.cc
@@ -8,7 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/values.h"
-#include "chromeos/dbus/shill_device_client_stub.h"
+#include "chromeos/dbus/fake_shill_device_client.h"
#include "chromeos/dbus/shill_property_changed_observer.h"
#include "dbus/bus.h"
#include "dbus/message.h"
@@ -240,7 +240,7 @@ ShillDeviceClient* ShillDeviceClient::Create(
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
return new ShillDeviceClientImpl();
DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
- return new ShillDeviceClientStub();
+ return new FakeShillDeviceClient();
}
} // namespace chromeos
diff --git a/chromeos/dbus/shill_device_client_stub.cc b/chromeos/dbus/shill_device_client_stub.cc
deleted file mode 100644
index 98d5894..0000000
--- a/chromeos/dbus/shill_device_client_stub.cc
+++ /dev/null
@@ -1,300 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromeos/dbus/shill_device_client_stub.h"
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/stl_util.h"
-#include "base/values.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/shill_manager_client.h"
-#include "chromeos/dbus/shill_property_changed_observer.h"
-#include "dbus/bus.h"
-#include "dbus/message.h"
-#include "dbus/object_path.h"
-#include "dbus/object_proxy.h"
-#include "dbus/values_util.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-
-namespace chromeos {
-
-namespace {
-
-void ErrorFunction(const std::string& device_path,
- const std::string& error_name,
- const std::string& error_message) {
- LOG(ERROR) << "Shill Error for: " << device_path
- << ": " << error_name << " : " << error_message;
-}
-
-} // namespace
-
-ShillDeviceClientStub::ShillDeviceClientStub() : weak_ptr_factory_(this) {
-}
-
-ShillDeviceClientStub::~ShillDeviceClientStub() {
- STLDeleteContainerPairSecondPointers(
- observer_list_.begin(), observer_list_.end());
-}
-
-// ShillDeviceClient overrides.
-
-void ShillDeviceClientStub::Init(dbus::Bus* bus) {}
-
-void ShillDeviceClientStub::AddPropertyChangedObserver(
- const dbus::ObjectPath& device_path,
- ShillPropertyChangedObserver* observer){
- GetObserverList(device_path).AddObserver(observer);
-}
-
-void ShillDeviceClientStub::RemovePropertyChangedObserver(
- const dbus::ObjectPath& device_path,
- ShillPropertyChangedObserver* observer){
- GetObserverList(device_path).RemoveObserver(observer);
-}
-
-void ShillDeviceClientStub::GetProperties(
- const dbus::ObjectPath& device_path,
- const DictionaryValueCallback& callback){
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&ShillDeviceClientStub::PassStubDeviceProperties,
- weak_ptr_factory_.GetWeakPtr(),
- device_path, callback));
-}
-
-void ShillDeviceClientStub::ProposeScan(const dbus::ObjectPath& device_path,
- const VoidDBusMethodCallback& callback){
- PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
-}
-
-void ShillDeviceClientStub::SetProperty(const dbus::ObjectPath& device_path,
- const std::string& name,
- const base::Value& value,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::DictionaryValue* device_properties = NULL;
- if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
- &device_properties)) {
- std::string error_name("org.chromium.flimflam.Error.Failure");
- std::string error_message("Failed");
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(error_callback,
- error_name,
- error_message));
- return;
- }
- device_properties->SetWithoutPathExpansion(name, value.DeepCopy());
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&ShillDeviceClientStub::NotifyObserversPropertyChanged,
- weak_ptr_factory_.GetWeakPtr(), device_path, name));
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::ClearProperty(
- const dbus::ObjectPath& device_path,
- const std::string& name,
- const VoidDBusMethodCallback& callback){
- base::DictionaryValue* device_properties = NULL;
- if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
- &device_properties)) {
- PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE);
- return;
- }
- device_properties->RemoveWithoutPathExpansion(name, NULL);
- PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
-}
-
-void ShillDeviceClientStub::AddIPConfig(
- const dbus::ObjectPath& device_path,
- const std::string& method,
- const ObjectPathDBusMethodCallback& callback){
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS,
- dbus::ObjectPath()));
-}
-
-void ShillDeviceClientStub::RequirePin(const dbus::ObjectPath& device_path,
- const std::string& pin,
- bool require,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::EnterPin(const dbus::ObjectPath& device_path,
- const std::string& pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::UnblockPin(const dbus::ObjectPath& device_path,
- const std::string& puk,
- const std::string& pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::ChangePin(const dbus::ObjectPath& device_path,
- const std::string& old_pin,
- const std::string& new_pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::Register(const dbus::ObjectPath& device_path,
- const std::string& network_id,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::SetCarrier(const dbus::ObjectPath& device_path,
- const std::string& carrier,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-void ShillDeviceClientStub::Reset(const dbus::ObjectPath& device_path,
- const base::Closure& callback,
- const ErrorCallback& error_callback){
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
-}
-
-ShillDeviceClient::TestInterface* ShillDeviceClientStub::GetTestInterface(){
- return this;
-}
-
-// ShillDeviceClient::TestInterface overrides.
-
-void ShillDeviceClientStub::AddDevice(const std::string& device_path,
- const std::string& type,
- const std::string& object_path){
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- AddDevice(device_path);
-
- base::DictionaryValue* properties = GetDeviceProperties(device_path);
- properties->SetWithoutPathExpansion(
- shill::kTypeProperty,
- base::Value::CreateStringValue(type));
- properties->SetWithoutPathExpansion(
- shill::kDBusObjectProperty,
- base::Value::CreateStringValue(object_path));
- properties->SetWithoutPathExpansion(
- shill::kDBusConnectionProperty,
- base::Value::CreateStringValue("/stub"));
-}
-
-void ShillDeviceClientStub::RemoveDevice(const std::string& device_path){
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- RemoveDevice(device_path);
-
- stub_devices_.RemoveWithoutPathExpansion(device_path, NULL);
-}
-
-void ShillDeviceClientStub::ClearDevices(){
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- ClearDevices();
-
- stub_devices_.Clear();
-}
-
-void ShillDeviceClientStub::SetDeviceProperty(const std::string& device_path,
- const std::string& name,
- const base::Value& value){
- VLOG(1) << "SetDeviceProperty: " << device_path
- << ": " << name << " = " << value;
- SetProperty(dbus::ObjectPath(device_path), name, value,
- base::Bind(&base::DoNothing),
- base::Bind(&ErrorFunction, device_path));
-}
-
-std::string ShillDeviceClientStub::GetDevicePathForType(
- const std::string& type) {
- for (base::DictionaryValue::Iterator iter(stub_devices_);
- !iter.IsAtEnd(); iter.Advance()) {
- const base::DictionaryValue* properties = NULL;
- if (!iter.value().GetAsDictionary(&properties))
- continue;
- std::string prop_type;
- if (!properties->GetStringWithoutPathExpansion(
- shill::kTypeProperty, &prop_type) ||
- prop_type != type)
- continue;
- return iter.key();
- }
- return std::string();
-}
-
-void ShillDeviceClientStub::PassStubDeviceProperties(
- const dbus::ObjectPath& device_path,
- const DictionaryValueCallback& callback) const {
- const base::DictionaryValue* device_properties = NULL;
- if (!stub_devices_.GetDictionaryWithoutPathExpansion(
- device_path.value(), &device_properties)) {
- base::DictionaryValue empty_dictionary;
- callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary);
- return;
- }
- callback.Run(DBUS_METHOD_CALL_SUCCESS, *device_properties);
-}
-
-// Posts a task to run a void callback with status code |status|.
-void ShillDeviceClientStub::PostVoidCallback(
- const VoidDBusMethodCallback& callback,
- DBusMethodCallStatus status) {
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, status));
-}
-
-void ShillDeviceClientStub::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,
- GetObserverList(device_path),
- OnPropertyChanged(property, *value));
-}
-
-base::DictionaryValue* ShillDeviceClientStub::GetDeviceProperties(
- const std::string& device_path) {
- base::DictionaryValue* properties = NULL;
- if (!stub_devices_.GetDictionaryWithoutPathExpansion(
- device_path, &properties)) {
- properties = new base::DictionaryValue;
- stub_devices_.SetWithoutPathExpansion(device_path, properties);
- }
- return properties;
-}
-
-ShillDeviceClientStub::PropertyObserverList&
-ShillDeviceClientStub::GetObserverList(const dbus::ObjectPath& device_path) {
- std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
- observer_list_.find(device_path);
- if (iter != observer_list_.end())
- return *(iter->second);
- PropertyObserverList* observer_list = new PropertyObserverList();
- observer_list_[device_path] = observer_list;
- return *observer_list;
-}
-
-} // namespace chromeos
diff --git a/chromeos/dbus/shill_device_client_stub.h b/chromeos/dbus/shill_device_client_stub.h
deleted file mode 100644
index fe2ca8c..0000000
--- a/chromeos/dbus/shill_device_client_stub.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_STUB_H_
-#define CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_STUB_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "chromeos/dbus/shill_device_client.h"
-
-namespace chromeos {
-
-// A stub implementation of ShillDeviceClient.
-// Implemented: Stub cellular device for SMS testing.
-class ShillDeviceClientStub : public ShillDeviceClient,
- public ShillDeviceClient::TestInterface {
- public:
- ShillDeviceClientStub();
- virtual ~ShillDeviceClientStub();
-
- // ShillDeviceClient overrides
- virtual void Init(dbus::Bus* bus) OVERRIDE;
- virtual void AddPropertyChangedObserver(
- const dbus::ObjectPath& device_path,
- ShillPropertyChangedObserver* observer) OVERRIDE;
- virtual void RemovePropertyChangedObserver(
- const dbus::ObjectPath& device_path,
- ShillPropertyChangedObserver* observer) OVERRIDE;
- virtual void GetProperties(const dbus::ObjectPath& device_path,
- const DictionaryValueCallback& callback) OVERRIDE;
- virtual void ProposeScan(const dbus::ObjectPath& device_path,
- const VoidDBusMethodCallback& callback) OVERRIDE;
-
- virtual void SetProperty(const dbus::ObjectPath& device_path,
- const std::string& name,
- const base::Value& value,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void ClearProperty(const dbus::ObjectPath& device_path,
- const std::string& name,
- const VoidDBusMethodCallback& callback) OVERRIDE;
- virtual void AddIPConfig(
- const dbus::ObjectPath& device_path,
- const std::string& method,
- const ObjectPathDBusMethodCallback& callback) OVERRIDE;
- virtual void RequirePin(const dbus::ObjectPath& device_path,
- const std::string& pin,
- bool require,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void EnterPin(const dbus::ObjectPath& device_path,
- const std::string& pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void UnblockPin(const dbus::ObjectPath& device_path,
- const std::string& puk,
- const std::string& pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void ChangePin(const dbus::ObjectPath& device_path,
- const std::string& old_pin,
- const std::string& new_pin,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void Register(const dbus::ObjectPath& device_path,
- const std::string& network_id,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void SetCarrier(const dbus::ObjectPath& device_path,
- const std::string& carrier,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual void Reset(const dbus::ObjectPath& device_path,
- const base::Closure& callback,
- const ErrorCallback& error_callback) OVERRIDE;
- virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE;
-
- // ShillDeviceClient::TestInterface overrides.
- virtual void AddDevice(const std::string& device_path,
- const std::string& type,
- const std::string& object_path) OVERRIDE;
- virtual void RemoveDevice(const std::string& device_path) OVERRIDE;
- virtual void ClearDevices() OVERRIDE;
- virtual void SetDeviceProperty(const std::string& device_path,
- const std::string& name,
- const base::Value& value) OVERRIDE;
- virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE;
-
- private:
- typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
-
- void SetDefaultProperties();
- void PassStubDeviceProperties(const dbus::ObjectPath& device_path,
- const DictionaryValueCallback& callback) const;
-
- // Posts a task to run a void callback with status code |status|.
- void PostVoidCallback(const VoidDBusMethodCallback& callback,
- DBusMethodCallStatus status);
-
- void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path,
- const std::string& property);
- base::DictionaryValue* GetDeviceProperties(const std::string& device_path);
- PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
-
- // Dictionary of <device_name, Dictionary>.
- base::DictionaryValue stub_devices_;
- // Observer list for each device.
- std::map<dbus::ObjectPath, PropertyObserverList*> 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.
- base::WeakPtrFactory<ShillDeviceClientStub> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ShillDeviceClientStub);
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_STUB_H_
diff --git a/chromeos/dbus/shill_ipconfig_client.cc b/chromeos/dbus/shill_ipconfig_client.cc
index 46aeb71..e30346a 100644
--- a/chromeos/dbus/shill_ipconfig_client.cc
+++ b/chromeos/dbus/shill_ipconfig_client.cc
@@ -8,7 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/values.h"
-#include "chromeos/dbus/shill_ipconfig_client_stub.h"
+#include "chromeos/dbus/fake_shill_ipconfig_client.h"
#include "chromeos/dbus/shill_property_changed_observer.h"
#include "dbus/bus.h"
#include "dbus/message.h"
@@ -177,7 +177,7 @@ ShillIPConfigClient* ShillIPConfigClient::Create(
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
return new ShillIPConfigClientImpl();
DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
- return new ShillIPConfigClientStub();
+ return new FakeShillIPConfigClient();
}
} // namespace chromeos