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 |