[shill] Enable Device objects to persist themselves to disk

BUG=chromium-os:17254
TEST=unit

Change-Id: Ia00bc2658e0fe03e13e399d7afab81cc09aa0195
Reviewed-on: http://gerrit.chromium.org/gerrit/5309
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 8d5c2cc..8142277 100644
--- a/device_unittest.cc
+++ b/device_unittest.cc
@@ -20,6 +20,7 @@
 #include "shill/mock_control.h"
 #include "shill/mock_device.h"
 #include "shill/mock_glib.h"
+#include "shill/mock_store.h"
 #include "shill/property_store_unittest.h"
 #include "shill/shill_event.h"
 
@@ -27,6 +28,7 @@
 using std::string;
 using std::vector;
 using ::testing::_;
+using ::testing::AtLeast;
 using ::testing::NiceMock;
 using ::testing::Return;
 using ::testing::Test;
@@ -122,4 +124,27 @@
   EXPECT_TRUE(device_->ipconfig_->update_callback_.get());
 }
 
+TEST_F(DeviceTest, Load) {
+  NiceMock<MockStore> storage;
+  const string id = device_->GetStorageIdentifier();
+  EXPECT_CALL(storage, ContainsGroup(id)).WillOnce(Return(true));
+  EXPECT_CALL(storage, GetBool(id, _, _))
+      .Times(AtLeast(1))
+      .WillRepeatedly(Return(true));
+  EXPECT_TRUE(device_->Load(&storage));
+}
+
+TEST_F(DeviceTest, Save) {
+  NiceMock<MockStore> storage;
+  const string id = device_->GetStorageIdentifier();
+  device_->ipconfig_ = new IPConfig(&control_interface_, kDeviceName);
+  EXPECT_CALL(storage, SetString(id, _, _))
+      .Times(AtLeast(1))
+      .WillRepeatedly(Return(true));
+  EXPECT_CALL(storage, SetBool(id, _, _))
+      .Times(AtLeast(1))
+      .WillRepeatedly(Return(true));
+  EXPECT_TRUE(device_->Save(&storage));
+}
+
 }  // namespace shill