shill: portal: Recheck portal state
Introduce a retry interval for automatically retrying portal
checks. Also provide a Manager API method for immediately
re-checking portal status.
BUG=chromium-os:27335
TEST=New unit tests, tested on real machine, including setting
PortaCheckInterval over DBus, and using Jason's addition to
test-flimflam for 'recheck-portal'.
Change-Id: Idc7def18c6f863859e94f4d4e9f266ab2670679c
Reviewed-on: https://gerrit.chromium.org/gerrit/17367
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Ready: 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 e66a469..a60d37b 100644
--- a/default_profile_unittest.cc
+++ b/default_profile_unittest.cc
@@ -120,6 +120,11 @@
DefaultProfile::kStoragePortalURL,
""))
.WillOnce(Return(true));
+ EXPECT_CALL(*storage.get(),
+ SetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStoragePortalCheckInterval,
+ "0"))
+ .WillOnce(Return(true));
EXPECT_CALL(*storage.get(), Flush()).WillOnce(Return(true));
EXPECT_CALL(*device_.get(), Save(storage.get())).WillOnce(Return(true));
@@ -148,6 +153,11 @@
DefaultProfile::kStoragePortalURL,
_))
.WillOnce(Return(false));
+ EXPECT_CALL(*storage.get(),
+ GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStoragePortalCheckInterval,
+ _))
+ .WillOnce(Return(false));
profile_->set_storage(storage.release());
Manager::Properties manager_props;
@@ -156,6 +166,8 @@
EXPECT_FALSE(manager_props.offline_mode);
EXPECT_EQ("", manager_props.check_portal_list);
EXPECT_EQ(PortalDetector::kDefaultURL, manager_props.portal_url);
+ EXPECT_EQ(PortalDetector::kDefaultCheckIntervalSeconds,
+ manager_props.portal_check_interval_seconds);
}
TEST_F(DefaultProfileTest, LoadManagerProperties) {
@@ -179,6 +191,14 @@
DefaultProfile::kStoragePortalURL,
_))
.WillOnce(DoAll(SetArgumentPointee<2>(portal_url), Return(true)));
+ const string portal_check_interval_string("10");
+ const int portal_check_interval_int = 10;
+ EXPECT_CALL(*storage.get(),
+ GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStoragePortalCheckInterval,
+ _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(portal_check_interval_string),
+ Return(true)));
profile_->set_storage(storage.release());
Manager::Properties manager_props;
@@ -187,6 +207,8 @@
EXPECT_TRUE(manager_props.offline_mode);
EXPECT_EQ(portal_list, manager_props.check_portal_list);
EXPECT_EQ(portal_url, manager_props.portal_url);
+ EXPECT_EQ(portal_check_interval_int,
+ manager_props.portal_check_interval_seconds);
}
TEST_F(DefaultProfileTest, GetStoragePath) {