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

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

Issue 2071403003: Revises RequestCoordinator to not try to schedule another request when previous one fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 8cdcf4fd3930fbabdc8749ef702e3385e9b66fa4..ebcbe140f39a7b3f1a30b8ffbf8e619d52ed20f4 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -197,7 +197,7 @@ TEST_F(RequestCoordinatorTest, SavePageLater) {
EXPECT_TRUE(scheduler_stub->schedule_called());
}
-TEST_F(RequestCoordinatorTest, OfflinerDone) {
+TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceeded) {
// Add a request to the queue, wait for callbacks to finish.
offline_pages::SavePageRequest request(
kRequestId, kUrl, kClientId, base::Time::Now());
@@ -231,4 +231,37 @@ TEST_F(RequestCoordinatorTest, OfflinerDone) {
EXPECT_EQ(0UL, last_requests().size());
}
+TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailed) {
+ // Add a request to the queue, wait for callbacks to finish.
+ offline_pages::SavePageRequest request(
+ kRequestId, kUrl, kClientId, 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);
+
+ // Call the OfflinerDoneCallback to simulate the request failed, wait
+ // for callbacks.
+ SendOfflinerDoneCallback(request, Offliner::RequestStatus::FAILED);
+ 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();
+
+ // Still one request in the queue.
+ EXPECT_EQ(1UL, last_requests().size());
+ // TODO(dougarnett): Verify retry count gets incremented.
+}
+
} // namespace offline_pages
« 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