Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Unified Diff: components/offline_pages/core/background/request_coordinator_unittest.cc

Issue 2775223006: [Offline Pages] Improve RequestCoordinator state tracking. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/core/background/request_coordinator_unittest.cc
diff --git a/components/offline_pages/core/background/request_coordinator_unittest.cc b/components/offline_pages/core/background/request_coordinator_unittest.cc
index 5e1b1dca3cf3046a76d3378467824ff533015eee..37eebf71bf65a809709e6d13dda9fb126bff7229 100644
--- a/components/offline_pages/core/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/core/background/request_coordinator_unittest.cc
@@ -129,9 +129,15 @@ class RequestCoordinatorTest : public testing::Test {
return coordinator_taco_->request_coordinator();
}
- bool is_busy() { return coordinator()->is_busy(); }
+ bool is_busy() {
Pete Williamson 2017/03/28 00:35:13 Better to get these to return the state, and check
romax 2017/03/28 01:09:56 Done.
+ return coordinator()->state() ==
+ RequestCoordinator::RequestCoordinatorState::OFFLINING;
+ }
- bool is_starting() { return coordinator()->is_starting(); }
+ bool is_starting() {
+ return coordinator()->state() ==
+ RequestCoordinator::RequestCoordinatorState::STARTING;
+ }
// Test processing callback function.
void ProcessingCallbackFunction(bool result) {
@@ -1171,7 +1177,7 @@ TEST_F(RequestCoordinatorTest,
PumpLoop();
EXPECT_FALSE(is_starting());
- EXPECT_FALSE(coordinator()->is_busy());
+ EXPECT_FALSE(is_busy());
EXPECT_TRUE(OfflinerWasCanceled());
}
@@ -1185,7 +1191,7 @@ TEST_F(RequestCoordinatorTest,
PumpLoop();
// Verify that immediate start from adding the request did happen.
- EXPECT_TRUE(coordinator()->is_busy());
+ EXPECT_TRUE(is_busy());
// Advance the mock clock 1 second before the watchdog timeout.
AdvanceClockBy(base::TimeDelta::FromSeconds(
@@ -1196,7 +1202,7 @@ TEST_F(RequestCoordinatorTest,
PumpLoop();
// Verify still busy.
- EXPECT_TRUE(coordinator()->is_busy());
+ EXPECT_TRUE(is_busy());
EXPECT_FALSE(OfflinerWasCanceled());
// Advance the mock clock past the watchdog timeout now.
@@ -1260,7 +1266,7 @@ TEST_F(RequestCoordinatorTest, TryNextRequestWithNoNetwork) {
EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
waiting_callback()));
PumpLoop();
- EXPECT_TRUE(coordinator()->is_busy());
+ EXPECT_TRUE(is_busy());
// Now lose the network connection.
SetNetworkConnected(false);
@@ -1271,8 +1277,8 @@ TEST_F(RequestCoordinatorTest, TryNextRequestWithNoNetwork) {
PumpLoop();
// Not starting nor busy with next request.
- EXPECT_FALSE(coordinator()->is_starting());
- EXPECT_FALSE(coordinator()->is_busy());
+ EXPECT_FALSE(is_starting());
+ EXPECT_FALSE(is_busy());
// Get queued requests.
coordinator()->queue()->GetRequests(base::Bind(
@@ -1552,7 +1558,7 @@ TEST_F(RequestCoordinatorTest, SnapshotOnLastTryForImmediateProcessing) {
observer().Clear();
// Verify that the request is being processed.
- EXPECT_TRUE(coordinator()->is_busy());
+ EXPECT_TRUE(is_busy());
// Advance the mock clock 1 second more than the watchdog timeout.
AdvanceClockBy(base::TimeDelta::FromSeconds(

Powered by Google App Engine
This is Rietveld 408576698