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

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

Issue 2556613003: [OfflinePages] Restarts immediate processing if stopped due to no net (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0f6648f8af83669729b5bc5f6d4f38ed71d283ba..9d6954a463ab31c034e10d453c41d843a9e3025a 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -328,6 +328,13 @@ class RequestCoordinatorTest
}
}
+ void CallConnectionTypeObserver() {
+ if (coordinator()->connection_notifier_) {
+ coordinator()->connection_notifier_->OnConnectionTypeChanged(
+ GetConnectionType());
+ }
+ }
+
void SetIsLowEndDeviceForTest(bool is_low_end_device) {
coordinator()->is_low_end_device_ = is_low_end_device;
}
@@ -695,6 +702,35 @@ TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceeded) {
observer().last_status());
}
+TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceededButLostNetwork) {
+ // Add a request to the queue and set offliner done callback for it.
+ offline_pages::SavePageRequest request(kRequestId1, kUrl1, kClientId1,
+ base::Time::Now(), kUserRequested);
+ SetupForOfflinerDoneCallbackTest(&request);
+ EnableOfflinerCallback(false);
+
+ // Add a 2nd request to the queue.
+ AddRequest2();
+
+ // Disconnect network.
+ SetNetworkConnected(false);
+
+ // Call the OfflinerDoneCallback to simulate the page being completed, wait
+ // for callbacks.
+ SendOfflinerDoneCallback(request, Offliner::RequestStatus::SAVED);
+ PumpLoop();
+ EXPECT_TRUE(immediate_schedule_callback_called());
+
+ // Verify not busy with 2nd request (since no connection).
+ EXPECT_FALSE(is_busy());
+
+ // Now connect network and verify processing starts.
+ SetNetworkConnected(true);
+ CallConnectionTypeObserver();
+ PumpLoop();
+ EXPECT_TRUE(is_busy());
+}
+
TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailed) {
// Add a request to the queue, wait for callbacks to finish.
offline_pages::SavePageRequest request(
@@ -1368,13 +1404,23 @@ TEST_F(RequestCoordinatorTest,
}
TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) {
+ // If low end device, pretend it is not so that immediate start allowed.
+ SetIsLowEndDeviceForTest(false);
+
SetNetworkConnected(false);
+ EnableOfflinerCallback(false);
EXPECT_NE(
coordinator()->SavePageLater(
kUrl1, kClientId1, kUserRequested,
RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0);
PumpLoop();
EXPECT_FALSE(is_busy());
+
+ // Now connect network and verify processing starts.
+ SetNetworkConnected(true);
+ CallConnectionTypeObserver();
+ PumpLoop();
+ EXPECT_TRUE(is_busy());
}
TEST_F(RequestCoordinatorTest,
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698