Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: chrome/browser/extensions/api/alarms/alarms_api_unittest.cc

Issue 14319002: Change AlarmManager to use ProfileKeyedAPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Got rid of kServiceIsNULLWhileTesting Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/extensions/extension_function_test_utils.h" 11 #include "chrome/browser/extensions/extension_function_test_utils.h"
12 #include "chrome/browser/extensions/test_extension_system.h"
13 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/extensions/background_info.h" 15 #include "chrome/common/extensions/background_info.h"
17 #include "chrome/common/extensions/extension_messages.h" 16 #include "chrome/common/extensions/extension_messages.h"
18 #include "chrome/test/base/browser_with_test_window_test.h" 17 #include "chrome/test/base/browser_with_test_window_test.h"
19 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
20 #include "content/public/test/mock_render_process_host.h" 19 #include "content/public/test/mock_render_process_host.h"
21 #include "ipc/ipc_test_sink.h" 20 #include "ipc/ipc_test_sink.h"
22 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 20 matching lines...) Expand all
43 std::vector<std::string> alarms_seen; 42 std::vector<std::string> alarms_seen;
44 }; 43 };
45 44
46 } // namespace 45 } // namespace
47 46
48 class ExtensionAlarmsTest : public BrowserWithTestWindowTest { 47 class ExtensionAlarmsTest : public BrowserWithTestWindowTest {
49 public: 48 public:
50 virtual void SetUp() { 49 virtual void SetUp() {
51 BrowserWithTestWindowTest::SetUp(); 50 BrowserWithTestWindowTest::SetUp();
52 51
53 TestExtensionSystem* system = static_cast<TestExtensionSystem*>( 52 alarm_manager_ = AlarmManager::Get(browser()->profile());
54 ExtensionSystem::Get(browser()->profile())); 53 alarm_manager_->SetClockForTesting(&test_clock_);
55 system->CreateAlarmManager(&test_clock_);
56 alarm_manager_ = system->alarm_manager();
57 54
58 alarm_delegate_ = new AlarmDelegate(); 55 alarm_delegate_ = new AlarmDelegate();
59 alarm_manager_->set_delegate(alarm_delegate_); 56 alarm_manager_->set_delegate(alarm_delegate_);
60 57
61 extension_ = utils::CreateEmptyExtensionWithLocation( 58 extension_ = utils::CreateEmptyExtensionWithLocation(
62 extensions::Manifest::UNPACKED); 59 extensions::Manifest::UNPACKED);
63 60
64 // Make sure there's a RenderViewHost for alarms to warn into. 61 // Make sure there's a RenderViewHost for alarms to warn into.
65 AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_)); 62 AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_));
66 contents_ = browser()->tab_strip_model()->GetActiveWebContents(); 63 contents_ = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); 509 EXPECT_TRUE(alarm_manager_->timer_.IsRunning());
513 MessageLoop::current()->Run(); 510 MessageLoop::current()->Run();
514 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); 511 EXPECT_FALSE(alarm_manager_->timer_.IsRunning());
515 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]"); 512 CreateAlarm("[\"bb\", {\"delayInMinutes\": 10}]");
516 EXPECT_TRUE(alarm_manager_->timer_.IsRunning()); 513 EXPECT_TRUE(alarm_manager_->timer_.IsRunning());
517 alarm_manager_->RemoveAllAlarms(extension_->id()); 514 alarm_manager_->RemoveAllAlarms(extension_->id());
518 EXPECT_FALSE(alarm_manager_->timer_.IsRunning()); 515 EXPECT_FALSE(alarm_manager_->timer_.IsRunning());
519 } 516 }
520 517
521 } // namespace extensions 518 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698