| 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 "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/test/mock_render_process_host.h" | 10 #include "content/public/test/mock_render_process_host.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Test delegate which quits the message loop when an alarm fires. | 28 // Test delegate which quits the message loop when an alarm fires. |
| 29 class AlarmDelegate : public AlarmManager::Delegate { | 29 class AlarmDelegate : public AlarmManager::Delegate { |
| 30 public: | 30 public: |
| 31 ~AlarmDelegate() override {} | 31 ~AlarmDelegate() override {} |
| 32 void OnAlarm(const std::string& extension_id, const Alarm& alarm) override { | 32 void OnAlarm(const std::string& extension_id, const Alarm& alarm) override { |
| 33 alarms_seen.push_back(alarm.js_alarm->name); | 33 alarms_seen.push_back(alarm.js_alarm->name); |
| 34 if (base::MessageLoop::current()->is_running()) | 34 if (base::MessageLoop::current()->is_running()) |
| 35 base::MessageLoop::current()->Quit(); | 35 base::MessageLoop::current()->QuitWhenIdle(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 std::vector<std::string> alarms_seen; | 38 std::vector<std::string> alarms_seen; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 void RunScheduleNextPoll(AlarmManager* alarm_manager) { | 43 void RunScheduleNextPoll(AlarmManager* alarm_manager) { |
| 44 alarm_manager->ScheduleNextPoll(); | 44 alarm_manager->ScheduleNextPoll(); |
| 45 } | 45 } |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 // The next poll should be the first poll that hasn't happened and is in-line | 690 // The next poll should be the first poll that hasn't happened and is in-line |
| 691 // with the original scheduling. | 691 // with the original scheduling. |
| 692 // Last poll was at 380 seconds; next poll should be at 480 seconds. | 692 // Last poll was at 380 seconds; next poll should be at 480 seconds. |
| 693 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + | 693 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + |
| 694 base::TimeDelta::FromSeconds(100)).ToJsTime(), | 694 base::TimeDelta::FromSeconds(100)).ToJsTime(), |
| 695 alarm_manager_->next_poll_time_.ToJsTime()); | 695 alarm_manager_->next_poll_time_.ToJsTime()); |
| 696 } | 696 } |
| 697 | 697 |
| 698 } // namespace extensions | 698 } // namespace extensions |
| OLD | NEW |