| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 private: | 112 private: |
| 113 GURL url_; | 113 GURL url_; |
| 114 | 114 |
| 115 // The ID of our parent application | 115 // The ID of our parent application |
| 116 base::string16 appid_; | 116 base::string16 appid_; |
| 117 | 117 |
| 118 // Parent profile | 118 // Parent profile |
| 119 Profile* profile_; | 119 Profile* profile_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 #if defined(ENABLE_NOTIFICATIONS) && !defined(TOOLKIT_GTK) | 122 #if defined(ENABLE_NOTIFICATIONS) |
| 123 // Wait for the notification created. | 123 // Wait for the notification created. |
| 124 class NotificationWaiter : public message_center::MessageCenterObserver { | 124 class NotificationWaiter : public message_center::MessageCenterObserver { |
| 125 public: | 125 public: |
| 126 explicit NotificationWaiter(const std::string& target_id) | 126 explicit NotificationWaiter(const std::string& target_id) |
| 127 : target_id_(target_id) {} | 127 : target_id_(target_id) {} |
| 128 virtual ~NotificationWaiter() {} | 128 virtual ~NotificationWaiter() {} |
| 129 | 129 |
| 130 void WaitForNotificationAdded() { | 130 void WaitForNotificationAdded() { |
| 131 DCHECK(!run_loop_.running()); | 131 DCHECK(!run_loop_.running()); |
| 132 message_center::MessageCenter* message_center = | 132 message_center::MessageCenter* message_center = |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 contents2->Navigate(url2); | 336 contents2->Navigate(url2); |
| 337 EXPECT_EQ(2U, GetPrefs(&profile)->size()); | 337 EXPECT_EQ(2U, GetPrefs(&profile)->size()); |
| 338 service.ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16("appid")); | 338 service.ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16("appid")); |
| 339 EXPECT_FALSE(service.IsTracked(contents)); | 339 EXPECT_FALSE(service.IsTracked(contents)); |
| 340 EXPECT_EQ(NULL, | 340 EXPECT_EQ(NULL, |
| 341 service.GetAppBackgroundContents(base::ASCIIToUTF16("appid"))); | 341 service.GetAppBackgroundContents(base::ASCIIToUTF16("appid"))); |
| 342 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 342 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
| 343 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); | 343 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); |
| 344 } | 344 } |
| 345 | 345 |
| 346 #if defined(ENABLE_NOTIFICATIONS) && !defined(TOOLKIT_GTK) | 346 #if defined(ENABLE_NOTIFICATIONS) |
| 347 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloon) { | 347 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloon) { |
| 348 scoped_refptr<extensions::Extension> extension = | 348 scoped_refptr<extensions::Extension> extension = |
| 349 extension_test_util::LoadManifest("image_loading_tracker", "app.json"); | 349 extension_test_util::LoadManifest("image_loading_tracker", "app.json"); |
| 350 ASSERT_TRUE(extension.get()); | 350 ASSERT_TRUE(extension.get()); |
| 351 ASSERT_TRUE(extension->GetManifestData("icons")); | 351 ASSERT_TRUE(extension->GetManifestData("icons")); |
| 352 | 352 |
| 353 const Notification* notification = CreateCrashNotification(extension); | 353 const Notification* notification = CreateCrashNotification(extension); |
| 354 EXPECT_FALSE(notification->icon().IsEmpty()); | 354 EXPECT_FALSE(notification->icon().IsEmpty()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 // 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 |
| 358 // a crash notification for an extension without icon. | 358 // a crash notification for an extension without icon. |
| 359 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) { | 359 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) { |
| 360 // Extension manifest file with no 'icon' field. | 360 // Extension manifest file with no 'icon' field. |
| 361 scoped_refptr<extensions::Extension> extension = | 361 scoped_refptr<extensions::Extension> extension = |
| 362 extension_test_util::LoadManifest("app", "manifest.json"); | 362 extension_test_util::LoadManifest("app", "manifest.json"); |
| 363 ASSERT_TRUE(extension.get()); | 363 ASSERT_TRUE(extension.get()); |
| 364 ASSERT_FALSE(extension->GetManifestData("icons")); | 364 ASSERT_FALSE(extension->GetManifestData("icons")); |
| 365 | 365 |
| 366 const Notification* notification = CreateCrashNotification(extension); | 366 const Notification* notification = CreateCrashNotification(extension); |
| 367 EXPECT_FALSE(notification->icon().IsEmpty()); | 367 EXPECT_FALSE(notification->icon().IsEmpty()); |
| 368 } | 368 } |
| 369 #endif | 369 #endif |
| OLD | NEW |