| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 alarm_manager_ = AlarmManager::Get(browser()->profile()); | 53 alarm_manager_ = AlarmManager::Get(browser()->profile()); |
| 54 alarm_manager_->SetClockForTesting(test_clock_); | 54 alarm_manager_->SetClockForTesting(test_clock_); |
| 55 | 55 |
| 56 alarm_delegate_ = new AlarmDelegate(); | 56 alarm_delegate_ = new AlarmDelegate(); |
| 57 alarm_manager_->set_delegate(alarm_delegate_); | 57 alarm_manager_->set_delegate(alarm_delegate_); |
| 58 | 58 |
| 59 extension_ = utils::CreateEmptyExtensionWithLocation( | 59 extension_ = utils::CreateEmptyExtensionWithLocation( |
| 60 extensions::Manifest::UNPACKED); | 60 extensions::Manifest::UNPACKED); |
| 61 | 61 |
| 62 // Make sure there's a RenderViewHost for alarms to warn into. | 62 // Make sure there's a RenderViewHost for alarms to warn into. |
| 63 AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_)); | 63 AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_.get())); |
| 64 contents_ = browser()->tab_strip_model()->GetActiveWebContents(); | 64 contents_ = browser()->tab_strip_model()->GetActiveWebContents(); |
| 65 | 65 |
| 66 test_clock_->SetNow(base::Time::FromDoubleT(10)); | 66 test_clock_->SetNow(base::Time::FromDoubleT(10)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 base::Value* RunFunctionWithExtension( | 69 base::Value* RunFunctionWithExtension( |
| 70 UIThreadExtensionFunction* function, const std::string& args) { | 70 UIThreadExtensionFunction* function, const std::string& args) { |
| 71 scoped_refptr<UIThreadExtensionFunction> delete_function(function); | 71 scoped_refptr<UIThreadExtensionFunction> delete_function(function); |
| 72 function->set_extension(extension_.get()); | 72 function->set_extension(extension_.get()); |
| 73 function->SetRenderViewHost(contents_->GetRenderViewHost()); | 73 function->SetRenderViewHost(contents_->GetRenderViewHost()); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); | 510 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); |
| 511 base::MessageLoop::current()->Run(); | 511 base::MessageLoop::current()->Run(); |
| 512 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); | 512 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); |
| 513 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); | 513 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); |
| 514 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); | 514 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); |
| 515 alarm_manager_->RemoveAllAlarms(extension_->id()); | 515 alarm_manager_->RemoveAllAlarms(extension_->id()); |
| 516 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); | 516 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); |
| 517 } | 517 } |
| 518 | 518 |
| 519 } // namespace extensions | 519 } // namespace extensions |
| OLD | NEW |