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

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

Issue 2282973003: [OfflinePages] Resuming a SavePageRequest now may start processing if network is connected. (Closed)
Patch Set: Added TODO for double loop 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
« 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 70bb02c3bb5c7385bc39e6692798f5eab5517365..330e6d7cc60ebfab83270843fd63c39470eb5a19 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -851,4 +851,43 @@ TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) {
EXPECT_FALSE(is_busy());
}
+TEST_F(RequestCoordinatorTest, ResumeStartsProcessingWhenConnected) {
+ SetNetworkConditionsForTest(
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE);
+
+ // 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();
+ EXPECT_FALSE(is_busy());
+
+ // Pause the request.
+ std::vector<int64_t> request_ids;
+ request_ids.push_back(kRequestId1);
+ coordinator()->PauseRequests(request_ids);
+ PumpLoop();
+
+ // Resume the request while disconnected.
+ coordinator()->ResumeRequests(request_ids);
+ PumpLoop();
+ EXPECT_FALSE(is_busy());
+
+ // Pause the request again.
+ coordinator()->PauseRequests(request_ids);
+ PumpLoop();
+
+ // Now simulate being connected.
+ SetNetworkConditionsForTest(
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G);
+
+ // Resume the request while connected.
+ coordinator()->ResumeRequests(request_ids);
+ EXPECT_FALSE(is_busy());
+ PumpLoop();
+ EXPECT_TRUE(is_busy());
+}
+
} // 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