summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 16:45:46 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 16:45:46 +0000
commit0e7085a9497b7b4954885e81cf4a4319213dea84 (patch)
treedd082d0f9d50b781f9f1d61cb88199ee64fe28e4 /chromeos/dbus
parent03283943a1a609eb88bbd0c346a764ae0af46e29 (diff)
downloadchromium_src-0e7085a9497b7b4954885e81cf4a4319213dea84.zip
chromium_src-0e7085a9497b7b4954885e81cf4a4319213dea84.tar.gz
chromium_src-0e7085a9497b7b4954885e81cf4a4319213dea84.tar.bz2
Provide IPConfigs in networkingPrivate.GetProperties
BUG=365848 For components/wifi fixes for tests: R=pneubeck@chromium.org TBR=mef@chromium.org Review URL: https://codereview.chromium.org/267433005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/fake_shill_ipconfig_client.cc15
-rw-r--r--chromeos/dbus/fake_shill_ipconfig_client.h9
-rw-r--r--chromeos/dbus/fake_shill_manager_client.cc39
-rw-r--r--chromeos/dbus/fake_shill_service_client.cc3
-rw-r--r--chromeos/dbus/shill_ipconfig_client.cc6
-rw-r--r--chromeos/dbus/shill_ipconfig_client.h14
6 files changed, 82 insertions, 4 deletions
diff --git a/chromeos/dbus/fake_shill_ipconfig_client.cc b/chromeos/dbus/fake_shill_ipconfig_client.cc
index 625d7b4..ccb2e5e 100644
--- a/chromeos/dbus/fake_shill_ipconfig_client.cc
+++ b/chromeos/dbus/fake_shill_ipconfig_client.cc
@@ -90,6 +90,21 @@ void FakeShillIPConfigClient::Remove(const dbus::ObjectPath& ipconfig_path,
FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
}
+ShillIPConfigClient::TestInterface*
+FakeShillIPConfigClient::GetTestInterface() {
+ return this;
+}
+
+// ShillIPConfigClient::TestInterface overrides
+
+void FakeShillIPConfigClient::AddIPConfig(
+ const std::string& ip_config_path,
+ const base::DictionaryValue& properties) {
+ ipconfigs_.SetWithoutPathExpansion(ip_config_path, properties.DeepCopy());
+}
+
+// Private methods
+
void FakeShillIPConfigClient::PassProperties(
const base::DictionaryValue* values,
const DictionaryValueCallback& callback) const {
diff --git a/chromeos/dbus/fake_shill_ipconfig_client.h b/chromeos/dbus/fake_shill_ipconfig_client.h
index ec5dee2..ff25246 100644
--- a/chromeos/dbus/fake_shill_ipconfig_client.h
+++ b/chromeos/dbus/fake_shill_ipconfig_client.h
@@ -14,7 +14,9 @@
namespace chromeos {
// A fake implementation of ShillIPConfigClient.
-class CHROMEOS_EXPORT FakeShillIPConfigClient : public ShillIPConfigClient {
+class CHROMEOS_EXPORT FakeShillIPConfigClient
+ : public ShillIPConfigClient,
+ public ShillIPConfigClient::TestInterface {
public:
FakeShillIPConfigClient();
virtual ~FakeShillIPConfigClient();
@@ -40,6 +42,11 @@ class CHROMEOS_EXPORT FakeShillIPConfigClient : public ShillIPConfigClient {
const VoidDBusMethodCallback& callback) OVERRIDE;
virtual void Remove(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) OVERRIDE;
+ virtual ShillIPConfigClient::TestInterface* GetTestInterface() OVERRIDE;
+
+ // ShillIPConfigClient::TestInterface overrides.
+ virtual void AddIPConfig(const std::string& ip_config_path,
+ const base::DictionaryValue& properties) OVERRIDE;
private:
// Runs callback with |values|.
diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc
index 8c8c2b8..452f16d 100644
--- a/chromeos/dbus/fake_shill_manager_client.cc
+++ b/chromeos/dbus/fake_shill_manager_client.cc
@@ -14,6 +14,7 @@
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
+#include "chromeos/dbus/shill_ipconfig_client.h"
#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/dbus/shill_property_changed_observer.h"
#include "chromeos/dbus/shill_service_client.h"
@@ -547,12 +548,16 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
DBusThreadManager* dbus_manager = DBusThreadManager::Get();
ShillServiceClient::TestInterface* services =
dbus_manager->GetShillServiceClient()->GetTestInterface();
+ DCHECK(services);
ShillProfileClient::TestInterface* profiles =
dbus_manager->GetShillProfileClient()->GetTestInterface();
+ DCHECK(profiles);
ShillDeviceClient::TestInterface* devices =
dbus_manager->GetShillDeviceClient()->GetTestInterface();
- if (!services || !profiles || !devices)
- return;
+ DCHECK(devices);
+ ShillIPConfigClient::TestInterface* ip_configs =
+ dbus_manager->GetShillIPConfigClient()->GetTestInterface();
+ DCHECK(ip_configs);
const std::string shared_profile = ShillProfileClient::GetSharedProfilePath();
profiles->AddProfile(shared_profile, std::string());
@@ -563,12 +568,36 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
bool enabled;
std::string state;
+ // IPConfigs
+ base::DictionaryValue ipconfig_v4_dictionary;
+ ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
+ shill::kAddressProperty, "0.0.0.0");
+ ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
+ shill::kGatewayProperty, "0.0.0.1");
+ ipconfig_v4_dictionary.SetIntegerWithoutPathExpansion(
+ shill::kPrefixlenProperty, 0);
+ ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
+ shill::kMethodProperty, shill::kTypeIPv4);
+ ip_configs->AddIPConfig("ipconfig_v4_path", ipconfig_v4_dictionary);
+ base::DictionaryValue ipconfig_v6_dictionary;
+ ipconfig_v6_dictionary.SetStringWithoutPathExpansion(
+ shill::kAddressProperty, "0:0:0:0:0:0:0:0");
+ ipconfig_v6_dictionary.SetStringWithoutPathExpansion(
+ shill::kMethodProperty, shill::kTypeIPv6);
+ ip_configs->AddIPConfig("ipconfig_v6_path", ipconfig_v6_dictionary);
+
// Ethernet
state = GetInitialStateForType(shill::kTypeEthernet, &enabled);
if (state == shill::kStateOnline) {
AddTechnology(shill::kTypeEthernet, enabled);
devices->AddDevice(
"/device/eth1", shill::kTypeEthernet, "stub_eth_device1");
+ base::ListValue eth_ip_configs;
+ eth_ip_configs.AppendString("ipconfig_v4_path");
+ eth_ip_configs.AppendString("ipconfig_v6_path");
+ devices->SetDeviceProperty("/device/eth1",
+ shill::kIPConfigsProperty,
+ eth_ip_configs);
services->AddService("eth1", "eth1",
shill::kTypeEthernet,
state,
@@ -586,6 +615,12 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
}
AddTechnology(shill::kTypeWifi, enabled);
devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1");
+ base::ListValue wifi_ip_configs;
+ wifi_ip_configs.AppendString("ipconfig_v4_path");
+ wifi_ip_configs.AppendString("ipconfig_v6_path");
+ devices->SetDeviceProperty("/device/wifi1",
+ shill::kIPConfigsProperty,
+ wifi_ip_configs);
services->AddService("wifi1",
"wifi1",
diff --git a/chromeos/dbus/fake_shill_service_client.cc b/chromeos/dbus/fake_shill_service_client.cc
index 30673f3..ef4ffe6 100644
--- a/chromeos/dbus/fake_shill_service_client.cc
+++ b/chromeos/dbus/fake_shill_service_client.cc
@@ -89,7 +89,8 @@ void FakeShillServiceClient::GetProperties(
NULL);
call_status = DBUS_METHOD_CALL_SUCCESS;
} else {
- LOG(ERROR) << "Properties not found for: " << service_path.value();
+ // This may happen if we remove services from the list.
+ VLOG(2) << "Properties not found for: " << service_path.value();
result_properties.reset(new base::DictionaryValue);
call_status = DBUS_METHOD_CALL_FAILURE;
}
diff --git a/chromeos/dbus/shill_ipconfig_client.cc b/chromeos/dbus/shill_ipconfig_client.cc
index 7af7fa2..48861ed 100644
--- a/chromeos/dbus/shill_ipconfig_client.cc
+++ b/chromeos/dbus/shill_ipconfig_client.cc
@@ -51,6 +51,7 @@ class ShillIPConfigClientImpl : public ShillIPConfigClient {
const VoidDBusMethodCallback& callback) OVERRIDE;
virtual void Remove(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) OVERRIDE;
+ virtual ShillIPConfigClient::TestInterface* GetTestInterface() OVERRIDE;
protected:
virtual void Init(dbus::Bus* bus) OVERRIDE {
@@ -164,6 +165,11 @@ void ShillIPConfigClientImpl::Remove(
GetHelper(ipconfig_path)->CallVoidMethod(&method_call, callback);
}
+ShillIPConfigClient::TestInterface*
+ShillIPConfigClientImpl::GetTestInterface() {
+ return NULL;
+}
+
} // namespace
ShillIPConfigClient::ShillIPConfigClient() {}
diff --git a/chromeos/dbus/shill_ipconfig_client.h b/chromeos/dbus/shill_ipconfig_client.h
index ef144b2..379d8e9 100644
--- a/chromeos/dbus/shill_ipconfig_client.h
+++ b/chromeos/dbus/shill_ipconfig_client.h
@@ -37,6 +37,17 @@ class CHROMEOS_EXPORT ShillIPConfigClient : public DBusClient {
public:
typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
+
+ class TestInterface {
+ public:
+ // Adds an IPConfig entry.
+ virtual void AddIPConfig(const std::string& ip_config_path,
+ const base::DictionaryValue& properties) = 0;
+
+ protected:
+ virtual ~TestInterface() {}
+ };
+
virtual ~ShillIPConfigClient();
// Factory function, creates a new instance which is owned by the caller.
@@ -81,6 +92,9 @@ class CHROMEOS_EXPORT ShillIPConfigClient : public DBusClient {
virtual void Remove(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) = 0;
+ // Returns an interface for testing (stub only), or returns NULL.
+ virtual ShillIPConfigClient::TestInterface* GetTestInterface() = 0;
+
protected:
friend class ShillIPConfigClientTest;