Chromium Code Reviews| 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..cdb7ef7b119f271cddd2a200718300135a910fdf 100644 |
| --- a/components/offline_pages/background/request_coordinator_unittest.cc |
| +++ b/components/offline_pages/background/request_coordinator_unittest.cc |
| @@ -606,6 +606,50 @@ 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(); |
| + |
| + // Simulate the offliner responding to the cancel request |
| + SendOfflinerDoneCallback(request1, |
|
dougarnett
2016/08/23 20:59:45
as discussed, we may seeing that SendToOffliner wa
|
| + Offliner::RequestStatus::PRERENDERING_CANCELED); |
| + PumpLoop(); |
| + |
| + // OfflinerDoneCallback will not end up getting called with status SAVED, |
| + // since we cancelled the event before the LoadAndSave completed. |
| + EXPECT_EQ(Offliner::RequestStatus::PRERENDERING_CANCELED, |
| + last_offlining_status()); |
| + |
| + // 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( |