shill: Add Portal Detection object
Add a utility object that will perform a repeated test of an
HTTP URL and return the result to a callback.
BUG=chromium-os:23318
TEST=New unit tests
Change-Id: I0449dbe51fb1dcef2ecd3bb88de1bcaf2950f749
Reviewed-on: https://gerrit.chromium.org/gerrit/15472
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/default_profile_unittest.cc b/default_profile_unittest.cc
index 695e092..e66a469 100644
--- a/default_profile_unittest.cc
+++ b/default_profile_unittest.cc
@@ -19,6 +19,7 @@
#include "shill/mock_control.h"
#include "shill/mock_device.h"
#include "shill/mock_store.h"
+#include "shill/portal_detector.h"
#include "shill/property_store_unittest.h"
using std::map;
@@ -115,6 +116,10 @@
DefaultProfile::kStorageCheckPortalList,
""))
.WillOnce(Return(true));
+ EXPECT_CALL(*storage.get(), SetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStoragePortalURL,
+ ""))
+ .WillOnce(Return(true));
EXPECT_CALL(*storage.get(), Flush()).WillOnce(Return(true));
EXPECT_CALL(*device_.get(), Save(storage.get())).WillOnce(Return(true));
@@ -125,6 +130,34 @@
manager()->DeregisterDevice(device_);
}
+TEST_F(DefaultProfileTest, LoadManagerDefaultProperties) {
+ scoped_ptr<MockStore> storage(new MockStore);
+ EXPECT_CALL(*storage.get(), GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStorageHostName,
+ _))
+ .WillOnce(Return(false));
+ EXPECT_CALL(*storage.get(), GetBool(DefaultProfile::kStorageId,
+ DefaultProfile::kStorageOfflineMode,
+ _))
+ .WillOnce(Return(false));
+ EXPECT_CALL(*storage.get(), GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStorageCheckPortalList,
+ _))
+ .WillOnce(Return(false));
+ EXPECT_CALL(*storage.get(), GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStoragePortalURL,
+ _))
+ .WillOnce(Return(false));
+ profile_->set_storage(storage.release());
+
+ Manager::Properties manager_props;
+ ASSERT_TRUE(profile_->LoadManagerProperties(&manager_props));
+ EXPECT_EQ("", manager_props.host_name);
+ EXPECT_FALSE(manager_props.offline_mode);
+ EXPECT_EQ("", manager_props.check_portal_list);
+ EXPECT_EQ(PortalDetector::kDefaultURL, manager_props.portal_url);
+}
+
TEST_F(DefaultProfileTest, LoadManagerProperties) {
scoped_ptr<MockStore> storage(new MockStore);
const string host_name("hostname");
@@ -141,6 +174,11 @@
DefaultProfile::kStorageCheckPortalList,
_))
.WillOnce(DoAll(SetArgumentPointee<2>(portal_list), Return(true)));
+ const string portal_url("http://www.chromium.org");
+ EXPECT_CALL(*storage.get(), GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStoragePortalURL,
+ _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(portal_url), Return(true)));
profile_->set_storage(storage.release());
Manager::Properties manager_props;
@@ -148,6 +186,7 @@
EXPECT_EQ(host_name, manager_props.host_name);
EXPECT_TRUE(manager_props.offline_mode);
EXPECT_EQ(portal_list, manager_props.check_portal_list);
+ EXPECT_EQ(portal_url, manager_props.portal_url);
}
TEST_F(DefaultProfileTest, GetStoragePath) {