summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 23:20:38 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 23:20:38 +0000
commita1bfc8a9208af349125e54706e06b083e7d938d7 (patch)
tree2ecd3ea7b6b3ca1ea71ed73850402b84e2063fe7 /chromeos
parent0e385397a22e81e5a1cccbe4170ea72520453383 (diff)
downloadchromium_src-a1bfc8a9208af349125e54706e06b083e7d938d7.zip
chromium_src-a1bfc8a9208af349125e54706e06b083e7d938d7.tar.gz
chromium_src-a1bfc8a9208af349125e54706e06b083e7d938d7.tar.bz2
Update shill profile entry stubs
This improves the stub behavior for services and profile entries. BUG=251922 R=gspencer@chromium.org Review URL: https://codereview.chromium.org/18165003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/dbus_thread_manager.cc16
-rw-r--r--chromeos/dbus/dbus_thread_manager.h2
-rw-r--r--chromeos/dbus/shill_manager_client_stub.cc19
-rw-r--r--chromeos/dbus/shill_profile_client.h3
-rw-r--r--chromeos/dbus/shill_profile_client_stub.cc45
-rw-r--r--chromeos/dbus/shill_profile_client_stub.h3
6 files changed, 65 insertions, 23 deletions
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index 41a576a..66f4baf 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -102,16 +102,18 @@ class DBusThreadManagerImpl : public DBusThreadManager {
debug_daemon_client_.reset(
DebugDaemonClient::Create(client_type_, system_bus_.get()));
+ // Construction order of the Stub implementations of the Shill clients
+ // matters; stub clients may depend only on clients previously constructed.
shill_manager_client_.reset(
ShillManagerClient::Create(client_type_override_, system_bus_.get()));
shill_device_client_.reset(
ShillDeviceClient::Create(client_type_override_, system_bus_.get()));
shill_ipconfig_client_.reset(
ShillIPConfigClient::Create(client_type_override_, system_bus_.get()));
- shill_profile_client_.reset(
- ShillProfileClient::Create(client_type_override_, system_bus_.get()));
shill_service_client_.reset(
ShillServiceClient::Create(client_type_override_, system_bus_.get()));
+ shill_profile_client_.reset(
+ ShillProfileClient::Create(client_type_override_, system_bus_.get()));
gsm_sms_client_.reset(
GsmSMSClient::Create(client_type_override_, system_bus_.get()));
@@ -271,14 +273,14 @@ class DBusThreadManagerImpl : public DBusThreadManager {
return shill_manager_client_.get();
}
- virtual ShillProfileClient* GetShillProfileClient() OVERRIDE {
- return shill_profile_client_.get();
- }
-
virtual ShillServiceClient* GetShillServiceClient() OVERRIDE {
return shill_service_client_.get();
}
+ virtual ShillProfileClient* GetShillProfileClient() OVERRIDE {
+ return shill_profile_client_.get();
+ }
+
virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE {
return gsm_sms_client_.get();
}
@@ -390,8 +392,8 @@ class DBusThreadManagerImpl : public DBusThreadManager {
scoped_ptr<ShillDeviceClient> shill_device_client_;
scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_;
scoped_ptr<ShillManagerClient> shill_manager_client_;
- scoped_ptr<ShillProfileClient> shill_profile_client_;
scoped_ptr<ShillServiceClient> shill_service_client_;
+ scoped_ptr<ShillProfileClient> shill_profile_client_;
scoped_ptr<GsmSMSClient> gsm_sms_client_;
scoped_ptr<ImageBurnerClient> image_burner_client_;
scoped_ptr<IntrospectableClient> introspectable_client_;
diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h
index a46ee64..07894ef 100644
--- a/chromeos/dbus/dbus_thread_manager.h
+++ b/chromeos/dbus/dbus_thread_manager.h
@@ -147,8 +147,8 @@ class CHROMEOS_EXPORT DBusThreadManager {
virtual ShillDeviceClient* GetShillDeviceClient() = 0;
virtual ShillIPConfigClient* GetShillIPConfigClient() = 0;
virtual ShillManagerClient* GetShillManagerClient() = 0;
- virtual ShillProfileClient* GetShillProfileClient() = 0;
virtual ShillServiceClient* GetShillServiceClient() = 0;
+ virtual ShillProfileClient* GetShillProfileClient() = 0;
virtual SMSClient* GetSMSClient() = 0;
virtual SystemClockClient* GetSystemClockClient() = 0;
virtual UpdateEngineClient* GetUpdateEngineClient() = 0;
diff --git a/chromeos/dbus/shill_manager_client_stub.cc b/chromeos/dbus/shill_manager_client_stub.cc
index 307c589..82eac3b 100644
--- a/chromeos/dbus/shill_manager_client_stub.cc
+++ b/chromeos/dbus/shill_manager_client_stub.cc
@@ -227,9 +227,14 @@ void ShillManagerClientStub::ConfigureService(
service_client->SetServiceProperty(service_path, iter.key(), iter.value());
}
- ShillProfileClient::TestInterface* profile_test =
- DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
- profile_test->AddService(service_path);
+ // If the Profile property is set, add it to ProfileClient.
+ std::string profile_path;
+ merged_properties->GetStringWithoutPathExpansion(flimflam::kProfileProperty,
+ &profile_path);
+ if (!profile_path.empty()) {
+ DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
+ AddService(profile_path, service_path);
+ }
if (!callback.is_null()) {
base::MessageLoop::current()->PostTask(
@@ -398,6 +403,8 @@ void ShillManagerClientStub::AddManagerService(const std::string& service_path,
base::Value::CreateStringValue(service_path))) {
CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
}
+ GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent(
+ base::Value::CreateStringValue(service_path));
if (add_to_watch_list)
AddServiceToWatchList(service_path);
}
@@ -409,6 +416,8 @@ void ShillManagerClientStub::RemoveManagerService(
service_path_value, NULL)) {
CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
}
+ GetListProperty(shill::kServiceCompleteListProperty)->Remove(
+ service_path_value, NULL);
if (GetListProperty(flimflam::kServiceWatchListProperty)->Remove(
service_path_value, NULL)) {
CallNotifyObserversPropertyChanged(
@@ -418,6 +427,7 @@ void ShillManagerClientStub::RemoveManagerService(
void ShillManagerClientStub::ClearManagerServices() {
GetListProperty(flimflam::kServicesProperty)->Clear();
+ GetListProperty(shill::kServiceCompleteListProperty)->Clear();
GetListProperty(flimflam::kServiceWatchListProperty)->Clear();
CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0);
@@ -473,6 +483,9 @@ void ShillManagerClientStub::PassStubProperties(
flimflam::kServicesProperty,
GetEnabledServiceList(flimflam::kServicesProperty));
stub_properties->SetWithoutPathExpansion(
+ shill::kServiceCompleteListProperty,
+ GetEnabledServiceList(shill::kServiceCompleteListProperty));
+ stub_properties->SetWithoutPathExpansion(
flimflam::kServiceWatchListProperty,
GetEnabledServiceList(flimflam::kServiceWatchListProperty));
callback.Run(DBUS_METHOD_CALL_SUCCESS, *stub_properties);
diff --git a/chromeos/dbus/shill_profile_client.h b/chromeos/dbus/shill_profile_client.h
index 9c6c2a7..b93f335 100644
--- a/chromeos/dbus/shill_profile_client.h
+++ b/chromeos/dbus/shill_profile_client.h
@@ -50,7 +50,8 @@ class CHROMEOS_EXPORT ShillProfileClient {
virtual void AddEntry(const std::string& profile_path,
const std::string& entry_path,
const base::DictionaryValue& properties) = 0;
- virtual bool AddService(const std::string& service_path) = 0;
+ virtual bool AddService(const std::string& profile_path,
+ const std::string& service_path) = 0;
protected:
virtual ~TestInterface() {}
diff --git a/chromeos/dbus/shill_profile_client_stub.cc b/chromeos/dbus/shill_profile_client_stub.cc
index e023237..b906d6d 100644
--- a/chromeos/dbus/shill_profile_client_stub.cc
+++ b/chromeos/dbus/shill_profile_client_stub.cc
@@ -42,6 +42,8 @@ void PassDictionary(
ShillProfileClientStub::ShillProfileClientStub() {
AddProfile(kSharedProfilePath, std::string());
+ // TODO(stevenjb): Remove implicit dependency on Service stub implementation.
+ AddService(kSharedProfilePath, "wifi2");
}
ShillProfileClientStub::~ShillProfileClientStub() {
@@ -109,10 +111,16 @@ void ShillProfileClientStub::DeleteEntry(const dbus::ObjectPath& profile_path,
return;
if (!profile->entries.RemoveWithoutPathExpansion(entry_path, NULL)) {
- error_callback.Run("Error.InvalidProfileEntry", "Invalid profile entry");
+ error_callback.Run("Error.InvalidProfileEntry", entry_path);
return;
}
+ base::StringValue profile_path_value("");
+ DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface()->
+ SetServiceProperty(entry_path,
+ flimflam::kProfileProperty,
+ profile_path_value);
+
base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
@@ -143,21 +151,38 @@ void ShillProfileClientStub::AddEntry(const std::string& profile_path,
properties.DeepCopy());
}
-bool ShillProfileClientStub::AddService(const std::string& service_path) {
+bool ShillProfileClientStub::AddService(const std::string& profile_path,
+ const std::string& service_path) {
+ ProfileProperties* profile = GetProfile(dbus::ObjectPath(profile_path),
+ ErrorCallback());
+ if (!profile) {
+ LOG(ERROR) << "No matching profile: " << profile_path;
+ return false;
+ }
+
ShillServiceClient::TestInterface* service_test =
DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
- const base::DictionaryValue* properties =
+ const base::DictionaryValue* service_properties =
service_test->GetServiceProperties(service_path);
- std::string profile_path;
- if (!properties)
+ if (!service_properties) {
+ LOG(ERROR) << "No matching service: " << service_path;
return false;
-
- properties->GetStringWithoutPathExpansion(flimflam::kProfileProperty,
- &profile_path);
- if (profile_path.empty())
+ }
+ std::string service_profile_path;
+ service_properties->GetStringWithoutPathExpansion(flimflam::kProfileProperty,
+ &service_profile_path);
+ if (!service_profile_path.empty() && service_profile_path != profile_path) {
+ LOG(ERROR) << "Service has non matching profile path: "
+ << service_profile_path;
return false;
+ }
- AddEntry(profile_path, service_path, *properties);
+ base::StringValue profile_path_value(profile_path);
+ service_test->SetServiceProperty(service_path,
+ flimflam::kProfileProperty,
+ profile_path_value);
+ profile->entries.SetWithoutPathExpansion(service_path,
+ service_properties->DeepCopy());
return true;
}
diff --git a/chromeos/dbus/shill_profile_client_stub.h b/chromeos/dbus/shill_profile_client_stub.h
index 61ab7d0..fd6ef24d 100644
--- a/chromeos/dbus/shill_profile_client_stub.h
+++ b/chromeos/dbus/shill_profile_client_stub.h
@@ -48,7 +48,8 @@ class ShillProfileClientStub : public ShillProfileClient,
virtual void AddEntry(const std::string& profile_path,
const std::string& entry_path,
const base::DictionaryValue& properties) OVERRIDE;
- virtual bool AddService(const std::string& service_path) OVERRIDE;
+ virtual bool AddService(const std::string& profile_path,
+ const std::string& service_path) OVERRIDE;
private:
struct ProfileProperties;