[shill] Enable the getting of properties, and wire to dbus.

PropertyStore exposes getters for iterators pointing to the beginning
and end of its property maps, and a static utility method in DBusAdaptor
uses these to iterate through all the properties in the PropertyStore and build
up a map of property name -> DBus::Variant-wrapped value.

BUG=chromium-os:16343
TEST=unit tests

Change-Id: I85ebbaee167ab2feed0fcf8fe654274de352aca0
Reviewed-on: http://gerrit.chromium.org/gerrit/3359
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/device_unittest.cc b/device_unittest.cc
index 5910fd0..24a28eb 100644
--- a/device_unittest.cc
+++ b/device_unittest.cc
@@ -56,25 +56,46 @@
   EXPECT_FALSE(device_->Contains(""));
 }
 
+TEST_F(DeviceTest, GetProperties) {
+  map<string, ::DBus::Variant> props;
+  Error error(Error::kInvalidProperty, "");
+  {
+    ::DBus::Error dbus_error;
+    bool expected = true;
+    device_->SetBoolProperty(flimflam::kPoweredProperty, expected, &error);
+    DBusAdaptor::GetProperties(device_.get(), &props, &dbus_error);
+    ASSERT_FALSE(props.find(flimflam::kPoweredProperty) == props.end());
+    EXPECT_EQ(props[flimflam::kPoweredProperty].reader().get_bool(),
+              expected);
+  }
+  {
+    ::DBus::Error dbus_error;
+    DBusAdaptor::GetProperties(device_.get(), &props, &dbus_error);
+    ASSERT_FALSE(props.find(flimflam::kNameProperty) == props.end());
+    EXPECT_EQ(props[flimflam::kNameProperty].reader().get_string(),
+              string(kDeviceName));
+  }
+}
+
 TEST_F(DeviceTest, Dispatch) {
   ::DBus::Error error;
   EXPECT_TRUE(DBusAdaptor::DispatchOnType(device_.get(),
                                           flimflam::kPoweredProperty,
                                           PropertyStoreTest::kBoolV,
-                                          error));
+                                          &error));
 
   // Ensure that an attempt to write a R/O property returns InvalidArgs error.
   EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(),
                                            flimflam::kAddressProperty,
                                            PropertyStoreTest::kStringV,
-                                           error));
+                                           &error));
   EXPECT_EQ(invalid_args_, error.name());
 }
 
 TEST_P(DeviceTest, TestProperty) {
   // Ensure that an attempt to write unknown properties returns InvalidProperty.
   ::DBus::Error error;
-  EXPECT_FALSE(DBusAdaptor::DispatchOnType(&manager_, "", GetParam(), error));
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(&manager_, "", GetParam(), &error));
   EXPECT_EQ(invalid_prop_, error.name());
 }