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

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

Issue 2196293002: Skips processing more SavePageLater requests in current processing window when one completes unsucc… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK in default case 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 ca13ae5a8da5ee00e1dd58fb1b74b8943e341a4a..eb59471a63d58a5e4c96cea95777a9e6fbd897c4 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -31,6 +31,9 @@ namespace {
// put test constants here
const GURL kUrl("http://universe.com/everything");
const ClientId kClientId("bookmark", "42");
+const int kRequestId2(2);
+const GURL kUrl2("http://universe.com/toinfinityandbeyond");
+const ClientId kClientId2("bookmark", "43");
const int kRequestId(1);
const long kTestTimeoutSeconds = 1;
const long kTestTimeBudgetSeconds = 200;
@@ -358,6 +361,15 @@ TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailed) {
base::Unretained(this)));
PumpLoop();
+ // 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(
@@ -375,23 +387,21 @@ TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailed) {
EnableOfflinerCallback(true);
SendOfflinerDoneCallback(request,
Offliner::RequestStatus::PRERENDERING_FAILED);
- // There will be one request left in the queue after the prerender fails, stop
- // processing now so that it will remain in the queue for us to check. This
- // won't affect the offliner done callback other than preventing
- // TryNextRequest from doing anything.
- coordinator()->StopProcessing();
-
PumpLoop();
- // Verify the request is not removed from the queue, and wait for callbacks.
+ // TODO(dougarnett): Consider injecting mock RequestPicker for this test
+ // and verifying that there is no attempt to pick another request following
+ // this failure code.
+
+ // Verify neither request is removed from the queue; 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());
- // Verify retry count was incremented.
+ // Still two requests in the queue.
+ EXPECT_EQ(2UL, last_requests().size());
+ // Verify retry count was incremented for first request.
const SavePageRequest& found_request = last_requests().front();
EXPECT_EQ(1L, found_request.attempt_count());
}
@@ -516,7 +526,6 @@ TEST_F(RequestCoordinatorTest, PrerendererTimeout) {
last_offlining_status());
}
-
TEST_F(RequestCoordinatorTest, TimeBudgetExceeded) {
// Build a request to use with the pre-renderer, and put it on the queue.
offline_pages::SavePageRequest request1(

Powered by Google App Engine
This is Rietveld 408576698