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

Unified Diff: components/doodle/doodle_service_unittest.cc

Issue 2776973003: [Doodle] Move ttl clamping from fetcher to service (Closed)
Patch Set: Created 3 years, 9 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/doodle/doodle_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/doodle/doodle_service_unittest.cc
diff --git a/components/doodle/doodle_service_unittest.cc b/components/doodle/doodle_service_unittest.cc
index ed978193f15ac02b5b124837a5042c83e01fe5ed..da7e25417961be3669dc6ac2a4333e8770498ed5 100644
--- a/components/doodle/doodle_service_unittest.cc
+++ b/components/doodle/doodle_service_unittest.cc
@@ -357,6 +357,20 @@ TEST_F(DoodleServiceTest, DisregardsAlreadyExpiredConfigs) {
service()->RemoveObserver(&observer);
}
+TEST_F(DoodleServiceTest, ClampsTimeToLive) {
+ // Load a config with an excessive time-to-live.
+ service()->Refresh();
+ DoodleConfig config = CreateConfig(DoodleType::SIMPLE);
+ fetcher()->ServeAllCallbacks(DoodleState::AVAILABLE,
+ base::TimeDelta::FromDays(100), config);
+ ASSERT_THAT(service()->config(), Eq(config));
+
+ // The time-to-live should have been clamped to a reasonable maximum.
+ ASSERT_THAT(task_runner()->GetPendingTaskCount(), Eq(1u));
+ EXPECT_THAT(task_runner()->NextPendingTaskDelay(),
+ Eq(base::TimeDelta::FromDays(30)));
+}
+
TEST_F(DoodleServiceTest, RecordsMetricsForSuccessfulDownload) {
base::HistogramTester histograms;
« no previous file with comments | « components/doodle/doodle_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698