summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/message_center/views/message_popup_collection.cc19
-rw-r--r--ui/message_center/views/message_popup_collection_unittest.cc23
2 files changed, 35 insertions, 7 deletions
diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc
index b82460d..5355ad6 100644
--- a/ui/message_center/views/message_popup_collection.cc
+++ b/ui/message_center/views/message_popup_collection.cc
@@ -363,9 +363,7 @@ void MessagePopupCollection::OnNotificationRemoved(
return;
target_top_edge_ = (*iter)->bounds().y();
- (*iter)->CloseWithAnimation(true);
- if (by_user) {
- RepositionWidgetsWithTarget();
+ if (by_user && !user_is_closing_toasts_by_clicking_) {
// [Re] start a timeout after which the toasts re-position to their
// normal locations after tracking the mouse pointer for easy deletion.
// This provides a period of time when toasts are easy to remove because
@@ -373,11 +371,18 @@ void MessagePopupCollection::OnNotificationRemoved(
// pointer. If the user continue to remove the toasts, the delay is reset.
// Once user stopped removing the toasts, the toasts re-populate/rearrange
// after the specified delay.
- if (!user_is_closing_toasts_by_clicking_) {
- user_is_closing_toasts_by_clicking_ = true;
- IncrementDeferCounter();
- }
+ user_is_closing_toasts_by_clicking_ = true;
+ IncrementDeferCounter();
}
+
+ // CloseWithAnimation ultimately causes a call to RemoveToast, which calls
+ // OnMouseExited. This means that |user_is_closing_toasts_by_clicking_| must
+ // have been set before this call, otherwise it will remain true even after
+ // the toast is closed, since the defer timer won't be started.
+ (*iter)->CloseWithAnimation(true);
+
+ if (by_user)
+ RepositionWidgetsWithTarget();
}
void MessagePopupCollection::OnDeferTimerExpired() {
diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc
index a46a5b6..cca2774 100644
--- a/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -377,6 +377,29 @@ TEST_F(MessagePopupCollectionTest, DetectMouseHover) {
// TODO(dimich): Test repositioning - both normal one and when user is closing
// the toasts.
+TEST_F(MessagePopupCollectionTest, DetectMouseHoverWithUserClose) {
+ std::string id0 = AddNotification();
+ std::string id1 = AddNotification();
+ WaitForTransitionsDone();
+
+ views::WidgetDelegateView* toast0 = GetToast(id0);
+ EXPECT_TRUE(toast0 != NULL);
+ views::WidgetDelegateView* toast1 = GetToast(id1);
+ ASSERT_TRUE(toast1 != NULL);
+
+ ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 0);
+ toast1->OnMouseEntered(event);
+ static_cast<MessageCenterObserver*>(collection())->OnNotificationRemoved(
+ id1, true);
+
+ EXPECT_FALSE(MouseInCollection());
+ std::string id2 = AddNotification();
+
+ WaitForTransitionsDone();
+ views::WidgetDelegateView* toast2 = GetToast(id2);
+ EXPECT_TRUE(toast2 != NULL);
+}
+
} // namespace test
} // namespace message_center