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/values.h" | 7 #include "base/values.h" |
8 #include "base/test/mock_time_provider.h" | 8 #include "base/test/mock_time_provider.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 extension_ = utils::CreateEmptyExtensionWithLocation( | 54 extension_ = utils::CreateEmptyExtensionWithLocation( |
55 extensions::Extension::LOAD); | 55 extensions::Extension::LOAD); |
56 | 56 |
57 current_time_ = base::Time::FromDoubleT(10); | 57 current_time_ = base::Time::FromDoubleT(10); |
58 ON_CALL(mock_time_, Now()) | 58 ON_CALL(mock_time_, Now()) |
59 .WillByDefault(testing::ReturnPointee(¤t_time_)); | 59 .WillByDefault(testing::ReturnPointee(¤t_time_)); |
60 } | 60 } |
61 | 61 |
62 base::Value* RunFunctionWithExtension( | 62 base::Value* RunFunctionWithExtension( |
63 UIThreadExtensionFunction* function, const std::string& args) { | 63 UIThreadExtensionFunction* function, const std::string& args) { |
| 64 scoped_refptr<UIThreadExtensionFunction> delete_function(function); |
64 function->set_extension(extension_.get()); | 65 function->set_extension(extension_.get()); |
65 return utils::RunFunctionAndReturnSingleResult(function, args, browser()); | 66 return utils::RunFunctionAndReturnSingleResult(function, args, browser()); |
66 } | 67 } |
67 | 68 |
68 base::DictionaryValue* RunFunctionAndReturnDict( | 69 base::DictionaryValue* RunFunctionAndReturnDict( |
69 UIThreadExtensionFunction* function, const std::string& args) { | 70 UIThreadExtensionFunction* function, const std::string& args) { |
70 base::Value* result = RunFunctionWithExtension(function, args); | 71 base::Value* result = RunFunctionWithExtension(function, args); |
71 return result ? utils::ToDictionary(result) : NULL; | 72 return result ? utils::ToDictionary(result) : NULL; |
72 } | 73 } |
73 | 74 |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); | 493 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); |
493 MessageLoop::current()->Run(); | 494 MessageLoop::current()->Run(); |
494 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); | 495 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); |
495 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); | 496 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); |
496 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); | 497 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); |
497 alarm_manager_->RemoveAllAlarms(extension_->id()); | 498 alarm_manager_->RemoveAllAlarms(extension_->id()); |
498 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); | 499 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); |
499 } | 500 } |
500 | 501 |
501 } // namespace extensions | 502 } // namespace extensions |
OLD | NEW |