| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/notifications/message_center_notification_manager.h" | 34 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 35 #include "chrome/browser/notifications/notification.h" | 35 #include "chrome/browser/notifications/notification.h" |
| 36 #include "ui/message_center/fake_message_center_tray_delegate.h" | 36 #include "ui/message_center/fake_message_center_tray_delegate.h" |
| 37 #include "ui/message_center/message_center.h" | 37 #include "ui/message_center/message_center.h" |
| 38 #include "ui/message_center/message_center_observer.h" | 38 #include "ui/message_center/message_center_observer.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 class BackgroundContentsServiceTest : public testing::Test { | 41 class BackgroundContentsServiceTest : public testing::Test { |
| 42 public: | 42 public: |
| 43 BackgroundContentsServiceTest() {} | 43 BackgroundContentsServiceTest() {} |
| 44 virtual ~BackgroundContentsServiceTest() {} | 44 ~BackgroundContentsServiceTest() override {} |
| 45 virtual void SetUp() { | 45 void SetUp() override { |
| 46 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 46 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 const base::DictionaryValue* GetPrefs(Profile* profile) { | 49 const base::DictionaryValue* GetPrefs(Profile* profile) { |
| 50 return profile->GetPrefs()->GetDictionary( | 50 return profile->GetPrefs()->GetDictionary( |
| 51 prefs::kRegisteredBackgroundContents); | 51 prefs::kRegisteredBackgroundContents); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Returns the stored pref URL for the passed app id. | 54 // Returns the stored pref URL for the passed app id. |
| 55 std::string GetPrefURLForApp(Profile* profile, const base::string16& appid) { | 55 std::string GetPrefURLForApp(Profile* profile, const base::string16& appid) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 Profile* profile_; | 161 Profile* profile_; |
| 162 base::RunLoop run_loop_; | 162 base::RunLoop run_loop_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(NotificationWaiter); | 164 DISALLOW_COPY_AND_ASSIGN(NotificationWaiter); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 class BackgroundContentsServiceNotificationTest | 167 class BackgroundContentsServiceNotificationTest |
| 168 : public BrowserWithTestWindowTest { | 168 : public BrowserWithTestWindowTest { |
| 169 public: | 169 public: |
| 170 BackgroundContentsServiceNotificationTest() {} | 170 BackgroundContentsServiceNotificationTest() {} |
| 171 virtual ~BackgroundContentsServiceNotificationTest() {} | 171 ~BackgroundContentsServiceNotificationTest() override {} |
| 172 | 172 |
| 173 // Overridden from testing::Test | 173 // Overridden from testing::Test |
| 174 virtual void SetUp() { | 174 void SetUp() override { |
| 175 BrowserWithTestWindowTest::SetUp(); | 175 BrowserWithTestWindowTest::SetUp(); |
| 176 // In ChromeOS environment, BrowserWithTestWindowTest initializes | 176 // In ChromeOS environment, BrowserWithTestWindowTest initializes |
| 177 // MessageCenter. | 177 // MessageCenter. |
| 178 #if !defined(OS_CHROMEOS) | 178 #if !defined(OS_CHROMEOS) |
| 179 message_center::MessageCenter::Initialize(); | 179 message_center::MessageCenter::Initialize(); |
| 180 #endif | 180 #endif |
| 181 profile_manager_.reset(new TestingProfileManager( | 181 profile_manager_.reset(new TestingProfileManager( |
| 182 TestingBrowserProcess::GetGlobal())); | 182 TestingBrowserProcess::GetGlobal())); |
| 183 ASSERT_TRUE(profile_manager_->SetUp()); | 183 ASSERT_TRUE(profile_manager_->SetUp()); |
| 184 MessageCenterNotificationManager* manager = | 184 MessageCenterNotificationManager* manager = |
| 185 static_cast<MessageCenterNotificationManager*>( | 185 static_cast<MessageCenterNotificationManager*>( |
| 186 g_browser_process->notification_ui_manager()); | 186 g_browser_process->notification_ui_manager()); |
| 187 manager->SetMessageCenterTrayDelegateForTest( | 187 manager->SetMessageCenterTrayDelegateForTest( |
| 188 new message_center::FakeMessageCenterTrayDelegate( | 188 new message_center::FakeMessageCenterTrayDelegate( |
| 189 message_center::MessageCenter::Get(), base::Closure())); | 189 message_center::MessageCenter::Get(), base::Closure())); |
| 190 } | 190 } |
| 191 | 191 |
| 192 virtual void TearDown() { | 192 void TearDown() override { |
| 193 g_browser_process->notification_ui_manager()->CancelAll(); | 193 g_browser_process->notification_ui_manager()->CancelAll(); |
| 194 profile_manager_.reset(); | 194 profile_manager_.reset(); |
| 195 #if !defined(OS_CHROMEOS) | 195 #if !defined(OS_CHROMEOS) |
| 196 message_center::MessageCenter::Shutdown(); | 196 message_center::MessageCenter::Shutdown(); |
| 197 #endif | 197 #endif |
| 198 BrowserWithTestWindowTest::TearDown(); | 198 BrowserWithTestWindowTest::TearDown(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 protected: | 201 protected: |
| 202 // Creates crash notification for the specified extension and returns | 202 // Creates crash notification for the specified extension and returns |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 CreateCrashNotification(extension); | 385 CreateCrashNotification(extension); |
| 386 CreateCrashNotification(extension); | 386 CreateCrashNotification(extension); |
| 387 | 387 |
| 388 message_center::MessageCenter* message_center = | 388 message_center::MessageCenter* message_center = |
| 389 message_center::MessageCenter::Get(); | 389 message_center::MessageCenter::Get(); |
| 390 message_center::NotificationList::Notifications notifications = | 390 message_center::NotificationList::Notifications notifications = |
| 391 message_center->GetVisibleNotifications(); | 391 message_center->GetVisibleNotifications(); |
| 392 ASSERT_EQ(1u, notifications.size()); | 392 ASSERT_EQ(1u, notifications.size()); |
| 393 } | 393 } |
| 394 #endif | 394 #endif |
| OLD | NEW |