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

Unified Diff: ui/views/mus/native_widget_mus_unittest.cc

Issue 2013713002: Revert of Finish eliminating PlatformWindowMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/views/mus/native_widget_mus.cc ('k') | ui/views/mus/platform_window_mus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/native_widget_mus_unittest.cc
diff --git a/ui/views/mus/native_widget_mus_unittest.cc b/ui/views/mus/native_widget_mus_unittest.cc
index 17db5428720faa4ab30f988b80436297a0beb604..53f9338ed07a43a59f9bef8da44da03cd0c4e074 100644
--- a/ui/views/mus/native_widget_mus_unittest.cc
+++ b/ui/views/mus/native_widget_mus_unittest.cc
@@ -418,6 +418,58 @@
EXPECT_EQ(1, handler.num_mouse_events());
}
+// Tests that an incoming UI event is acked with the handled status.
+TEST_F(NativeWidgetMusTest, EventAcked) {
+ std::unique_ptr<Widget> widget(CreateWidget(nullptr));
+ widget->Show();
+
+ View* content = new HandleMousePressView;
+ content->SetBounds(10, 20, 90, 180);
+ widget->GetContentsView()->AddChildView(content);
+
+ // Dispatch an input event to the window and view.
+ std::unique_ptr<ui::MouseEvent> event = CreateMouseEvent();
+ std::unique_ptr<base::Callback<void(EventResult)>> ack_callback(
+ new base::Callback<void(EventResult)>(base::Bind(
+ &NativeWidgetMusTest::AckCallback, base::Unretained(this))));
+ OnWindowInputEvent(
+ static_cast<NativeWidgetMus*>(widget->native_widget_private()),
+ *event,
+ &ack_callback);
+
+ // The test took ownership of the callback and called it.
+ EXPECT_FALSE(ack_callback);
+ EXPECT_EQ(1, ack_callback_count());
+}
+
+// Tests that a window that is deleted during event handling properly acks the
+// event.
+TEST_F(NativeWidgetMusTest, EventAckedWithWindowDestruction) {
+ std::unique_ptr<Widget> widget(CreateWidget(nullptr));
+ widget->Show();
+
+ View* content = new DeleteWidgetView(&widget);
+ content->SetBounds(10, 20, 90, 180);
+ widget->GetContentsView()->AddChildView(content);
+
+ // Dispatch an input event to the window and view.
+ std::unique_ptr<ui::MouseEvent> event = CreateMouseEvent();
+ std::unique_ptr<base::Callback<void(EventResult)>> ack_callback(
+ new base::Callback<void(EventResult)>(base::Bind(
+ &NativeWidgetMusTest::AckCallback, base::Unretained(this))));
+ OnWindowInputEvent(
+ static_cast<NativeWidgetMus*>(widget->native_widget_private()),
+ *event,
+ &ack_callback);
+
+ // The widget was deleted.
+ EXPECT_FALSE(widget.get());
+
+ // The test took ownership of the callback and called it.
+ EXPECT_FALSE(ack_callback);
+ EXPECT_EQ(1, ack_callback_count());
+}
+
TEST_F(NativeWidgetMusTest, SetAndReleaseCapture) {
std::unique_ptr<Widget> widget(CreateWidget(nullptr));
widget->Show();
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | ui/views/mus/platform_window_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698