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

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

Issue 2294933003: [Offline Pages] Handle prerender FinalStatus UnsupportedScheme as a cancel rather than failure. (Closed)
Patch Set: Revert started try count change from this cl and added TODO with followup bug id. 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
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 330e6d7cc60ebfab83270843fd63c39470eb5a19..25c6311e1034c0437c628875ebec7a272b1969b7 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -543,6 +543,45 @@ TEST_F(RequestCoordinatorTest, OfflinerDoneForegroundCancel) {
EXPECT_EQ(0L, found_request.completed_attempt_count());
}
+TEST_F(RequestCoordinatorTest, OfflinerDonePrerenderingCancel) {
+ // 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();
+
+ // 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);
+ SendOfflinerDoneCallback(request,
+ Offliner::RequestStatus::PRERENDERING_CANCELED);
+ PumpLoop();
+
+ // Verify the request is not removed from the queue, and wait for callbacks.
+ coordinator()->queue()->GetRequests(base::Bind(
+ &RequestCoordinatorTest::GetRequestsDone, base::Unretained(this)));
+ PumpLoop();
+
+ // Request still in the queue.
+ EXPECT_EQ(1UL, last_requests().size());
+ // Verify prerendering cancel not counted as an attempt after all.
+ const SavePageRequest& found_request = last_requests().front();
+ EXPECT_EQ(0L, found_request.completed_attempt_count());
+}
+
// This tests a StopProcessing call before we have actually started the
// prerenderer.
TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingImmediately) {
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | components/offline_pages/background/request_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698