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

Unified Diff: ash/system/web_notification/web_notification_tray_unittest.cc

Issue 11684003: Make MessageCenter a singleton object and build on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update comment. Created 7 years, 12 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/web_notification/web_notification_tray_unittest.cc
diff --git a/ash/system/web_notification/web_notification_tray_unittest.cc b/ash/system/web_notification/web_notification_tray_unittest.cc
index 2a58c01d339e07e33e5cee0816b2ed2bd8f9dde6..19885398db9e112068d48e656f2c2a5888cb36ab 100644
--- a/ash/system/web_notification/web_notification_tray_unittest.cc
+++ b/ash/system/web_notification/web_notification_tray_unittest.cc
@@ -32,8 +32,14 @@ WebNotificationTray* GetWebNotificationTray() {
class TestDelegate : public message_center::MessageCenter::Delegate {
public:
- TestDelegate() {}
- virtual ~TestDelegate() {}
+ TestDelegate(message_center::MessageCenter* message_center)
+ : message_center_(message_center) {
+ message_center_->SetDelegate(this);
+ }
+ virtual ~TestDelegate() {
+ message_center_->SetDelegate(NULL);
+ message_center_->notification_list()->RemoveAllNotifications();
+ }
// WebNotificationTray::Delegate overrides.
virtual void NotificationRemoved(const std::string& notifcation_id) {
@@ -88,6 +94,7 @@ class TestDelegate : public message_center::MessageCenter::Delegate {
private:
std::set<std::string> notification_ids_;
+ message_center::MessageCenter* message_center_;
DISALLOW_COPY_AND_ASSIGN(TestDelegate);
};
@@ -98,9 +105,8 @@ typedef test::AshTestBase WebNotificationTrayTest;
TEST_F(WebNotificationTrayTest, WebNotifications) {
WebNotificationTray* tray = GetWebNotificationTray();
- scoped_ptr<TestDelegate> delegate(new TestDelegate);
message_center::MessageCenter* message_center = tray->message_center();
- message_center->SetDelegate(delegate.get());
+ scoped_ptr<TestDelegate> delegate(new TestDelegate(message_center));
ASSERT_TRUE(tray->GetWidget());
// Add a notification.
@@ -137,8 +143,7 @@ TEST_F(WebNotificationTrayTest, WebNotifications) {
TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) {
WebNotificationTray* tray = GetWebNotificationTray();
- scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->message_center()->SetDelegate(delegate.get());
+ scoped_ptr<TestDelegate> delegate(new TestDelegate(tray->message_center()));
ASSERT_TRUE(tray->GetWidget());
@@ -164,8 +169,7 @@ using message_center::NotificationList;
TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
WebNotificationTray* tray = GetWebNotificationTray();
- scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->message_center()->SetDelegate(delegate.get());
+ scoped_ptr<TestDelegate> delegate(new TestDelegate(tray->message_center()));
// Add the max visible notifications +1, ensure the correct visible number.
size_t notifications_to_add =
@@ -185,8 +189,7 @@ TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
TEST_F(WebNotificationTrayTest, ManyPopupNotifications) {
WebNotificationTray* tray = GetWebNotificationTray();
- scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->message_center()->SetDelegate(delegate.get());
+ scoped_ptr<TestDelegate> delegate(new TestDelegate(tray->message_center()));
// Add the max visible popup notifications +1, ensure the correct num visible.
size_t notifications_to_add =
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698