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

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

Issue 2078113002: Don't start a second pre-render if one is in progress. (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
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 ebcbe140f39a7b3f1a30b8ffbf8e619d52ed20f4..bb4c34c080c02bb08a8b068c1a4983b01e2349b9 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/location.h"
+#include "base/logging.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/offline_pages/background/device_conditions.h"
@@ -92,6 +93,14 @@ class RequestCoordinatorTest
return coordinator_.get();
}
+ bool request_in_progress() {
+ return coordinator_->request_in_progress_;
dougarnett 2016/06/20 18:30:08 Might consider public method on Coordinator instea
Pete Williamson 2016/06/21 17:55:25 New public method is_busy() added. (Following acce
+ }
+
+ void SendRequestToOffliner(SavePageRequest& request) {
+ coordinator_->SendRequestToOffliner(request);
+ }
+
// Empty callback function
void EmptyCallbackFunction(bool result) {
}
@@ -175,6 +184,23 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) {
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback));
}
+TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) {
+ // Build a request.
+ offline_pages::SavePageRequest request(
+ kRequestId, kUrl, kClientId, base::Time::Now());
+ // Sending the request to the offliner should make it busy.
+ SendRequestToOffliner(request);
dougarnett 2016/06/20 18:30:08 Why not call StartProcessing (with some PumpLoops
Pete Williamson 2016/06/21 17:55:25 I tried that, but the process goes all the way thr
dougarnett 2016/06/22 17:25:47 Ah, so that is actually a good case that I wasn't
Pete Williamson 2016/06/22 22:32:26 If I understand your suggestion correctly, then be
dougarnett 2016/06/22 23:18:36 I see your point with OfflinerStub now - I missed
+ EXPECT_TRUE(request_in_progress());
+ // Now trying to start processing on another request should return false.
+ DeviceConditions device_conditions(false, 75,
+ net::NetworkChangeNotifier::CONNECTION_3G);
+ base::Callback<void(bool)> callback =
+ base::Bind(
+ &RequestCoordinatorTest::EmptyCallbackFunction,
+ base::Unretained(this));
+ EXPECT_FALSE(coordinator()->StartProcessing(device_conditions, callback));
+}
+
TEST_F(RequestCoordinatorTest, SavePageLater) {
EXPECT_TRUE(coordinator()->SavePageLater(kUrl, kClientId));

Powered by Google App Engine
This is Rietveld 408576698