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

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

Issue 23764003: Make toasts notice when they're hidden and send the mouse-out event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a test. Created 7 years, 4 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') | no next file » | 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 f43199755efda3c338d1dcb04d6f4755ff0fe2f1..d2b897d0fddde348bdc2aaeae1f2990ac83f6e67 100644
--- a/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -10,12 +10,15 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/events/event.h"
+#include "ui/base/events/event_constants.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
#include "ui/message_center/fake_message_center.h"
#include "ui/message_center/views/toast_contents_view.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
namespace message_center {
namespace test {
@@ -51,6 +54,10 @@ class MessagePopupCollectionTest : public views::ViewsTestBase {
return collection_->toasts_.size();
}
+ bool MouseInCollection() {
+ return collection_->latest_toast_entered_ != NULL;
+ }
+
bool IsToastShown(const std::string& id) {
views::Widget* widget = collection_->GetWidgetForTest(id);
return widget && widget->IsVisible();
@@ -335,6 +342,39 @@ TEST_F(MessagePopupCollectionTest, LeftPositioningWithLeftTaskbar) {
gfx::Rect(0, 0, 600, 400)); // Display-bounds.
}
+TEST_F(MessagePopupCollectionTest, DetectMouseHover) {
+ std::string id0 = AddNotification();
+ std::string id1 = AddNotification();
+ WaitForTransitionsDone();
+
+ views::WidgetDelegateView* toast0 = GetToast(id0);
+ EXPECT_TRUE(toast0 != NULL);
+ views::WidgetDelegateView* toast1 = GetToast(id1);
+ EXPECT_TRUE(toast1 != NULL);
+
+ ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 0);
+
+ // Test that mouse detection logic works in presence of out-of-order events.
+ toast0->OnMouseEntered(event);
+ EXPECT_TRUE(MouseInCollection());
+ toast1->OnMouseEntered(event);
+ EXPECT_TRUE(MouseInCollection());
+ toast0->OnMouseExited(event);
+ EXPECT_TRUE(MouseInCollection());
+ toast1->OnMouseExited(event);
+ EXPECT_FALSE(MouseInCollection());
+
+ // Test that mouse detection logic works in presence of WindowClosing events.
+ toast0->OnMouseEntered(event);
+ EXPECT_TRUE(MouseInCollection());
+ toast1->OnMouseEntered(event);
+ EXPECT_TRUE(MouseInCollection());
+ toast0->WindowClosing();
+ EXPECT_TRUE(MouseInCollection());
+ toast1->WindowClosing();
+ EXPECT_FALSE(MouseInCollection());
+}
+
// TODO(dimich): Test repositioning - both normal one and when user is closing
// the toasts.
« no previous file with comments | « ui/message_center/views/message_popup_collection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698