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" |
11 #include "extensions/browser/api/alarms/alarm_manager.h" | 11 #include "extensions/browser/api/alarms/alarm_manager.h" |
12 #include "extensions/browser/api/alarms/alarms_api.h" | 12 #include "extensions/browser/api/alarms/alarms_api.h" |
13 #include "extensions/browser/api_test_utils.h" | 13 #include "extensions/browser/api_test_utils.h" |
14 #include "extensions/browser/api_unittest.h" | 14 #include "extensions/browser/api_unittest.h" |
15 #include "extensions/common/extension_messages.h" | 15 #include "extensions/common/extension_messages.h" |
16 #include "ipc/ipc_test_sink.h" | 16 #include "ipc/ipc_test_sink.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 typedef extensions::core_api::alarms::Alarm JsAlarm; | 20 typedef extensions::api::alarms::Alarm JsAlarm; |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 namespace utils = api_test_utils; | 24 namespace utils = api_test_utils; |
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: |
(...skipping 658 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 |