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

Unified Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 344793013: Dispatch a synthetic mouse exit to the widget handling mouse events when a widget grabs capture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« ui/aura/window_event_dispatcher.cc ('K') | « ui/aura/window_tree_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget_interactive_uitest.cc
diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc
index 45026a9eb1e79064bc024dcb5279e2ab30850b83..4e4a64ba19a44a9d98359a70925a35d94777294c 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -866,7 +866,6 @@ class WidgetCaptureTest : public ViewsTestBase {
EXPECT_FALSE(widget2.GetAndClearGotCaptureLost());
}
- private:
NativeWidget* CreateNativeWidget(bool create_desktop_native_widget,
Widget* widget) {
#if !defined(OS_CHROMEOS)
@@ -876,6 +875,7 @@ class WidgetCaptureTest : public ViewsTestBase {
return NULL;
}
+ private:
DISALLOW_COPY_AND_ASSIGN(WidgetCaptureTest);
};
@@ -892,6 +892,47 @@ TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) {
#endif
#if !defined(OS_CHROMEOS)
+// Test that a synthetic mouse exit is sent to the widget which was handling
+// mouse events when a different widget grabs capture.
+// TODO(pkotwicz): Make test pass on CrOS.
sadrul 2014/06/26 12:59:35 I guess you need to create multiple WindowTreeHost
+TEST_F(WidgetCaptureTest, MouseExitOnCaptureGrab) {
+ Widget widget1;
+ Widget::InitParams params1 =
+ CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params1.native_widget = CreateNativeWidget(true, &widget1);
+ params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget1.Init(params1);
+ MouseView* mouse_view1 = new MouseView;
+ widget1.SetContentsView(mouse_view1);
+ widget1.Show();
+ widget1.SetBounds(gfx::Rect(300, 300));
+
+ Widget widget2;
+ Widget::InitParams params2 =
+ CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params2.native_widget = CreateNativeWidget(true, &widget2);
+ params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget2.Init(params2);
+ widget2.Show();
+ widget2.SetBounds(gfx::Rect(400, 0, 300, 300));
+
+ ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(100, 100),
+ gfx::Point(100, 100), ui::EF_NONE, ui::EF_NONE);
+ ui::EventDispatchDetails details = widget1.GetNativeWindow()->GetHost()->
+ event_processor()->OnEventFromSource(&mouse_move_event);
+ ASSERT_FALSE(details.dispatcher_destroyed);
+ EXPECT_EQ(1, mouse_view1->EnteredCalls());
+ EXPECT_EQ(0, mouse_view1->ExitedCalls());
+
+ widget2.SetCapture(NULL);
+ EXPECT_EQ(0, mouse_view1->EnteredCalls());
+ // Grabbing native capture on Windows generates a ui::ET_MOUSE_EXITED event
+ // in addition to the one generated by Chrome.
+ EXPECT_LT(0, mouse_view1->ExitedCalls());
+}
+#endif
+
+#if !defined(OS_CHROMEOS)
namespace {
// Used to veirfy OnMouseEvent() has been invoked.
« ui/aura/window_event_dispatcher.cc ('K') | « ui/aura/window_tree_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698