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

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: Remove unnecessary property. Created 4 years, 10 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 | « ui/message_center/views/message_popup_collection.cc ('k') | ui/message_center/views/message_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a41ae016cc2fcf9a8020d458bbeed604f34d9e0b 100644
--- a/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -118,7 +118,8 @@ class MessagePopupCollectionTest : public views::ViewsTestBase {
void CloseAllToasts() {
// Assumes there is at least one toast to close.
EXPECT_TRUE(GetToastCounts() > 0);
- MessageCenter::Get()->RemoveAllNotifications(false);
+ MessageCenter::Get()->RemoveAllNotifications(
+ false /* by_user */, MessageCenter::RemoveType::ALL);
}
gfx::Rect GetToastRectAt(size_t index) {
@@ -480,6 +481,44 @@ 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_pinned(true);
+
+ // Add a pinned 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
« no previous file with comments | « ui/message_center/views/message_popup_collection.cc ('k') | ui/message_center/views/message_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698