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

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

Issue 11189099: Re-factor Ash Message Center code part 4/4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 2 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
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 4867ca066ce96233ab7f67359c9624c7e2e57839..9b7044a8cde58c0b3ec4982a77302d6f5c93f9e4 100644
--- a/ash/system/web_notification/web_notification_tray_unittest.cc
+++ b/ash/system/web_notification/web_notification_tray_unittest.cc
@@ -29,7 +29,7 @@ WebNotificationTray* GetWebNotificationTray() {
web_notification_tray();
}
-class TestDelegate : public WebNotificationTray::Delegate {
+class TestDelegate : public message_center::MessageCenter::Delegate {
public:
TestDelegate() {}
virtual ~TestDelegate() {}
@@ -54,11 +54,12 @@ class TestDelegate : public WebNotificationTray::Delegate {
void AddNotification(WebNotificationTray* tray, const std::string& id) {
notification_ids_.insert(id);
- tray->AddNotification(id,
- ASCIIToUTF16("Test Web Notification"),
- ASCIIToUTF16("Notification message body."),
- ASCIIToUTF16("www.test.org"),
- "" /* extension id */);
+ tray->message_center()->AddNotification(
+ id,
+ ASCIIToUTF16("Test Web Notification"),
+ ASCIIToUTF16("Notification message body."),
+ ASCIIToUTF16("www.test.org"),
+ "" /* extension id */);
}
void UpdateNotification(WebNotificationTray* tray,
@@ -66,13 +67,14 @@ class TestDelegate : public WebNotificationTray::Delegate {
const std::string& new_id) {
notification_ids_.erase(old_id);
notification_ids_.insert(new_id);
- tray->UpdateNotification(old_id, new_id,
- ASCIIToUTF16("Updated Web Notification"),
- ASCIIToUTF16("Updated message body."));
+ tray->message_center()->UpdateNotification(
+ old_id, new_id,
+ ASCIIToUTF16("Updated Web Notification"),
+ ASCIIToUTF16("Updated message body."));
}
void RemoveNotification(WebNotificationTray* tray, const std::string& id) {
- tray->RemoveNotification(id);
+ tray->message_center()->RemoveNotification(id);
notification_ids_.erase(id);
}
@@ -93,43 +95,46 @@ typedef test::AshTestBase WebNotificationTrayTest;
TEST_F(WebNotificationTrayTest, WebNotifications) {
WebNotificationTray* tray = GetWebNotificationTray();
scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->SetDelegate(delegate.get());
-
+ message_center::MessageCenter* message_center = tray->message_center();
+ message_center->SetDelegate(delegate.get());
ASSERT_TRUE(tray->GetWidget());
// Add a notification.
delegate->AddNotification(tray, "test_id1");
- EXPECT_EQ(1u, tray->notification_list()->notifications().size());
- EXPECT_TRUE(tray->notification_list()->HasNotification("test_id1"));
+ EXPECT_EQ(1u, tray->message_center()->NotificationCount());
+ EXPECT_TRUE(message_center->notification_list()->HasNotification("test_id1"));
delegate->AddNotification(tray, "test_id2");
delegate->AddNotification(tray, "test_id2");
- EXPECT_EQ(2u, tray->notification_list()->notifications().size());
- EXPECT_TRUE(tray->notification_list()->HasNotification("test_id2"));
+ EXPECT_EQ(2u, tray->message_center()->NotificationCount());
+ EXPECT_TRUE(message_center->notification_list()->HasNotification("test_id2"));
// Ensure that updating a notification does not affect the count.
delegate->UpdateNotification(tray, "test_id2", "test_id3");
delegate->UpdateNotification(tray, "test_id3", "test_id3");
- EXPECT_EQ(2u, tray->notification_list()->notifications().size());
+ EXPECT_EQ(2u, tray->message_center()->NotificationCount());
EXPECT_FALSE(delegate->HasNotificationId("test_id2"));
- EXPECT_FALSE(tray->notification_list()->HasNotification("test_id2"));
+ EXPECT_FALSE(message_center->notification_list()->HasNotification(
+ "test_id2"));
EXPECT_TRUE(delegate->HasNotificationId("test_id3"));
// Ensure that Removing the first notification removes it from the tray.
delegate->RemoveNotification(tray, "test_id1");
EXPECT_FALSE(delegate->HasNotificationId("test_id1"));
- EXPECT_FALSE(tray->notification_list()->HasNotification("test_id1"));
- EXPECT_EQ(1u, tray->notification_list()->notifications().size());
+ EXPECT_FALSE(message_center->notification_list()->HasNotification(
+ "test_id1"));
+ EXPECT_EQ(1u, tray->message_center()->NotificationCount());
// Remove the remianing notification.
delegate->RemoveNotification(tray, "test_id3");
- EXPECT_EQ(0u, tray->notification_list()->notifications().size());
- EXPECT_FALSE(tray->notification_list()->HasNotification("test_id3"));
+ EXPECT_EQ(0u, tray->message_center()->NotificationCount());
+ EXPECT_FALSE(message_center->notification_list()->HasNotification(
+ "test_id3"));
}
TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) {
WebNotificationTray* tray = GetWebNotificationTray();
scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->SetDelegate(delegate.get());
+ tray->message_center()->SetDelegate(delegate.get());
ASSERT_TRUE(tray->GetWidget());
@@ -156,7 +161,7 @@ using message_center::WebNotificationList;
TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
WebNotificationTray* tray = GetWebNotificationTray();
scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->SetDelegate(delegate.get());
+ tray->message_center()->SetDelegate(delegate.get());
// Add the max visible notifications +1, ensure the correct visible number.
size_t notifications_to_add =
@@ -169,7 +174,7 @@ TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
RunAllPendingInMessageLoop();
EXPECT_TRUE(tray->message_center_bubble() != NULL);
EXPECT_EQ(notifications_to_add,
- tray->notification_list()->notifications().size());
+ tray->message_center()->NotificationCount());
EXPECT_EQ(WebNotificationList::kMaxVisibleMessageCenterNotifications,
tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest());
}
@@ -177,7 +182,7 @@ TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
TEST_F(WebNotificationTrayTest, ManyPopupNotifications) {
WebNotificationTray* tray = GetWebNotificationTray();
scoped_ptr<TestDelegate> delegate(new TestDelegate);
- tray->SetDelegate(delegate.get());
+ tray->message_center()->SetDelegate(delegate.get());
// Add the max visible popup notifications +1, ensure the correct num visible.
size_t notifications_to_add =
@@ -191,7 +196,7 @@ TEST_F(WebNotificationTrayTest, ManyPopupNotifications) {
tray->ShowPopupBubble();
EXPECT_TRUE(tray->popup_bubble() != NULL);
EXPECT_EQ(notifications_to_add,
- tray->notification_list()->notifications().size());
+ tray->message_center()->NotificationCount());
EXPECT_EQ(WebNotificationList::kMaxVisiblePopupNotifications,
tray->GetPopupBubbleForTest()->NumMessageViewsForTest());
}
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | chrome/browser/ui/views/ash/balloon_collection_impl_ash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698