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

Unified Diff: ui/ozone/platform/wayland/wayland_window_unittest.cc

Issue 1712103002: ozone/platform/wayland: Implement pointer handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move declaration of WaylandWindow::FromSurface to top of class 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
Index: ui/ozone/platform/wayland/wayland_window_unittest.cc
diff --git a/ui/ozone/platform/wayland/wayland_window_unittest.cc b/ui/ozone/platform/wayland/wayland_window_unittest.cc
index 4a1364ff0ebcc3ccc15274980dffc9ac731e8c86..916cee1842eb95b742894f32072e286fb0a8f35b 100644
--- a/ui/ozone/platform/wayland/wayland_window_unittest.cc
+++ b/ui/ozone/platform/wayland/wayland_window_unittest.cc
@@ -8,6 +8,7 @@
#include "base/strings/utf_string_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/events/event.h"
#include "ui/ozone/platform/wayland/fake_server.h"
#include "ui/ozone/platform/wayland/mock_platform_window_delegate.h"
#include "ui/ozone/platform/wayland/wayland_display.h"
@@ -109,6 +110,48 @@ TEST_F(WaylandWindowTest, Restore) {
window.Restore();
}
+namespace {
+MouseEvent test_mouse_event(ET_MOUSE_PRESSED,
+ gfx::Point(10, 15),
+ gfx::Point(10, 15),
+ base::TimeDelta::FromSeconds(123456),
+ EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON,
+ EF_LEFT_MOUSE_BUTTON);
spang 2016/02/24 16:42:21 It should go on the class.
Michael Forney 2016/02/24 19:32:21 Done.
+} // namespace
+
+TEST_F(WaylandWindowTest, CanDispatchMouseEventDefault) {
+ EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event));
+}
+
+TEST_F(WaylandWindowTest, CanDispatchMouseEventFocus) {
+ window.set_pointer_focus(true);
+ EXPECT_TRUE(window.CanDispatchEvent(&test_mouse_event));
+}
+
+TEST_F(WaylandWindowTest, CanDispatchMouseEventUnfocus) {
+ window.set_pointer_focus(false);
+ EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event));
+}
+
+ACTION_P(CloneEvent, ptr) {
+ *ptr = Event::Clone(*arg0);
+}
+
+TEST_F(WaylandWindowTest, DispatchEvent) {
+ scoped_ptr<Event> event;
+ EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ window.DispatchEvent(&test_mouse_event);
+ ASSERT_TRUE(event);
+ ASSERT_TRUE(event->IsMouseEvent());
+ auto mouse_event = static_cast<MouseEvent*>(event.get());
+ EXPECT_EQ(mouse_event->location_f(), test_mouse_event.location_f());
+ EXPECT_EQ(mouse_event->root_location_f(), test_mouse_event.root_location_f());
+ EXPECT_EQ(mouse_event->time_stamp(), test_mouse_event.time_stamp());
+ EXPECT_EQ(mouse_event->button_flags(), test_mouse_event.button_flags());
+ EXPECT_EQ(mouse_event->changed_button_flags(),
+ test_mouse_event.changed_button_flags());
+}
+
TEST_F(WaylandWindowTest, ConfigureEvent) {
wl_array states;
wl_array_init(&states);

Powered by Google App Engine
This is Rietveld 408576698