| 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/browser_process_impl.h" | 9 #include "chrome/browser/browser_process_impl.h" |
| 10 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" | 10 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 extensions::Extension::LOAD); | 57 extensions::Extension::LOAD); |
| 58 | 58 |
| 59 current_time_ = base::Time::FromDoubleT(10); | 59 current_time_ = base::Time::FromDoubleT(10); |
| 60 ON_CALL(mock_time_, Now()) | 60 ON_CALL(mock_time_, Now()) |
| 61 .WillByDefault(testing::ReturnPointee(¤t_time_)); | 61 .WillByDefault(testing::ReturnPointee(¤t_time_)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 base::Value* RunFunctionWithExtension( | 64 base::Value* RunFunctionWithExtension( |
| 65 UIThreadExtensionFunction* function, const std::string& args) { | 65 UIThreadExtensionFunction* function, const std::string& args) { |
| 66 function->set_extension(extension_.get()); | 66 function->set_extension(extension_.get()); |
| 67 return utils::RunFunctionAndReturnResult(function, args, browser()); | 67 return utils::RunFunctionAndReturnSingleResult(function, args, browser()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 base::DictionaryValue* RunFunctionAndReturnDict( | 70 base::DictionaryValue* RunFunctionAndReturnDict( |
| 71 UIThreadExtensionFunction* function, const std::string& args) { | 71 UIThreadExtensionFunction* function, const std::string& args) { |
| 72 base::Value* result = RunFunctionWithExtension(function, args); | 72 base::Value* result = RunFunctionWithExtension(function, args); |
| 73 return result ? utils::ToDictionary(result) : NULL; | 73 return result ? utils::ToDictionary(result) : NULL; |
| 74 } | 74 } |
| 75 | 75 |
| 76 base::ListValue* RunFunctionAndReturnList( | 76 base::ListValue* RunFunctionAndReturnList( |
| 77 UIThreadExtensionFunction* function, const std::string& args) { | 77 UIThreadExtensionFunction* function, const std::string& args) { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); | 494 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); |
| 495 MessageLoop::current()->Run(); | 495 MessageLoop::current()->Run(); |
| 496 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); | 496 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); |
| 497 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); | 497 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); |
| 498 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); | 498 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); |
| 499 alarm_manager_->RemoveAllAlarms(extension_->id()); | 499 alarm_manager_->RemoveAllAlarms(extension_->id()); |
| 500 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); | 500 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace extensions | 503 } // namespace extensions |
| OLD | NEW |