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

Unified Diff: ui/message_center/message_center_tray_unittest.cc

Issue 1334363002: [Eraser] First pass at removing the notification center panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: peter comments Created 5 years, 3 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: ui/message_center/message_center_tray_unittest.cc
diff --git a/ui/message_center/message_center_tray_unittest.cc b/ui/message_center/message_center_tray_unittest.cc
index 1562156695a486d5afcfd08c034e400f24943640..e12bd094c3fb7d91ce0380e61e06b1a11a22c124 100644
--- a/ui/message_center/message_center_tray_unittest.cc
+++ b/ui/message_center/message_center_tray_unittest.cc
@@ -69,11 +69,15 @@ class MessageCenterTrayTest : public testing::Test {
}
void AddNotification(const std::string& id) {
+ AddNotification(id, DummyNotifierId());
+ }
+
+ void AddNotification(const std::string& id, NotifierId notifier_id) {
scoped_ptr<Notification> notification(new Notification(
message_center::NOTIFICATION_TYPE_SIMPLE, id,
ASCIIToUTF16("Test Web Notification"),
ASCIIToUTF16("Notification message body."), gfx::Image(),
- ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(),
+ ASCIIToUTF16("www.test.org"), GURL(), notifier_id,
message_center::RichNotificationData(), NULL /* delegate */));
message_center_->AddNotification(notification.Pass());
}
@@ -100,12 +104,12 @@ TEST_F(MessageCenterTrayTest, BasicMessageCenter) {
ASSERT_FALSE(message_center_tray_->popups_visible());
ASSERT_FALSE(message_center_tray_->message_center_visible());
- message_center_tray_->ToggleMessageCenterBubble();
+ message_center_tray_->ShowMessageCenterBubble();
ASSERT_FALSE(message_center_tray_->popups_visible());
ASSERT_TRUE(message_center_tray_->message_center_visible());
- message_center_tray_->ToggleMessageCenterBubble();
+ message_center_tray_->HideMessageCenterBubble();
ASSERT_FALSE(message_center_tray_->popups_visible());
ASSERT_FALSE(message_center_tray_->message_center_visible());
@@ -221,7 +225,7 @@ TEST_F(MessageCenterTrayTest, ShowBubbleFails) {
ASSERT_FALSE(message_center_tray_->popups_visible());
ASSERT_FALSE(message_center_tray_->message_center_visible());
- message_center_tray_->ToggleMessageCenterBubble();
+ message_center_tray_->ShowMessageCenterBubble();
ASSERT_FALSE(message_center_tray_->popups_visible());
ASSERT_FALSE(message_center_tray_->message_center_visible());
@@ -232,7 +236,8 @@ TEST_F(MessageCenterTrayTest, ShowBubbleFails) {
ASSERT_FALSE(message_center_tray_->message_center_visible());
}
-TEST_F(MessageCenterTrayTest, ContextMenuTest) {
+#ifdef OS_CHROMEOS
+TEST_F(MessageCenterTrayTest, ContextMenuTestWithMessageCenter) {
const std::string id1 = "id1";
const std::string id2 = "id2";
const std::string id3 = "id3";
@@ -288,4 +293,80 @@ TEST_F(MessageCenterTrayTest, ContextMenuTest) {
EXPECT_FALSE(model->IsEnabledAt(0));
}
+#else
+TEST_F(MessageCenterTrayTest, ContextMenuTestPopupsOnly) {
+ const std::string id1 = "id1";
+ const std::string id2 = "id2";
+ const std::string id3 = "id3";
+
+ base::string16 display_source = ASCIIToUTF16("https://www.test.org");
+ NotifierId notifier_id(GURL("https://www.test.org"));
+
+ AddNotification(id1, notifier_id);
+
+ NotifierId notifier_id2(NotifierId::APPLICATION, "sample-app");
+ scoped_ptr<Notification> notification(new Notification(
+ message_center::NOTIFICATION_TYPE_SIMPLE, id2,
+ ASCIIToUTF16("Test Web Notification"),
+ ASCIIToUTF16("Notification message body."), gfx::Image(),
+ base::string16() /* empty display source */, GURL(), notifier_id2,
+ message_center::RichNotificationData(), NULL /* delegate */));
+ message_center_->AddNotification(notification.Pass());
+
+ AddNotification(id3, notifier_id);
+
+ // The dummy notifier is SYSTEM_COMPONENT so no context menu is visible.
+ scoped_ptr<ui::MenuModel> model(
+ message_center_tray_->CreateNotificationMenuModel(DummyNotifierId(),
+ display_source));
+ EXPECT_EQ(nullptr, model.get());
+
+ model = message_center_tray_->CreateNotificationMenuModel(notifier_id,
+ display_source);
+ EXPECT_EQ(1, model->GetItemCount());
+
+ // The first item is to disable notifications from the notifier id. It also
+ // removes all notifications from the same notifier, i.e. id1 and id3.
+ EXPECT_TRUE(model->IsEnabledAt(0));
+ model->ActivatedAt(0);
+
+ NotificationList::Notifications notifications =
+ message_center_->GetVisibleNotifications();
+ EXPECT_EQ(1u, notifications.size());
+ EXPECT_EQ(id2, (*notifications.begin())->id());
+
+ // Disables the context menu.
+ delegate_->enable_context_menu_ = false;
+
+ // id2 doesn't have the display source, so it don't have the menu item for
+ // disabling notifications.
+ EXPECT_EQ(nullptr, message_center_tray_->CreateNotificationMenuModel(
+ notifier_id2, base::string16()));
+}
+#endif
+
+TEST_F(MessageCenterTrayTest, DelegateDisabledContextMenu) {
+ const std::string id1 = "id1";
+ base::string16 display_source = ASCIIToUTF16("www.test.org");
+ AddNotification(id1);
+ NotifierId notifier_id(GURL("www.test.org"));
+
+ delegate_->enable_context_menu_ = false;
+ // id2 doesn't have the display source, so it don't have the menu item for
+ // disabling notifications.
+ scoped_ptr<ui::MenuModel> model(
+ message_center_tray_->CreateNotificationMenuModel(notifier_id,
+ display_source));
+
+// The commands are disabled because delegate disables context menu.
+#ifndef OS_CHROMEOS
+ EXPECT_EQ(1, model->GetItemCount());
+#else
+ EXPECT_EQ(2, model->GetItemCount());
+ EXPECT_FALSE(model->IsEnabledAt(1));
+#endif
+
+ EXPECT_FALSE(model->IsEnabledAt(0));
+}
+
} // namespace message_center
« no previous file with comments | « ui/message_center/message_center_tray.cc ('k') | ui/resources/default_100_percent/mac/notification_dark_tray_attention.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698