6 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
9 #include <gdk/gdkwayland.h>
13 #include "gtest/gtest.h"
15 TEST(FlTouchManagerTest, TouchEvents) {
19 g_autoptr(GError)
error =
nullptr;
21 EXPECT_EQ(
error,
nullptr);
23 std::vector<FlutterPointerEvent> pointer_events;
26 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
27 size_t events_count) {
28 for (
size_t i = 0;
i < events_count;
i++) {
29 pointer_events.push_back(events[
i]);
37 GdkDevice* touchscreen =
38 GDK_DEVICE(g_object_new(gdk_wayland_device_get_type(),
"input-source",
39 GDK_SOURCE_TOUCHSCREEN,
nullptr));
40 GdkEventTouch*
event =
41 reinterpret_cast<GdkEventTouch*
>(gdk_event_new(GDK_TOUCH_BEGIN));
45 event->device = touchscreen;
47 EXPECT_EQ(pointer_events.size(), 2u);
48 EXPECT_EQ(pointer_events[0].x, 4.0);
49 EXPECT_EQ(pointer_events[0].y, 8.0);
50 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindTouch);
51 EXPECT_EQ(pointer_events[0].timestamp,
53 EXPECT_EQ(pointer_events[0].phase, kAdd);
55 EXPECT_EQ(pointer_events[1].x, 4.0);
56 EXPECT_EQ(pointer_events[1].y, 8.0);
57 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindTouch);
58 EXPECT_EQ(pointer_events[1].timestamp,
60 EXPECT_EQ(pointer_events[1].phase, kDown);
62 event->type = GDK_TOUCH_UPDATE;
64 EXPECT_EQ(pointer_events.size(), 3u);
65 EXPECT_EQ(pointer_events[2].x, 4.0);
66 EXPECT_EQ(pointer_events[2].y, 8.0);
67 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindTouch);
68 EXPECT_EQ(pointer_events[2].timestamp,
70 EXPECT_EQ(pointer_events[2].phase, kMove);
72 event->type = GDK_TOUCH_END;
74 EXPECT_EQ(pointer_events.size(), 5u);
75 EXPECT_EQ(pointer_events[3].x, 4.0);
76 EXPECT_EQ(pointer_events[3].y, 8.0);
77 EXPECT_EQ(pointer_events[3].device_kind, kFlutterPointerDeviceKindTouch);
78 EXPECT_EQ(pointer_events[3].timestamp,
80 EXPECT_EQ(pointer_events[3].phase, kUp);
82 EXPECT_EQ(pointer_events[4].x, 4.0);
83 EXPECT_EQ(pointer_events[4].y, 8.0);
84 EXPECT_EQ(pointer_events[4].device_kind, kFlutterPointerDeviceKindTouch);
85 EXPECT_EQ(pointer_events[4].timestamp,
87 EXPECT_EQ(pointer_events[4].phase, kRemove);