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

Side by Side Diff: chrome/browser/background/background_contents_service_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
« no previous file with comments | « ash/test/test_suite.cc ('k') | chrome/browser/background/background_mode_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/background/background_contents_service.h" 5 #include "chrome/browser/background/background_contents_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 class BackgroundContentsServiceNotificationTest 174 class BackgroundContentsServiceNotificationTest
175 : public BrowserWithTestWindowTest { 175 : public BrowserWithTestWindowTest {
176 public: 176 public:
177 BackgroundContentsServiceNotificationTest() {} 177 BackgroundContentsServiceNotificationTest() {}
178 ~BackgroundContentsServiceNotificationTest() override {} 178 ~BackgroundContentsServiceNotificationTest() override {}
179 179
180 // Overridden from testing::Test 180 // Overridden from testing::Test
181 void SetUp() override { 181 void SetUp() override {
182 BrowserWithTestWindowTest::SetUp(); 182 BrowserWithTestWindowTest::SetUp();
183 // In ChromeOS environment, BrowserWithTestWindowTest initializes
184 // MessageCenter.
185 #if !defined(OS_CHROMEOS)
186 message_center::MessageCenter::Initialize();
187 #endif
188 profile_manager_.reset(new TestingProfileManager( 183 profile_manager_.reset(new TestingProfileManager(
189 TestingBrowserProcess::GetGlobal())); 184 TestingBrowserProcess::GetGlobal()));
190 ASSERT_TRUE(profile_manager_->SetUp()); 185 ASSERT_TRUE(profile_manager_->SetUp());
191 MessageCenterNotificationManager* manager = 186 MessageCenterNotificationManager* manager =
192 static_cast<MessageCenterNotificationManager*>( 187 static_cast<MessageCenterNotificationManager*>(
193 g_browser_process->notification_ui_manager()); 188 g_browser_process->notification_ui_manager());
194 manager->SetMessageCenterTrayDelegateForTest( 189 manager->SetMessageCenterTrayDelegateForTest(
195 new message_center::FakeMessageCenterTrayDelegate( 190 new message_center::FakeMessageCenterTrayDelegate(
196 message_center::MessageCenter::Get())); 191 message_center::MessageCenter::Get()));
197 } 192 }
198 193
199 void TearDown() override { 194 void TearDown() override {
200 g_browser_process->notification_ui_manager()->CancelAll(); 195 g_browser_process->notification_ui_manager()->CancelAll();
201 profile_manager_.reset(); 196 profile_manager_.reset();
202 #if !defined(OS_CHROMEOS)
203 message_center::MessageCenter::Shutdown();
204 #endif
205 BrowserWithTestWindowTest::TearDown(); 197 BrowserWithTestWindowTest::TearDown();
206 } 198 }
207 199
208 protected: 200 protected:
209 // Creates crash notification for the specified extension and returns 201 // Creates crash notification for the specified extension and returns
210 // the created one. 202 // the created one.
211 const Notification* CreateCrashNotification( 203 const Notification* CreateCrashNotification(
212 scoped_refptr<extensions::Extension> extension) { 204 scoped_refptr<extensions::Extension> extension) {
213 std::string notification_id = BackgroundContentsService:: 205 std::string notification_id = BackgroundContentsService::
214 GetNotificationDelegateIdForExtensionForTesting(extension->id()); 206 GetNotificationDelegateIdForExtensionForTesting(extension->id());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 CreateCrashNotification(extension); 406 CreateCrashNotification(extension);
415 CreateCrashNotification(extension); 407 CreateCrashNotification(extension);
416 408
417 message_center::MessageCenter* message_center = 409 message_center::MessageCenter* message_center =
418 message_center::MessageCenter::Get(); 410 message_center::MessageCenter::Get();
419 message_center::NotificationList::Notifications notifications = 411 message_center::NotificationList::Notifications notifications =
420 message_center->GetVisibleNotifications(); 412 message_center->GetVisibleNotifications();
421 ASSERT_EQ(1u, notifications.size()); 413 ASSERT_EQ(1u, notifications.size());
422 } 414 }
423 #endif 415 #endif
OLDNEW
« no previous file with comments | « ash/test/test_suite.cc ('k') | chrome/browser/background/background_mode_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698