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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file tests the chrome.alarms extension API. 5 // This file tests the chrome.alarms extension API.
6 6
7 #include "base/test/simple_test_clock.h" 7 #include "base/test/simple_test_clock.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" 9 #include "chrome/browser/extensions/api/alarms/alarm_manager.h"
10 #include "chrome/browser/extensions/api/alarms/alarms_api.h" 10 #include "chrome/browser/extensions/api/alarms/alarms_api.h"
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 alarm_manager_->last_poll_time_ = base::Time::FromJsTime(2 * 60000); 609 alarm_manager_->last_poll_time_ = base::Time::FromJsTime(2 * 60000);
610 // In released extensions, we set the granularity to at least 1 610 // In released extensions, we set the granularity to at least 1
611 // minute, which makes scheduler set it to 1 minute, rather than 611 // minute, which makes scheduler set it to 1 minute, rather than
612 // 1 second later (when b is supposed to go off). 612 // 1 second later (when b is supposed to go off).
613 alarm_manager_->ScheduleNextPoll(); 613 alarm_manager_->ScheduleNextPoll();
614 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + 614 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ +
615 base::TimeDelta::FromMinutes(1)).ToJsTime(), 615 base::TimeDelta::FromMinutes(1)).ToJsTime(),
616 alarm_manager_->test_next_poll_time_.ToJsTime()); 616 alarm_manager_->test_next_poll_time_.ToJsTime());
617 } 617 }
618 618
619 TEST_F(ExtensionAlarmsSchedulingTest, DifferentMinimumGranularities) {
620 test_clock_->SetNow(base::Time::FromJsTime(0));
621 // Create an alarm to go off in 12 seconds. This uses the default, unpacked
622 // extension - so there is no minimum granularity.
623 CreateAlarm("[\"a\", {\"periodInMinutes\": 0.2}]"); // 12 seconds.
624
625 // Create a new extension, which is packed, and has a granularity of 1 minute.
626 // CreateAlarm() uses extension_, so keep a ref of the old one around, and
627 // repopulate extension_.
628 scoped_refptr<Extension> extension2(extension_);
629 extension_ =
630 utils::CreateEmptyExtensionWithLocation(extensions::Manifest::INTERNAL);
631
632 CreateAlarm("[\"b\", {\"periodInMinutes\": 2}]");
633
634 alarm_manager_->last_poll_time_ = base::Time::FromJsTime(0);
635 alarm_manager_->ScheduleNextPoll();
636
637 // The next poll time should be 12 seconds from now - the time at which the
638 // first alarm should go off.
639 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ +
640 base::TimeDelta::FromSeconds(12)).ToJsTime(),
641 alarm_manager_->test_next_poll_time_.ToJsTime());
642 }
643
619 } // namespace extensions 644 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698