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_picker_unittest.cc

Issue 2176393004: Add expiration policy, code to check it, and a test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_picker_unittest.cc
diff --git a/components/offline_pages/background/request_picker_unittest.cc b/components/offline_pages/background/request_picker_unittest.cc
index e6c0092b4be3211b099fe653289225d74a91de91..c655f2e9736e372ead862d525b21d32ed75a3b1f 100644
--- a/components/offline_pages/background/request_picker_unittest.cc
+++ b/components/offline_pages/background/request_picker_unittest.cc
@@ -28,6 +28,7 @@ const GURL kUrl2("http://nytimes.com");
const ClientId kClientId2("bookmark", "5678");
const bool kUserRequested = true;
const int kAttemptCount = 1;
+const int kTwoWeeksInSeconds = 60 * 60 * 24 * 7 * 2;
// Constants for policy values - These settings represent the default values.
const bool kPreferUntried = false;
@@ -248,4 +249,20 @@ TEST_F(RequestPickerTest, ChooseLaterRequest) {
EXPECT_FALSE(request_queue_empty_called_);
}
+TEST_F(RequestPickerTest, ChooseUnexpiredRequest) {
+ base::Time creation_time1 =
+ base::Time::Now() - base::TimeDelta::FromSeconds(kTwoWeeksInSeconds);
+ base::Time creation_time2 = base::Time::Now();
+ SavePageRequest request1(kRequestId1, kUrl1, kClientId1, creation_time1,
+ kUserRequested);
+ SavePageRequest request2(kRequestId2, kUrl2, kClientId2, creation_time2,
+ kUserRequested);
+
+ QueueRequestsAndChooseOne(request1, request2);
+
+ EXPECT_EQ(kRequestId2, last_picked_->request_id());
+ EXPECT_FALSE(request_queue_empty_called_);
+}
+
+
dougarnett 2016/07/27 15:40:41 remove extra blank line
Pete Williamson 2016/07/27 17:20:06 Done.
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698