[shill] Add support for setting properties.

This CL adds a framework for supporting RPC-exposed properties in Shill.
It also plumbs the code for setting properties on Service objects to prove
the approach.  Device and Manager settings will follow.

BUG=chromium-os:16343
TEST=build shill, run unit tests.

Change-Id: I55869453d6039e688f1a49be9dfb1ba1315efe0a
Reviewed-on: http://gerrit.chromium.org/gerrit/3004
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/device_unittest.cc b/device_unittest.cc
index 0b81954..6d84221 100644
--- a/device_unittest.cc
+++ b/device_unittest.cc
@@ -2,16 +2,33 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <gtest/gtest.h>
-
 #include "shill/device.h"
-#include "shill/dhcp_provider.h"
-#include "shill/mock_control.h"
-#include "shill/mock_glib.h"
 
-using testing::_;
-using testing::Return;
-using testing::Test;
+#include <map>
+#include <string>
+#include <vector>
+
+#include <dbus-c++/dbus.h>
+#include <chromeos/dbus/service_constants.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "shill/dbus_adaptor.h"
+#include "shill/dhcp_provider.h"
+#include "shill/manager.h"
+#include "shill/mock_control.h"
+#include "shill/mock_device.h"
+#include "shill/mock_glib.h"
+#include "shill/property_store_unittest.h"
+#include "shill/shill_event.h"
+
+using std::map;
+using std::string;
+using std::vector;
+using ::testing::_;
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::Test;
 
 namespace shill {
 
@@ -19,12 +36,13 @@
 const char kDeviceName[] = "testdevice";
 }  // namespace {}
 
-class DeviceTest : public Test {
+class DeviceTest : public PropertyStoreTest {
  public:
   DeviceTest()
       : device_(new Device(&control_interface_, NULL, NULL, kDeviceName, 0)) {
     DHCPProvider::GetInstance()->glib_ = &glib_;
   }
+  virtual ~DeviceTest() {}
 
  protected:
   MockGLib glib_;
@@ -32,6 +50,57 @@
   DeviceRefPtr device_;
 };
 
+TEST_F(DeviceTest, Contains) {
+  EXPECT_TRUE(device_->Contains(flimflam::kNameProperty));
+  EXPECT_FALSE(device_->Contains(""));
+}
+
+TEST_F(DeviceTest, Dispatch) {
+  ::DBus::Error error;
+  EXPECT_TRUE(DBusAdaptor::DispatchOnType(device_.get(),
+                                          flimflam::kPoweredProperty,
+                                          bool_v_,
+                                          error));
+  EXPECT_TRUE(DBusAdaptor::DispatchOnType(
+      device_.get(),
+      flimflam::kBgscanSignalThresholdProperty,
+      int32_v_,
+      error));
+  EXPECT_TRUE(DBusAdaptor::DispatchOnType(device_.get(),
+                                          flimflam::kScanIntervalProperty,
+                                          uint16_v_,
+                                          error));
+
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(), "", byte_v_, error));
+  EXPECT_EQ(invalid_prop_, error.name());
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(),
+                                           "",
+                                           stringmap_v_,
+                                           error));
+  EXPECT_EQ(invalid_prop_, error.name());
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(),
+                                           "",
+                                           uint32_v_,
+                                           error));
+  EXPECT_EQ(invalid_prop_, error.name());
+
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(),
+                                           flimflam::kCarrierProperty,
+                                           string_v_,
+                                           error));
+  EXPECT_EQ(invalid_args_, error.name());
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(),
+                                           flimflam::kNetworksProperty,
+                                           strings_v_,
+                                           error));
+  EXPECT_EQ(invalid_args_, error.name());
+  EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_.get(),
+                                           flimflam::kPRLVersionProperty,
+                                           int16_v_,
+                                           error));
+  EXPECT_EQ(invalid_args_, error.name());
+}
+
 TEST_F(DeviceTest, TechnologyIs) {
   EXPECT_FALSE(device_->TechnologyIs(Device::kEthernet));
 }