Index: components/offline_pages/background/request_coordinator_unittest.cc |
diff --git a/components/offline_pages/background/request_coordinator_unittest.cc b/components/offline_pages/background/request_coordinator_unittest.cc |
index d63409ed2d579cfba0a43c51ee3669b9ecf39f4f..dea4fba7e3ad809d7d63a359c5385a852c01e1f2 100644 |
--- a/components/offline_pages/background/request_coordinator_unittest.cc |
+++ b/components/offline_pages/background/request_coordinator_unittest.cc |
@@ -241,6 +241,11 @@ class RequestCoordinatorTest |
offliner_->enable_callback(enable); |
} |
+ void SetNetworkConditionsForTest( |
+ net::NetworkChangeNotifier::ConnectionType connection) { |
+ coordinator()->SetNetworkConditionsForTest(connection); |
+ } |
+ |
void SetOfflinerTimeoutForTest(const base::TimeDelta& timeout) { |
coordinator_->SetOfflinerTimeoutForTest(timeout); |
} |
@@ -347,12 +352,14 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { |
} |
TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) { |
+ SetNetworkConditionsForTest( |
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE); |
// Put the request on the queue. |
EXPECT_TRUE(coordinator()->SavePageLater(kUrl1, kClientId1, kUserRequested)); |
// Set up for the call to StartProcessing by building arguments. |
- DeviceConditions device_conditions(false, 75, |
- net::NetworkChangeNotifier::CONNECTION_3G); |
+ DeviceConditions device_conditions( |
+ false, 75, net::NetworkChangeNotifier::CONNECTION_3G); |
base::Callback<void(bool)> callback = |
base::Bind(&RequestCoordinatorTest::EmptyCallbackFunction, |
base::Unretained(this)); |
@@ -834,4 +841,20 @@ TEST_F(RequestCoordinatorTest, RemoveRequest) { |
EXPECT_EQ(kRequestId1, std::get<0>(last_remove_results().at(0))); |
} |
+TEST_F(RequestCoordinatorTest, SavePageStartsProcessingWhenConnected) { |
+ SetNetworkConditionsForTest( |
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G); |
+ EXPECT_TRUE(coordinator()->SavePageLater(kUrl1, kClientId1, kUserRequested)); |
+ PumpLoop(); |
+ EXPECT_TRUE(is_busy()); |
+} |
+ |
+TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) { |
+ SetNetworkConditionsForTest( |
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE); |
+ EXPECT_TRUE(coordinator()->SavePageLater(kUrl1, kClientId1, kUserRequested)); |
+ PumpLoop(); |
+ EXPECT_FALSE(is_busy()); |
+} |
+ |
} // namespace offline_pages |