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

Unified Diff: ui/message_center/views/message_popup_collection_unittest.cc

Issue 1645843003: Implement Non-Closable Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/views/message_popup_collection_unittest.cc
diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc
index e38bb4b05a5415cc5f3445ed3b915c1030db809b..57915c5875afd5c25af25a808440555382515fa7 100644
--- a/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -480,6 +480,45 @@ TEST_F(MessagePopupCollectionTest, ManyPopupNotifications) {
WaitForTransitionsDone();
}
+#if defined(OS_CHROMEOS)
+
+TEST_F(MessagePopupCollectionTest, CloseNonClosableNotifications) {
+ const char* kNotificationId = "NOTIFICATION1";
+
+ scoped_ptr<Notification> notification(new Notification(
+ NOTIFICATION_TYPE_BASE_FORMAT, kNotificationId,
+ base::UTF8ToUTF16("test title"),
+ base::UTF8ToUTF16("test message"), gfx::Image(),
+ base::string16() /* display_source */, GURL(),
+ NotifierId(NotifierId::APPLICATION, kNotificationId),
+ message_center::RichNotificationData(), new NotificationDelegate()));
+ notification->set_closable(false);
+
+ // Add a non-closable notification.
+ MessageCenter::Get()->AddNotification(std::move(notification));
+ WaitForTransitionsDone();
+
+ // Confirms that there is a toast.
+ EXPECT_EQ(1u, GetToastCounts());
+ EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
+
+ // Close the toast.
+ views::WidgetDelegateView* toast1 = GetToast(kNotificationId);
+ ASSERT_TRUE(toast1 != NULL);
+ ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
+ ui::EventTimeForNow(), 0, 0);
+ toast1->OnMouseEntered(event);
+ static_cast<MessageCenterObserver*>(collection())->OnNotificationRemoved(
+ kNotificationId, true);
+ WaitForTransitionsDone();
+
+ // Confirms that there is no toast.
+ EXPECT_EQ(0u, GetToastCounts());
+ // But the notification still exists.
+ EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
+}
+
+#endif // defined(OS_CHROMEOS)
} // namespace test
} // namespace message_center

Powered by Google App Engine
This is Rietveld 408576698