[shill] Enable IPConfig to Store/Load itself
BUG=chromium-os:17256
TEST=unit
Change-Id: I7792156f95ecb2e17afaf4e3250ff3dbc0e3dac9
Reviewed-on: http://gerrit.chromium.org/gerrit/4602
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
diff --git a/ipconfig_unittest.cc b/ipconfig_unittest.cc
index 8f90607..1a7482f 100644
--- a/ipconfig_unittest.cc
+++ b/ipconfig_unittest.cc
@@ -8,7 +8,14 @@
#include <gtest/gtest.h>
#include "shill/mock_control.h"
+#include "shill/mock_store.h"
+using std::string;
+using testing::_;
+using testing::Return;
+using testing::SaveArg;
+using testing::SetArgumentPointee;
+using testing::StrictMock;
using testing::Test;
namespace shill {
@@ -42,6 +49,23 @@
EXPECT_FALSE(ipconfig_->ReleaseIP());
}
+TEST_F(IPConfigTest, SaveLoad) {
+ StrictMock<MockStore> storage;
+ string id, key, value;
+ EXPECT_CALL(storage, SetString(_, _, _))
+ .WillOnce(DoAll(SaveArg<0>(&id),
+ SaveArg<1>(&key),
+ SaveArg<2>(&value),
+ Return(true)));
+ ASSERT_TRUE(ipconfig_->Save(&storage));
+
+ EXPECT_CALL(storage, ContainsGroup(id))
+ .WillOnce(Return(true));
+ EXPECT_CALL(storage, GetString(id, key, _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(value), Return(true)));
+ ASSERT_TRUE(ipconfig_->Load(&storage));
+}
+
TEST_F(IPConfigTest, UpdateProperties) {
IPConfig::Properties properties;
properties.address = "1.2.3.4";