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

Unified Diff: chrome/browser/extensions/api/alarms/alarms_api_unittest.cc

Issue 141883002: Fix an issue found in https://chromiumcodereview.appspot.com/23205008/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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: chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
diff --git a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
index fa71090549ee88dd496c870a7d682bf722b90e78..91dc06abc65787a3028b7262e21a7ac47f587a8b 100644
--- a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
+++ b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
@@ -616,4 +616,29 @@ TEST_F(ExtensionAlarmsSchedulingTest, MinimumGranularity) {
alarm_manager_->test_next_poll_time_.ToJsTime());
}
+TEST_F(ExtensionAlarmsSchedulingTest, DifferentMinimumGranularities) {
+ test_clock_->SetNow(base::Time::FromJsTime(0));
+ // Create an alarm to go off in 12 seconds. This uses the default, unpacked
+ // extension - so there is no minimum granularity.
+ CreateAlarm("[\"a\", {\"periodInMinutes\": 0.2}]"); // 12 seconds.
+
+ // Create a new extension, which is packed, and has a granularity of 1 minute.
+ // CreateAlarm() uses extension_, so keep a ref of the old one around, and
+ // repopulate extension_.
+ scoped_refptr<Extension> extension2(extension_);
+ extension_ =
+ utils::CreateEmptyExtensionWithLocation(extensions::Manifest::INTERNAL);
+
+ CreateAlarm("[\"b\", {\"periodInMinutes\": 2}]");
+
+ alarm_manager_->last_poll_time_ = base::Time::FromJsTime(0);
+ alarm_manager_->ScheduleNextPoll();
+
+ // The next poll time should be 12 seconds from now - the time at which the
+ // first alarm should go off.
+ EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ +
+ base::TimeDelta::FromSeconds(12)).ToJsTime(),
+ alarm_manager_->test_next_poll_time_.ToJsTime());
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698