OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace utils = extension_function_test_utils; | 24 namespace utils = extension_function_test_utils; |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Test delegate which quits the message loop when an alarm fires. | 30 // Test delegate which quits the message loop when an alarm fires. |
31 class AlarmDelegate : public AlarmManager::Delegate { | 31 class AlarmDelegate : public AlarmManager::Delegate { |
32 public: | 32 public: |
33 virtual ~AlarmDelegate() {} | 33 ~AlarmDelegate() override {} |
34 virtual void OnAlarm(const std::string& extension_id, | 34 void OnAlarm(const std::string& extension_id, const Alarm& alarm) override { |
35 const Alarm& alarm) override { | |
36 alarms_seen.push_back(alarm.js_alarm->name); | 35 alarms_seen.push_back(alarm.js_alarm->name); |
37 if (base::MessageLoop::current()->is_running()) | 36 if (base::MessageLoop::current()->is_running()) |
38 base::MessageLoop::current()->Quit(); | 37 base::MessageLoop::current()->Quit(); |
39 } | 38 } |
40 | 39 |
41 std::vector<std::string> alarms_seen; | 40 std::vector<std::string> alarms_seen; |
42 }; | 41 }; |
43 | 42 |
44 } // namespace | 43 } // namespace |
45 | 44 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 657 |
659 // The next poll should be the first poll that hasn't happened and is in-line | 658 // The next poll should be the first poll that hasn't happened and is in-line |
660 // with the original scheduling. | 659 // with the original scheduling. |
661 // Last poll was at 380 seconds; next poll should be at 480 seconds. | 660 // Last poll was at 380 seconds; next poll should be at 480 seconds. |
662 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + | 661 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + |
663 base::TimeDelta::FromSeconds(100)).ToJsTime(), | 662 base::TimeDelta::FromSeconds(100)).ToJsTime(), |
664 alarm_manager_->next_poll_time_.ToJsTime()); | 663 alarm_manager_->next_poll_time_.ToJsTime()); |
665 } | 664 } |
666 | 665 |
667 } // namespace extensions | 666 } // namespace extensions |
OLD | NEW |