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

Side by Side Diff: chrome/browser/notifications/message_center_notifications_unittest.cc

Issue 2528013002: Initialize the message center as part of the testing browser process (Closed)
Patch Set: re-uploding due to time outs Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <memory> 5 #include <memory>
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 26 matching lines...) Expand all
37 37
38 namespace message_center { 38 namespace message_center {
39 39
40 class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest { 40 class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
41 public: 41 public:
42 MessageCenterNotificationManagerTest() {} 42 MessageCenterNotificationManagerTest() {}
43 43
44 protected: 44 protected:
45 void SetUp() override { 45 void SetUp() override {
46 BrowserWithTestWindowTest::SetUp(); 46 BrowserWithTestWindowTest::SetUp();
47 #if !defined(OS_CHROMEOS)
48 // BrowserWithTestWindowTest owns an AshTestHelper on OS_CHROMEOS, which
49 // in turn initializes the message center. On other platforms, we need to
50 // initialize it here.
51 MessageCenter::Initialize();
52 #endif
53
54 47
55 TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal(); 48 TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
56 profile_manager_.reset(new TestingProfileManager(browser_process)); 49 profile_manager_.reset(new TestingProfileManager(browser_process));
57 ASSERT_TRUE(profile_manager_->SetUp()); 50 ASSERT_TRUE(profile_manager_->SetUp());
58 51
59 message_center_ = MessageCenter::Get(); 52 message_center_ = MessageCenter::Get();
60 delegate_ = new FakeMessageCenterTrayDelegate(message_center_); 53 delegate_ = new FakeMessageCenterTrayDelegate(message_center_);
61 notification_manager()->SetMessageCenterTrayDelegateForTest(delegate_); 54 notification_manager()->SetMessageCenterTrayDelegateForTest(delegate_);
62 } 55 }
63 56
64 void TearDown() override { 57 void TearDown() override {
65 profile_manager_.reset(); 58 profile_manager_.reset();
66 59
67 #if !defined(OS_CHROMEOS)
68 // Shutdown the message center if we initialized it manually.
69 MessageCenter::Shutdown();
70 #endif
71
72 BrowserWithTestWindowTest::TearDown(); 60 BrowserWithTestWindowTest::TearDown();
73 } 61 }
74 62
75 MessageCenterNotificationManager* notification_manager() { 63 MessageCenterNotificationManager* notification_manager() {
76 return (MessageCenterNotificationManager*) 64 return (MessageCenterNotificationManager*)
77 g_browser_process->notification_ui_manager(); 65 g_browser_process->notification_ui_manager();
78 } 66 }
79 67
80 MessageCenter* message_center() { return message_center_; } 68 MessageCenter* message_center() { return message_center_; }
81 69
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 EXPECT_EQ(0u, message_center()->NotificationCount()); 119 EXPECT_EQ(0u, message_center()->NotificationCount());
132 notification_manager()->Add(GetANotification("test"), &profile); 120 notification_manager()->Add(GetANotification("test"), &profile);
133 EXPECT_EQ(1u, message_center()->NotificationCount()); 121 EXPECT_EQ(1u, message_center()->NotificationCount());
134 notification_manager()->Update(GetANotification("test"), &profile); 122 notification_manager()->Update(GetANotification("test"), &profile);
135 EXPECT_EQ(1u, message_center()->NotificationCount()); 123 EXPECT_EQ(1u, message_center()->NotificationCount());
136 chrome::MultiUserWindowManager::DeleteInstance(); 124 chrome::MultiUserWindowManager::DeleteInstance();
137 } 125 }
138 #endif 126 #endif
139 127
140 } // namespace message_center 128 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698