| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 class BackgroundContentsServiceNotificationTest | 156 class BackgroundContentsServiceNotificationTest |
| 157 : public BrowserWithTestWindowTest { | 157 : public BrowserWithTestWindowTest { |
| 158 public: | 158 public: |
| 159 BackgroundContentsServiceNotificationTest() {} | 159 BackgroundContentsServiceNotificationTest() {} |
| 160 virtual ~BackgroundContentsServiceNotificationTest() {} | 160 virtual ~BackgroundContentsServiceNotificationTest() {} |
| 161 | 161 |
| 162 // Overridden from testing::Test | 162 // Overridden from testing::Test |
| 163 virtual void SetUp() { | 163 virtual void SetUp() { |
| 164 BrowserWithTestWindowTest::SetUp(); | 164 BrowserWithTestWindowTest::SetUp(); |
| 165 if (!NotificationUIManager::DelegatesToMessageCenter()) | |
| 166 return; | |
| 167 | |
| 168 // In ChromeOS environment, BrowserWithTestWindowTest initializes | 165 // In ChromeOS environment, BrowserWithTestWindowTest initializes |
| 169 // MessageCenter. | 166 // MessageCenter. |
| 170 #if !defined(OS_CHROMEOS) | 167 #if !defined(OS_CHROMEOS) |
| 171 message_center::MessageCenter::Initialize(); | 168 message_center::MessageCenter::Initialize(); |
| 172 #endif | 169 #endif |
| 173 profile_manager_.reset(new TestingProfileManager( | 170 profile_manager_.reset(new TestingProfileManager( |
| 174 TestingBrowserProcess::GetGlobal())); | 171 TestingBrowserProcess::GetGlobal())); |
| 175 ASSERT_TRUE(profile_manager_->SetUp()); | 172 ASSERT_TRUE(profile_manager_->SetUp()); |
| 176 MessageCenterNotificationManager* manager = | 173 MessageCenterNotificationManager* manager = |
| 177 static_cast<MessageCenterNotificationManager*>( | 174 static_cast<MessageCenterNotificationManager*>( |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 service.ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16("appid")); | 338 service.ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16("appid")); |
| 342 EXPECT_FALSE(service.IsTracked(contents)); | 339 EXPECT_FALSE(service.IsTracked(contents)); |
| 343 EXPECT_EQ(NULL, | 340 EXPECT_EQ(NULL, |
| 344 service.GetAppBackgroundContents(base::ASCIIToUTF16("appid"))); | 341 service.GetAppBackgroundContents(base::ASCIIToUTF16("appid"))); |
| 345 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 342 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
| 346 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); | 343 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); |
| 347 } | 344 } |
| 348 | 345 |
| 349 #if defined(ENABLE_NOTIFICATIONS) && !defined(TOOLKIT_GTK) | 346 #if defined(ENABLE_NOTIFICATIONS) && !defined(TOOLKIT_GTK) |
| 350 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloon) { | 347 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloon) { |
| 351 if (!NotificationUIManager::DelegatesToMessageCenter()) | |
| 352 return; | |
| 353 | |
| 354 scoped_refptr<extensions::Extension> extension = | 348 scoped_refptr<extensions::Extension> extension = |
| 355 extension_test_util::LoadManifest("image_loading_tracker", "app.json"); | 349 extension_test_util::LoadManifest("image_loading_tracker", "app.json"); |
| 356 ASSERT_TRUE(extension.get()); | 350 ASSERT_TRUE(extension.get()); |
| 357 ASSERT_TRUE(extension->GetManifestData("icons")); | 351 ASSERT_TRUE(extension->GetManifestData("icons")); |
| 358 | 352 |
| 359 const Notification* notification = CreateCrashNotification(extension); | 353 const Notification* notification = CreateCrashNotification(extension); |
| 360 EXPECT_FALSE(notification->icon().IsEmpty()); | 354 EXPECT_FALSE(notification->icon().IsEmpty()); |
| 361 } | 355 } |
| 362 | 356 |
| 363 // Verify if a test notification can show the default extension icon for | 357 // Verify if a test notification can show the default extension icon for |
| 364 // a crash notification for an extension without icon. | 358 // a crash notification for an extension without icon. |
| 365 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) { | 359 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) { |
| 366 if (!NotificationUIManager::DelegatesToMessageCenter()) | |
| 367 return; | |
| 368 | |
| 369 // Extension manifest file with no 'icon' field. | 360 // Extension manifest file with no 'icon' field. |
| 370 scoped_refptr<extensions::Extension> extension = | 361 scoped_refptr<extensions::Extension> extension = |
| 371 extension_test_util::LoadManifest("app", "manifest.json"); | 362 extension_test_util::LoadManifest("app", "manifest.json"); |
| 372 ASSERT_TRUE(extension.get()); | 363 ASSERT_TRUE(extension.get()); |
| 373 ASSERT_FALSE(extension->GetManifestData("icons")); | 364 ASSERT_FALSE(extension->GetManifestData("icons")); |
| 374 | 365 |
| 375 const Notification* notification = CreateCrashNotification(extension); | 366 const Notification* notification = CreateCrashNotification(extension); |
| 376 EXPECT_FALSE(notification->icon().IsEmpty()); | 367 EXPECT_FALSE(notification->icon().IsEmpty()); |
| 377 } | 368 } |
| 378 #endif | 369 #endif |
| OLD | NEW |