[shill] Enable default profile to persist device info
Make Profile::Save() take a pointer to a vector of DeviceRefPtrs. The base
implementation ignores this pointer, but the DefaultProfile implementation
persists all the devices to disk.
BUG=chromium-os:17254
TEST=unit
STATUS=Verified
Change-Id: I5d72bd2319edfb9ae57366cbd5c766b558ffc8a4
Reviewed-on: http://gerrit.chromium.org/gerrit/8057
Commit-Ready: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
diff --git a/default_profile_unittest.cc b/default_profile_unittest.cc
index 84ecc16..f920e9b 100644
--- a/default_profile_unittest.cc
+++ b/default_profile_unittest.cc
@@ -6,6 +6,7 @@
#include <map>
#include <string>
+#include <vector>
#include <chromeos/dbus/service_constants.h>
#include <gtest/gtest.h>
@@ -13,11 +14,13 @@
#include "shill/manager.h"
#include "shill/mock_control.h"
+#include "shill/mock_device.h"
#include "shill/mock_store.h"
#include "shill/property_store_unittest.h"
using std::map;
using std::string;
+using std::vector;
using ::testing::_;
using ::testing::Return;
@@ -29,7 +32,13 @@
: profile_(new DefaultProfile(control_interface(),
manager(),
FilePath(kTestStoragePath),
- properties_)) {
+ properties_)),
+ device_(new MockDevice(control_interface(),
+ dispatcher(),
+ manager(),
+ "null0",
+ "addr0",
+ 0)) {
}
virtual ~DefaultProfileTest() {}
@@ -38,6 +47,7 @@
static const char kTestStoragePath[];
ProfileRefPtr profile_;
+ scoped_refptr<MockDevice> device_;
Manager::Properties properties_;
};
@@ -84,7 +94,12 @@
DefaultProfile::kStorageOfflineMode,
false))
.WillOnce(Return(true));
+
+ EXPECT_CALL(*device_.get(), Save(&storage)).WillOnce(Return(true));
+
+ manager()->RegisterDevice(device_);
ASSERT_TRUE(profile_->Save(&storage));
+ manager()->DeregisterDevice(device_);
}
TEST_F(DefaultProfileTest, GetStoragePath) {