Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 = |
| 133 message_center::MessageCenter::Get(); | 133 message_center::MessageCenter::Get(); |
| 134 if (message_center->HasNotification(target_id_)) | |
| 135 return; | |
| 136 | 134 |
| 137 message_center->AddObserver(this); | 135 message_center->AddObserver(this); |
| 138 run_loop_.Run(); | 136 run_loop_.Run(); |
| 139 message_center->RemoveObserver(this); | 137 message_center->RemoveObserver(this); |
| 140 } | 138 } |
| 141 | 139 |
| 142 private: | 140 private: |
| 143 // message_center::MessageCenterObserver overrides: | 141 // message_center::MessageCenterObserver overrides: |
| 144 virtual void OnNotificationAdded( | 142 virtual void OnNotificationAdded( |
| 145 const std::string& notification_id) OVERRIDE { | 143 const std::string& notification_id) OVERRIDE { |
| 146 if (notification_id == target_id_) | 144 if (notification_id == target_id_) |
| 147 run_loop_.Quit(); | 145 run_loop_.Quit(); |
| 148 } | 146 } |
| 147 virtual void OnNotificationUpdated( | |
|
Andrew T Wilson (Slow)
2014/05/19 14:02:27
blank line above this
dewittj
2014/05/20 18:18:22
Done.
| |
| 148 const std::string& notification_id) OVERRIDE { | |
| 149 if (notification_id == target_id_) | |
| 150 run_loop_.Quit(); | |
| 151 } | |
| 149 | 152 |
| 150 std::string target_id_; | 153 std::string target_id_; |
| 151 base::RunLoop run_loop_; | 154 base::RunLoop run_loop_; |
| 152 | 155 |
| 153 DISALLOW_COPY_AND_ASSIGN(NotificationWaiter); | 156 DISALLOW_COPY_AND_ASSIGN(NotificationWaiter); |
| 154 }; | 157 }; |
| 155 | 158 |
| 156 class BackgroundContentsServiceNotificationTest | 159 class BackgroundContentsServiceNotificationTest |
| 157 : public BrowserWithTestWindowTest { | 160 : public BrowserWithTestWindowTest { |
| 158 public: | 161 public: |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) { | 362 TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) { |
| 360 // Extension manifest file with no 'icon' field. | 363 // Extension manifest file with no 'icon' field. |
| 361 scoped_refptr<extensions::Extension> extension = | 364 scoped_refptr<extensions::Extension> extension = |
| 362 extension_test_util::LoadManifest("app", "manifest.json"); | 365 extension_test_util::LoadManifest("app", "manifest.json"); |
| 363 ASSERT_TRUE(extension.get()); | 366 ASSERT_TRUE(extension.get()); |
| 364 ASSERT_FALSE(extension->GetManifestData("icons")); | 367 ASSERT_FALSE(extension->GetManifestData("icons")); |
| 365 | 368 |
| 366 const Notification* notification = CreateCrashNotification(extension); | 369 const Notification* notification = CreateCrashNotification(extension); |
| 367 EXPECT_FALSE(notification->icon().IsEmpty()); | 370 EXPECT_FALSE(notification->icon().IsEmpty()); |
| 368 } | 371 } |
| 372 | |
| 373 TEST_F(BackgroundContentsServiceNotificationTest, TestShowTwoBalloons) { | |
| 374 TestingProfile profile; | |
| 375 scoped_refptr<extensions::Extension> extension = | |
| 376 extension_test_util::LoadManifest("app", "manifest.json"); | |
| 377 ASSERT_TRUE(extension.get()); | |
| 378 CreateCrashNotification(extension); | |
| 379 CreateCrashNotification(extension); | |
|
Andrew T Wilson (Slow)
2014/05/19 14:02:27
Do we need to check that there's only one extensio
dewittj
2014/05/20 18:18:22
Done.
| |
| 380 } | |
| 369 #endif | 381 #endif |
| OLD | NEW |