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

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

Issue 2409823002: Implement MarkRequestCompleted. (Closed)
Patch Set: rebase-update Created 4 years, 2 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 23c0e9b92d18993e1be0fb3db57a46df43c026be..18b0e67531f3e59c53536a571e5315dfab8a526b 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -944,6 +944,34 @@ TEST_F(RequestCoordinatorTest, RemoveInflightRequest) {
EXPECT_TRUE(OfflinerWasCanceled());
}
+TEST_F(RequestCoordinatorTest, MarkRequestCompleted) {
+ // Add a request to the queue.
+ 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));
+
+ // Call the method under test, making sure we send SUCCESS to the observer.
+ coordinator()->MarkRequestCompleted(kRequestId1);
+ PumpLoop();
+
+ // Our observer should have seen SUCCESS instead of REMOVED.
+ EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::SUCCESS,
+ observer().last_status());
+ EXPECT_TRUE(observer().completed_called());
+}
+
TEST_F(RequestCoordinatorTest, WatchdogTimeout) {
// Build a request to use with the pre-renderer, and put it on the queue.
offline_pages::SavePageRequest request(
« 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