summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/shill_manager_client_unittest.cc
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 18:51:24 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 18:51:24 +0000
commite499e674b043597f1f05ce1bd070241014a884a3 (patch)
tree041145537edafb540e79893654d7906f7fca6465 /chromeos/dbus/shill_manager_client_unittest.cc
parentb2ae272934e53cea31c6d279928c118b7cb1ebd3 (diff)
downloadchromium_src-e499e674b043597f1f05ce1bd070241014a884a3.zip
chromium_src-e499e674b043597f1f05ce1bd070241014a884a3.tar.gz
chromium_src-e499e674b043597f1f05ce1bd070241014a884a3.tar.bz2
Add support for Service.SetProperties
BUG=258633 R=satorux@chromium.org Review URL: https://codereview.chromium.org/18619006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/shill_manager_client_unittest.cc')
-rw-r--r--chromeos/dbus/shill_manager_client_unittest.cc82
1 files changed, 2 insertions, 80 deletions
diff --git a/chromeos/dbus/shill_manager_client_unittest.cc b/chromeos/dbus/shill_manager_client_unittest.cc
index e0d0db1..e2feccf 100644
--- a/chromeos/dbus/shill_manager_client_unittest.cc
+++ b/chromeos/dbus/shill_manager_client_unittest.cc
@@ -19,84 +19,6 @@ namespace chromeos {
namespace {
-// Pops a string-to-string dictionary from the reader.
-base::DictionaryValue* PopStringToStringDictionary(
- dbus::MessageReader* reader) {
- dbus::MessageReader array_reader(NULL);
- if (!reader->PopArray(&array_reader))
- return NULL;
- scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
- while (array_reader.HasMoreData()) {
- dbus::MessageReader entry_reader(NULL);
- std::string key;
- std::string value;
- if (!array_reader.PopDictEntry(&entry_reader) ||
- !entry_reader.PopString(&key) ||
- !entry_reader.PopString(&value))
- return NULL;
- result->SetWithoutPathExpansion(key,
- base::Value::CreateStringValue(value));
- }
- return result.release();
-}
-
-// Expects the reader to have a string-to-variant dictionary.
-void ExpectDictionaryValueArgument(
- const base::DictionaryValue* expected_dictionary,
- dbus::MessageReader* reader) {
- dbus::MessageReader array_reader(NULL);
- ASSERT_TRUE(reader->PopArray(&array_reader));
- while (array_reader.HasMoreData()) {
- dbus::MessageReader entry_reader(NULL);
- ASSERT_TRUE(array_reader.PopDictEntry(&entry_reader));
- std::string key;
- ASSERT_TRUE(entry_reader.PopString(&key));
- dbus::MessageReader variant_reader(NULL);
- ASSERT_TRUE(entry_reader.PopVariant(&variant_reader));
- scoped_ptr<base::Value> value;
- // Variants in the dictionary can be basic types or string-to-string
- // dictinoary.
- switch (variant_reader.GetDataType()) {
- case dbus::Message::ARRAY:
- value.reset(PopStringToStringDictionary(&variant_reader));
- break;
- case dbus::Message::BOOL:
- case dbus::Message::INT32:
- case dbus::Message::STRING:
- value.reset(dbus::PopDataAsValue(&variant_reader));
- break;
- default:
- NOTREACHED();
- }
- ASSERT_TRUE(value.get());
- const base::Value* expected_value = NULL;
- EXPECT_TRUE(expected_dictionary->GetWithoutPathExpansion(key,
- &expected_value));
- EXPECT_TRUE(value->Equals(expected_value));
- }
-}
-
-// Creates a DictionaryValue with example properties.
-base::DictionaryValue* CreateExampleProperties() {
- base::DictionaryValue* properties = new base::DictionaryValue;
- properties->SetWithoutPathExpansion(
- flimflam::kGuidProperty,
- base::Value::CreateStringValue("00000000-0000-0000-0000-000000000000"));
- properties->SetWithoutPathExpansion(
- flimflam::kModeProperty,
- base::Value::CreateStringValue(flimflam::kModeManaged));
- properties->SetWithoutPathExpansion(
- flimflam::kTypeProperty,
- base::Value::CreateStringValue(flimflam::kTypeWifi));
- properties->SetWithoutPathExpansion(
- flimflam::kSSIDProperty,
- base::Value::CreateStringValue("testssid"));
- properties->SetWithoutPathExpansion(
- flimflam::kSecurityProperty,
- base::Value::CreateStringValue(flimflam::kSecurityPsk));
- return properties;
-}
-
void ExpectStringArguments(const std::vector<std::string>& arguments,
dbus::MessageReader* reader) {
for (std::vector<std::string>::const_iterator iter = arguments.begin();
@@ -352,7 +274,7 @@ TEST_F(ShillManagerClientTest, ConfigureService) {
dbus::MessageWriter writer(response.get());
writer.AppendObjectPath(object_path);
// Create the argument dictionary.
- scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties());
+ scoped_ptr<base::DictionaryValue> arg(CreateExampleServiceProperties());
// Set expectations.
PrepareForMethodCall(flimflam::kConfigureServiceFunction,
base::Bind(&ExpectDictionaryValueArgument, arg.get()),
@@ -376,7 +298,7 @@ TEST_F(ShillManagerClientTest, GetService) {
dbus::MessageWriter writer(response.get());
writer.AppendObjectPath(object_path);
// Create the argument dictionary.
- scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties());
+ scoped_ptr<base::DictionaryValue> arg(CreateExampleServiceProperties());
// Set expectations.
PrepareForMethodCall(flimflam::kGetServiceFunction,
base::Bind(&ExpectDictionaryValueArgument, arg.get()),