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

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

Issue 2266323002: Cancel prerendering when a request is paused or removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename flag Created 4 years, 4 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
« 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 41393a47f6dd97cef81d1234cae0b53e2d9501b4..b35b5945191582ef8aa36a65940b71b427220539 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -606,6 +606,40 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingLater) {
EXPECT_TRUE(OfflinerWasCanceled());
}
+// This tests that canceling a request will result in TryNextRequest() getting
+// called.
+TEST_F(RequestCoordinatorTest, RemoveInflightRequest) {
+ // Add a request to the queue, wait for callbacks to finish.
+ offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1,
+ base::Time::Now(), kUserRequested);
+ coordinator()->queue()->AddRequest(
+ request1, base::Bind(&RequestCoordinatorTest::AddRequestDone,
+ base::Unretained(this)));
+ PumpLoop();
+
+ // Ensure the start processing request stops before the completion callback.
+ EnableOfflinerCallback(false);
+
+ DeviceConditions device_conditions(false, 75,
+ net::NetworkChangeNotifier::CONNECTION_3G);
+ base::Callback<void(bool)> callback = base::Bind(
+ &RequestCoordinatorTest::EmptyCallbackFunction, base::Unretained(this));
+ EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback));
+
+ // Let all the async parts of the start processing pipeline run to completion.
+ PumpLoop();
+
+ // Remove the request while it is processing.
+ std::vector<int64_t> request_ids{kRequestId1};
+ coordinator()->RemoveRequests(request_ids);
+
+ // Let the async callbacks in the cancel run.
+ PumpLoop();
+
+ // Since offliner was started, it will have seen cancel call.
+ EXPECT_TRUE(OfflinerWasCanceled());
+}
+
TEST_F(RequestCoordinatorTest, WatchdogTimeout) {
// Build a request to use with the pre-renderer, and put it on the queue.
offline_pages::SavePageRequest request(
« 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