| Flutter Linux Embedder |

Functions
fl_touch_manager_test.cc File Reference
`#include "flutter/shell/platform/linux/fl_touch_manager.h"`
`#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include <gdk/gdkwayland.h>`
`#include <cstring>`
`#include <vector>`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Functions
| TEST (FlTouchManagerTest, TouchEvents)

## Function Documentation

## ◆ TEST()

TEST | ( | FlTouchManagerTest | ,
|  | TouchEvents |
| ) |  |

Definition at line 15 of file fl_touch_manager_test.cc.

15 {
16 g_autoptr(FlDartProject) project = fl_dart_project_new();
17 g_autoptr(FlEngine) engine = fl_engine_new(project);
18
19 g_autoptr(GError) error = nullptr;
20 EXPECT_TRUE(fl_engine_start(engine, &error));
21 EXPECT_EQ(error, nullptr);
22
23 std::vector<FlutterPointerEvent> pointer_events;
24 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
25 SendPointerEvent,
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]);
30 }
31
32 return kSuccess;
33 }));
34
35 g_autoptr(FlTouchManager) manager = fl_touch_manager_new(engine, 0);
36
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));
42 event->time = 1;
43 event->x = 4.0;
44 event->y = 8.0;
45 event->device = touchscreen;
46 fl_touch_manager_handle_touch_event(manager, event, 1.0);
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,
52 1000lu); // Milliseconds -> Microseconds
53 EXPECT_EQ(pointer_events[0].phase, kAdd);
54
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,
59 1000lu); // Milliseconds -> Microseconds
60 EXPECT_EQ(pointer_events[1].phase, kDown);
61
62 event->type = GDK_TOUCH_UPDATE;
63 fl_touch_manager_handle_touch_event(manager, event, 1.0);
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,
69 1000lu); // Milliseconds -> Microseconds
70 EXPECT_EQ(pointer_events[2].phase, kMove);
71
72 event->type = GDK_TOUCH_END;
73 fl_touch_manager_handle_touch_event(manager, event, 1.0);
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,
79 1000lu); // Milliseconds -> Microseconds
80 EXPECT_EQ(pointer_events[3].phase, kUp);
81
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,
86 1000lu); // Milliseconds -> Microseconds
87 EXPECT_EQ(pointer_events[4].phase, kRemove);
88 }
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:52
fl_engine_get_embedder_api
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
Definition: fl_engine.cc:858
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:720
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:691
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
i
int i
Definition: fl_socket_accessible.cc:18
fl_touch_manager_handle_touch_event
void fl_touch_manager_handle_touch_event(FlTouchManager *self, GdkEventTouch *touch_event, gint scale_factor)
Definition: fl_touch_manager.cc:131
fl_touch_manager_new
FlTouchManager * fl_touch_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_touch_manager.cc:48

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_touch_manager_handle_touch_event(), fl_touch_manager_new(), and i.