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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 new AlarmsGetFunction(), "[\"7\"]")); | 316 new AlarmsGetFunction(), "[\"7\"]")); |
317 ASSERT_TRUE(result.get()); | 317 ASSERT_TRUE(result.get()); |
318 EXPECT_TRUE(JsAlarm::Populate(*result, &alarm)); | 318 EXPECT_TRUE(JsAlarm::Populate(*result, &alarm)); |
319 EXPECT_EQ("7", alarm.name); | 319 EXPECT_EQ("7", alarm.name); |
320 EXPECT_EQ(424000, alarm.scheduled_time); | 320 EXPECT_EQ(424000, alarm.scheduled_time); |
321 EXPECT_THAT(alarm.period_in_minutes, testing::Pointee(7)); | 321 EXPECT_THAT(alarm.period_in_minutes, testing::Pointee(7)); |
322 } | 322 } |
323 | 323 |
324 // Get a non-existent one. | 324 // Get a non-existent one. |
325 { | 325 { |
326 std::string error = RunFunctionAndReturnError( | 326 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary( |
327 new AlarmsGetFunction(), "[\"nobody\"]"); | 327 new AlarmsGetFunction(), "[\"nobody\"]")); |
328 EXPECT_FALSE(error.empty()); | 328 ASSERT_FALSE(result.get()); |
329 } | 329 } |
330 } | 330 } |
331 | 331 |
332 TEST_F(ExtensionAlarmsTest, GetAll) { | 332 TEST_F(ExtensionAlarmsTest, GetAll) { |
333 // Test getAll with 0 alarms. | 333 // Test getAll with 0 alarms. |
334 { | 334 { |
335 scoped_ptr<base::ListValue> result(RunFunctionAndReturnList( | 335 scoped_ptr<base::ListValue> result(RunFunctionAndReturnList( |
336 new AlarmsGetAllFunction(), "[]")); | 336 new AlarmsGetAllFunction(), "[]")); |
337 std::vector<linked_ptr<JsAlarm> > alarms = ToAlarmList(result.get()); | 337 std::vector<linked_ptr<JsAlarm> > alarms = ToAlarmList(result.get()); |
338 EXPECT_EQ(0u, alarms.size()); | 338 EXPECT_EQ(0u, alarms.size()); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 657 |
658 // 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 |
659 // with the original scheduling. | 659 // with the original scheduling. |
660 // 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. |
661 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + | 661 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + |
662 base::TimeDelta::FromSeconds(100)).ToJsTime(), | 662 base::TimeDelta::FromSeconds(100)).ToJsTime(), |
663 alarm_manager_->next_poll_time_.ToJsTime()); | 663 alarm_manager_->next_poll_time_.ToJsTime()); |
664 } | 664 } |
665 | 665 |
666 } // namespace extensions | 666 } // namespace extensions |
OLD | NEW |