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 f17f2993b0bdec2d0b1f6a46b9dd8138544276ee..5541742d5c3875d218d8804aef338fc56747a675 100644 |
| --- a/components/offline_pages/background/request_coordinator_unittest.cc |
| +++ b/components/offline_pages/background/request_coordinator_unittest.cc |
| @@ -544,6 +544,59 @@ TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailed) { |
| observer().last_status()); |
| } |
| +TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailedNoRetryFailure) { |
| + // Add a request to the queue, wait for callbacks to finish. |
| + offline_pages::SavePageRequest request(kRequestId1, kUrl1, kClientId1, |
| + base::Time::Now(), kUserRequested); |
| + request.MarkAttemptStarted(base::Time::Now()); |
| + coordinator()->queue()->AddRequest( |
| + request, base::Bind(&RequestCoordinatorTest::AddRequestDone, |
| + base::Unretained(this))); |
| + PumpLoop(); |
|
chili
2016/09/23 00:44:18
Just for my information... what does this do?
dougarnett
2016/09/23 18:20:01
Drives posted tasks on the task runner - eg, to ge
Pete Williamson
2016/09/27 19:25:07
To clarify a bit more, many tasks that the request
|
| + |
| + // Add second request to the queue to check handling when first fails. |
| + offline_pages::SavePageRequest request2(kRequestId2, kUrl2, kClientId2, |
| + base::Time::Now(), kUserRequested); |
| + coordinator()->queue()->AddRequest( |
| + request2, base::Bind(&RequestCoordinatorTest::AddRequestDone, |
| + base::Unretained(this))); |
| + PumpLoop(); |
| + |
| + // We need to give a callback to the request. |
| + base::Callback<void(bool)> callback = base::Bind( |
| + &RequestCoordinatorTest::EmptyCallbackFunction, base::Unretained(this)); |
| + coordinator()->SetProcessingCallbackForTest(callback); |
| + |
| + // Set up device conditions for the test. |
| + DeviceConditions device_conditions(false, 75, |
| + net::NetworkChangeNotifier::CONNECTION_3G); |
| + SetDeviceConditionsForTest(device_conditions); |
| + |
| + // Call the OfflinerDoneCallback to simulate the request failed, wait |
| + // for callbacks. |
| + EnableOfflinerCallback(true); |
|
Pete Williamson
2016/09/27 19:25:08
I don't think we want this line. As I recall, it
dougarnett
2016/09/29 01:11:23
Good catch - cleaning up the other identical cases
|
| + SendOfflinerDoneCallback( |
| + request, Offliner::RequestStatus::PRERENDERING_FAILED_NO_RETRY); |
| + PumpLoop(); |
| + |
| + // TODO(dougarnett): Consider injecting mock RequestPicker for this test |
| + // and verifying that there is as attempt to pick another request following |
| + // this non-retryable failure code. |
| + |
| + // Verify neither request is removed from the queue; wait for callbacks. |
|
Pete Williamson
2016/09/27 19:25:07
Comment looks old and may need updating (since the
dougarnett
2016/09/29 01:11:23
Done.
|
| + coordinator()->queue()->GetRequests(base::Bind( |
| + &RequestCoordinatorTest::GetRequestsDone, base::Unretained(this))); |
| + PumpLoop(); |
| + |
| + // Now just one request in the queue since non-retryable failure. |
| + EXPECT_EQ(1UL, last_requests().size()); |
| + // Check that the observer got the notification that we failed (and the |
| + // subsequent notification that the request was removed). |
| + EXPECT_TRUE(observer().completed_called()); |
| + EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::PRERENDER_FAILURE, |
| + observer().last_status()); |
| +} |
| + |
| TEST_F(RequestCoordinatorTest, OfflinerDoneForegroundCancel) { |
| // Add a request to the queue, wait for callbacks to finish. |
| offline_pages::SavePageRequest request( |