| Flutter Linux Embedder |

Functions
fl_pointer_manager_test.cc File Reference
`#include "flutter/shell/platform/linux/fl_pointer_manager.h"`
`#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Functions
| TEST (FlPointerManagerTest, EnterLeave)
| TEST (FlPointerManagerTest, EnterEnter)
| TEST (FlPointerManagerTest, EnterLeaveLeave)
| TEST (FlPointerManagerTest, EnterButtonPress)
| TEST (FlPointerManagerTest, NoEnterButtonPress)
| TEST (FlPointerManagerTest, ButtonPressButtonRelease)
| TEST (FlPointerManagerTest, ButtonPressButtonReleaseThreeButtons)
| TEST (FlPointerManagerTest, ButtonPressButtonPressButtonRelease)
| TEST (FlPointerManagerTest, ButtonPressButtonReleaseButtonRelease)
| TEST (FlPointerManagerTest, NoButtonPressButtonRelease)
| TEST (FlPointerManagerTest, Motion)
| TEST (FlPointerManagerTest, Drag)
| TEST (FlPointerManagerTest, DeviceKind)

## Function Documentation

## ◆ TEST() [1/13]

TEST | ( | FlPointerManagerTest | ,
|  | ButtonPressButtonPressButtonRelease |
| ) |  |

Definition at line 343 of file fl_pointer_manager_test.cc.

343 {
344 g_autoptr(FlDartProject) project = fl_dart_project_new();
345 g_autoptr(FlEngine) engine = fl_engine_new(project);
346
347 g_autoptr(GError) error = nullptr;
348 EXPECT_TRUE(fl_engine_start(engine, &error));
349 EXPECT_EQ(error, nullptr);
350
351 std::vector<FlutterPointerEvent> pointer_events;
352 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
353 SendPointerEvent,
354 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
355 size_t events_count) {
356 for (size_t i = 0; i < events_count; i++) {
357 pointer_events.push_back(events[i]);
358 }
359
360 return kSuccess;
361 }));
362
363 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
364 fl_pointer_manager_handle_button_press(
365 manager, 1234, kFlutterPointerDeviceKindMouse, 4.0, 8.0,
366 kFlutterPointerButtonMousePrimary);
367 // Ignore duplicate press
368 fl_pointer_manager_handle_button_press(
369 manager, 1234, kFlutterPointerDeviceKindMouse, 6.0, 10.0,
370 kFlutterPointerButtonMousePrimary);
371 fl_pointer_manager_handle_button_release(
372 manager, 1235, kFlutterPointerDeviceKindMouse, 5.0, 9.0,
373 kFlutterPointerButtonMousePrimary);
374
375 EXPECT_EQ(pointer_events.size(), 3u);
376
377 // Ignore first synthetic enter event
378 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
379 EXPECT_EQ(pointer_events[1].x, 4.0);
380 EXPECT_EQ(pointer_events[1].y, 8.0);
381 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
382 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
383 EXPECT_EQ(pointer_events[1].view_id, 42);
384 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
385 EXPECT_EQ(pointer_events[2].x, 5.0);
386 EXPECT_EQ(pointer_events[2].y, 9.0);
387 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
388 EXPECT_EQ(pointer_events[2].buttons, 0);
389 EXPECT_EQ(pointer_events[2].view_id, 42);
390 }
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:50
fl_engine_get_embedder_api
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
Definition: fl_engine.cc:661
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:544
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:524
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_pointer_manager_handle_button_release
gboolean fl_pointer_manager_handle_button_release(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, int64_t button)
Definition: fl_pointer_manager.cc:109
fl_pointer_manager_new
FlPointerManager * fl_pointer_manager_new(FlutterViewId view_id, FlEngine *engine)
Definition: fl_pointer_manager.cc:65
fl_pointer_manager_handle_button_press
gboolean fl_pointer_manager_handle_button_press(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, int64_t button)
Definition: fl_pointer_manager.cc:76
i
int i
Definition: fl_socket_accessible.cc:18

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_new(), and i.

## ◆ TEST() [2/13]

TEST | ( | FlPointerManagerTest | ,
|  | ButtonPressButtonRelease |
| ) |  |

Definition at line 224 of file fl_pointer_manager_test.cc.

224 {
225 g_autoptr(FlDartProject) project = fl_dart_project_new();
226 g_autoptr(FlEngine) engine = fl_engine_new(project);
227
228 g_autoptr(GError) error = nullptr;
229 EXPECT_TRUE(fl_engine_start(engine, &error));
230 EXPECT_EQ(error, nullptr);
231
232 std::vector<FlutterPointerEvent> pointer_events;
233 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
234 SendPointerEvent,
235 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
236 size_t events_count) {
237 for (size_t i = 0; i < events_count; i++) {
238 pointer_events.push_back(events[i]);
239 }
240
241 return kSuccess;
242 }));
243
244 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
245 fl_pointer_manager_handle_button_press(
246 manager, 1234, kFlutterPointerDeviceKindMouse, 4.0, 8.0,
247 kFlutterPointerButtonMousePrimary);
248 fl_pointer_manager_handle_button_release(
249 manager, 1235, kFlutterPointerDeviceKindMouse, 5.0, 9.0,
250 kFlutterPointerButtonMousePrimary);
251
252 EXPECT_EQ(pointer_events.size(), 3u);
253
254 // Ignore first synthetic enter event
255 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
256 EXPECT_EQ(pointer_events[1].x, 4.0);
257 EXPECT_EQ(pointer_events[1].y, 8.0);
258 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
259 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
260 EXPECT_EQ(pointer_events[1].view_id, 42);
261 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
262 EXPECT_EQ(pointer_events[2].x, 5.0);
263 EXPECT_EQ(pointer_events[2].y, 9.0);
264 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
265 EXPECT_EQ(pointer_events[2].buttons, 0);
266 EXPECT_EQ(pointer_events[2].view_id, 42);
267 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_new(), and i.

## ◆ TEST() [3/13]

TEST | ( | FlPointerManagerTest | ,
|  | ButtonPressButtonReleaseButtonRelease |
| ) |  |

Definition at line 392 of file fl_pointer_manager_test.cc.

392 {
393 g_autoptr(FlDartProject) project = fl_dart_project_new();
394 g_autoptr(FlEngine) engine = fl_engine_new(project);
395
396 g_autoptr(GError) error = nullptr;
397 EXPECT_TRUE(fl_engine_start(engine, &error));
398 EXPECT_EQ(error, nullptr);
399
400 std::vector<FlutterPointerEvent> pointer_events;
401 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
402 SendPointerEvent,
403 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
404 size_t events_count) {
405 for (size_t i = 0; i < events_count; i++) {
406 pointer_events.push_back(events[i]);
407 }
408
409 return kSuccess;
410 }));
411
412 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
413 fl_pointer_manager_handle_button_press(
414 manager, 1234, kFlutterPointerDeviceKindMouse, 4.0, 8.0,
415 kFlutterPointerButtonMousePrimary);
416 fl_pointer_manager_handle_button_release(
417 manager, 1235, kFlutterPointerDeviceKindMouse, 5.0, 9.0,
418 kFlutterPointerButtonMousePrimary);
419 // Ignore duplicate release
420 fl_pointer_manager_handle_button_release(
421 manager, 1235, kFlutterPointerDeviceKindMouse, 6.0, 10.0,
422 kFlutterPointerButtonMousePrimary);
423
424 EXPECT_EQ(pointer_events.size(), 3u);
425
426 // Ignore first synthetic enter event
427 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
428 EXPECT_EQ(pointer_events[1].x, 4.0);
429 EXPECT_EQ(pointer_events[1].y, 8.0);
430 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
431 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
432 EXPECT_EQ(pointer_events[1].view_id, 42);
433 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
434 EXPECT_EQ(pointer_events[2].x, 5.0);
435 EXPECT_EQ(pointer_events[2].y, 9.0);
436 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
437 EXPECT_EQ(pointer_events[2].buttons, 0);
438 EXPECT_EQ(pointer_events[2].view_id, 42);
439 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_new(), and i.

## ◆ TEST() [4/13]

TEST | ( | FlPointerManagerTest | ,
|  | ButtonPressButtonReleaseThreeButtons |
| ) |  |

Definition at line 269 of file fl_pointer_manager_test.cc.

269 {
270 g_autoptr(FlDartProject) project = fl_dart_project_new();
271 g_autoptr(FlEngine) engine = fl_engine_new(project);
272
273 g_autoptr(GError) error = nullptr;
274 EXPECT_TRUE(fl_engine_start(engine, &error));
275 EXPECT_EQ(error, nullptr);
276
277 std::vector<FlutterPointerEvent> pointer_events;
278 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
279 SendPointerEvent,
280 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
281 size_t events_count) {
282 for (size_t i = 0; i < events_count; i++) {
283 pointer_events.push_back(events[i]);
284 }
285
286 return kSuccess;
287 }));
288
289 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
290 // Press buttons 1-2-3, release 3-2-1
291 fl_pointer_manager_handle_button_press(
292 manager, 1234, kFlutterPointerDeviceKindMouse, 1.0, 2.0,
293 kFlutterPointerButtonMousePrimary);
294 fl_pointer_manager_handle_button_press(
295 manager, 1235, kFlutterPointerDeviceKindMouse, 3.0, 4.0,
296 kFlutterPointerButtonMouseSecondary);
297 fl_pointer_manager_handle_button_press(manager, 1236,
298 kFlutterPointerDeviceKindMouse, 5.0,
299 6.0, kFlutterPointerButtonMouseMiddle);
300 fl_pointer_manager_handle_button_release(
301 manager, 1237, kFlutterPointerDeviceKindMouse, 7.0, 8.0,
302 kFlutterPointerButtonMouseMiddle);
303 fl_pointer_manager_handle_button_release(
304 manager, 1238, kFlutterPointerDeviceKindMouse, 9.0, 10.0,
305 kFlutterPointerButtonMouseSecondary);
306 fl_pointer_manager_handle_button_release(
307 manager, 1239, kFlutterPointerDeviceKindMouse, 11.0, 12.0,
308 kFlutterPointerButtonMousePrimary);
309
310 EXPECT_EQ(pointer_events.size(), 7u);
311
312 // Ignore first synthetic enter event
313 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
314 EXPECT_EQ(pointer_events[1].x, 1.0);
315 EXPECT_EQ(pointer_events[1].y, 2.0);
316 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
317 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
318 EXPECT_EQ(pointer_events[2].x, 3.0);
319 EXPECT_EQ(pointer_events[2].y, 4.0);
320 EXPECT_EQ(pointer_events[2].buttons, kFlutterPointerButtonMousePrimary |
321 kFlutterPointerButtonMouseSecondary);
322 EXPECT_EQ(pointer_events[3].timestamp, 1236000u);
323 EXPECT_EQ(pointer_events[3].x, 5.0);
324 EXPECT_EQ(pointer_events[3].y, 6.0);
325 EXPECT_EQ(pointer_events[3].buttons, kFlutterPointerButtonMousePrimary |
326 kFlutterPointerButtonMouseSecondary |
327 kFlutterPointerButtonMouseMiddle);
328 EXPECT_EQ(pointer_events[4].timestamp, 1237000u);
329 EXPECT_EQ(pointer_events[4].x, 7.0);
330 EXPECT_EQ(pointer_events[4].y, 8.0);
331 EXPECT_EQ(pointer_events[4].buttons, kFlutterPointerButtonMousePrimary |
332 kFlutterPointerButtonMouseSecondary);
333 EXPECT_EQ(pointer_events[5].timestamp, 1238000u);
334 EXPECT_EQ(pointer_events[5].x, 9.0);
335 EXPECT_EQ(pointer_events[5].y, 10.0);
336 EXPECT_EQ(pointer_events[5].buttons, kFlutterPointerButtonMousePrimary);
337 EXPECT_EQ(pointer_events[6].timestamp, 1239000u);
338 EXPECT_EQ(pointer_events[6].x, 11.0);
339 EXPECT_EQ(pointer_events[6].y, 12.0);
340 EXPECT_EQ(pointer_events[6].buttons, 0);
341 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_new(), and i.

## ◆ TEST() [5/13]

TEST | ( | FlPointerManagerTest | ,
|  | DeviceKind |
| ) |  |

Definition at line 585 of file fl_pointer_manager_test.cc.

585 {
586 g_autoptr(FlDartProject) project = fl_dart_project_new();
587 g_autoptr(FlEngine) engine = fl_engine_new(project);
588
589 g_autoptr(GError) error = nullptr;
590 EXPECT_TRUE(fl_engine_start(engine, &error));
591 EXPECT_EQ(error, nullptr);
592
593 std::vector<FlutterPointerEvent> pointer_events;
594 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
595 SendPointerEvent,
596 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
597 size_t events_count) {
598 for (size_t i = 0; i < events_count; i++) {
599 pointer_events.push_back(events[i]);
600 }
601
602 return kSuccess;
603 }));
604
605 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
606 fl_pointer_manager_handle_enter(manager, 1234,
607 kFlutterPointerDeviceKindTrackpad, 1.0, 2.0);
608 fl_pointer_manager_handle_button_press(
609 manager, 1235, kFlutterPointerDeviceKindTrackpad, 1.0, 2.0,
610 kFlutterPointerButtonMousePrimary);
611 fl_pointer_manager_handle_motion(manager, 1238,
612 kFlutterPointerDeviceKindTrackpad, 3.0, 4.0);
613 fl_pointer_manager_handle_button_release(
614 manager, 1237, kFlutterPointerDeviceKindTrackpad, 3.0, 4.0,
615 kFlutterPointerButtonMousePrimary);
616 fl_pointer_manager_handle_leave(manager, 1235,
617 kFlutterPointerDeviceKindTrackpad, 3.0, 4.0);
618
619 EXPECT_EQ(pointer_events.size(), 5u);
620
621 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindTrackpad);
622 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindTrackpad);
623 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindTrackpad);
624 EXPECT_EQ(pointer_events[3].device_kind, kFlutterPointerDeviceKindTrackpad);
625 EXPECT_EQ(pointer_events[4].device_kind, kFlutterPointerDeviceKindTrackpad);
626 }
fl_pointer_manager_handle_motion
gboolean fl_pointer_manager_handle_motion(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:140
fl_pointer_manager_handle_enter
gboolean fl_pointer_manager_handle_enter(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:162
fl_pointer_manager_handle_leave
gboolean fl_pointer_manager_handle_leave(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:179

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_handle_enter(), fl_pointer_manager_handle_leave(), fl_pointer_manager_handle_motion(), fl_pointer_manager_new(), and i.

## ◆ TEST() [6/13]

TEST | ( | FlPointerManagerTest | ,
|  | Drag |
| ) |  |

Definition at line 521 of file fl_pointer_manager_test.cc.

521 {
522 g_autoptr(FlDartProject) project = fl_dart_project_new();
523 g_autoptr(FlEngine) engine = fl_engine_new(project);
524
525 g_autoptr(GError) error = nullptr;
526 EXPECT_TRUE(fl_engine_start(engine, &error));
527 EXPECT_EQ(error, nullptr);
528
529 std::vector<FlutterPointerEvent> pointer_events;
530 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
531 SendPointerEvent,
532 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
533 size_t events_count) {
534 for (size_t i = 0; i < events_count; i++) {
535 pointer_events.push_back(events[i]);
536 }
537
538 return kSuccess;
539 }));
540
541 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
542 fl_pointer_manager_handle_motion(manager, 1234,
543 kFlutterPointerDeviceKindMouse, 1.0, 2.0);
544 fl_pointer_manager_handle_button_press(
545 manager, 1235, kFlutterPointerDeviceKindMouse, 3.0, 4.0,
546 kFlutterPointerButtonMousePrimary);
547 fl_pointer_manager_handle_motion(manager, 1236,
548 kFlutterPointerDeviceKindMouse, 5.0, 6.0);
549 fl_pointer_manager_handle_button_release(
550 manager, 1237, kFlutterPointerDeviceKindMouse, 7.0, 8.0,
551 kFlutterPointerButtonMousePrimary);
552 fl_pointer_manager_handle_motion(manager, 1238,
553 kFlutterPointerDeviceKindMouse, 9.0, 10.0);
554
555 EXPECT_EQ(pointer_events.size(), 6u);
556
557 // Ignore first synthetic enter event
558 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
559 EXPECT_EQ(pointer_events[1].x, 1.0);
560 EXPECT_EQ(pointer_events[1].y, 2.0);
561 EXPECT_EQ(pointer_events[1].buttons, 0);
562 EXPECT_EQ(pointer_events[1].view_id, 42);
563 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
564 EXPECT_EQ(pointer_events[2].x, 3.0);
565 EXPECT_EQ(pointer_events[2].y, 4.0);
566 EXPECT_EQ(pointer_events[2].buttons, kFlutterPointerButtonMousePrimary);
567 EXPECT_EQ(pointer_events[2].view_id, 42);
568 EXPECT_EQ(pointer_events[3].timestamp, 1236000u);
569 EXPECT_EQ(pointer_events[3].x, 5.0);
570 EXPECT_EQ(pointer_events[3].y, 6.0);
571 EXPECT_EQ(pointer_events[3].buttons, kFlutterPointerButtonMousePrimary);
572 EXPECT_EQ(pointer_events[3].view_id, 42);
573 EXPECT_EQ(pointer_events[4].timestamp, 1237000u);
574 EXPECT_EQ(pointer_events[4].x, 7.0);
575 EXPECT_EQ(pointer_events[4].y, 8.0);
576 EXPECT_EQ(pointer_events[4].buttons, 0);
577 EXPECT_EQ(pointer_events[4].view_id, 42);
578 EXPECT_EQ(pointer_events[5].timestamp, 1238000u);
579 EXPECT_EQ(pointer_events[5].x, 9.0);
580 EXPECT_EQ(pointer_events[5].y, 10.0);
581 EXPECT_EQ(pointer_events[5].buttons, 0);
582 EXPECT_EQ(pointer_events[5].view_id, 42);
583 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_handle_motion(), fl_pointer_manager_new(), and i.

## ◆ TEST() [7/13]

TEST | ( | FlPointerManagerTest | ,
|  | EnterButtonPress |
| ) |  |

Definition at line 137 of file fl_pointer_manager_test.cc.

137 {
138 g_autoptr(FlDartProject) project = fl_dart_project_new();
139 g_autoptr(FlEngine) engine = fl_engine_new(project);
140
141 g_autoptr(GError) error = nullptr;
142 EXPECT_TRUE(fl_engine_start(engine, &error));
143 EXPECT_EQ(error, nullptr);
144
145 std::vector<FlutterPointerEvent> pointer_events;
146 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
147 SendPointerEvent,
148 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
149 size_t events_count) {
150 for (size_t i = 0; i < events_count; i++) {
151 pointer_events.push_back(events[i]);
152 }
153
154 return kSuccess;
155 }));
156
157 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
158 fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
159 1.0, 2.0);
160 fl_pointer_manager_handle_button_press(
161 manager, 1235, kFlutterPointerDeviceKindMouse, 4.0, 8.0,
162 kFlutterPointerButtonMousePrimary);
163
164 EXPECT_EQ(pointer_events.size(), 2u);
165
166 EXPECT_EQ(pointer_events[0].timestamp, 1234000u);
167 EXPECT_EQ(pointer_events[0].x, 1.0);
168 EXPECT_EQ(pointer_events[0].y, 2.0);
169 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
170 EXPECT_EQ(pointer_events[0].buttons, 0);
171 EXPECT_EQ(pointer_events[0].view_id, 42);
172
173 EXPECT_EQ(pointer_events[1].timestamp, 1235000u);
174 EXPECT_EQ(pointer_events[1].x, 4.0);
175 EXPECT_EQ(pointer_events[1].y, 8.0);
176 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
177 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
178 EXPECT_EQ(pointer_events[1].view_id, 42);
179 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_enter(), fl_pointer_manager_new(), and i.

## ◆ TEST() [8/13]

TEST | ( | FlPointerManagerTest | ,
|  | EnterEnter |
| ) |  |

Definition at line 54 of file fl_pointer_manager_test.cc.

54 {
55 g_autoptr(FlDartProject) project = fl_dart_project_new();
56 g_autoptr(FlEngine) engine = fl_engine_new(project);
57
58 g_autoptr(GError) error = nullptr;
59 EXPECT_TRUE(fl_engine_start(engine, &error));
60 EXPECT_EQ(error, nullptr);
61
62 std::vector<FlutterPointerEvent> pointer_events;
63 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
64 SendPointerEvent,
65 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
66 size_t events_count) {
67 for (size_t i = 0; i < events_count; i++) {
68 pointer_events.push_back(events[i]);
69 }
70
71 return kSuccess;
72 }));
73
74 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
75 fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
76 1.0, 2.0);
77 // Duplicate enter is ignored
78 fl_pointer_manager_handle_enter(manager, 1235, kFlutterPointerDeviceKindMouse,
79 3.0, 4.0);
80
81 EXPECT_EQ(pointer_events.size(), 1u);
82
83 EXPECT_EQ(pointer_events[0].timestamp, 1234000u);
84 EXPECT_EQ(pointer_events[0].x, 1.0);
85 EXPECT_EQ(pointer_events[0].y, 2.0);
86 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
87 EXPECT_EQ(pointer_events[0].buttons, 0);
88 EXPECT_EQ(pointer_events[0].view_id, 42);
89 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_enter(), fl_pointer_manager_new(), and i.

## ◆ TEST() [9/13]

TEST | ( | FlPointerManagerTest | ,
|  | EnterLeave |
| ) |  |

Definition at line 11 of file fl_pointer_manager_test.cc.

11 {
12 g_autoptr(FlDartProject) project = fl_dart_project_new();
13 g_autoptr(FlEngine) engine = fl_engine_new(project);
14
15 g_autoptr(GError) error = nullptr;
16 EXPECT_TRUE(fl_engine_start(engine, &error));
17 EXPECT_EQ(error, nullptr);
18
19 std::vector<FlutterPointerEvent> pointer_events;
20 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
21 SendPointerEvent,
22 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
23 size_t events_count) {
24 for (size_t i = 0; i < events_count; i++) {
25 pointer_events.push_back(events[i]);
26 }
27
28 return kSuccess;
29 }));
30
31 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
32 fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
33 1.0, 2.0);
34 fl_pointer_manager_handle_leave(manager, 1235, kFlutterPointerDeviceKindMouse,
35 3.0, 4.0);
36
37 EXPECT_EQ(pointer_events.size(), 2u);
38
39 EXPECT_EQ(pointer_events[0].timestamp, 1234000u);
40 EXPECT_EQ(pointer_events[0].x, 1.0);
41 EXPECT_EQ(pointer_events[0].y, 2.0);
42 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
43 EXPECT_EQ(pointer_events[0].buttons, 0);
44 EXPECT_EQ(pointer_events[0].view_id, 42);
45
46 EXPECT_EQ(pointer_events[1].timestamp, 1235000u);
47 EXPECT_EQ(pointer_events[1].x, 3.0);
48 EXPECT_EQ(pointer_events[1].y, 4.0);
49 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
50 EXPECT_EQ(pointer_events[1].buttons, 0);
51 EXPECT_EQ(pointer_events[1].view_id, 42);
52 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_enter(), fl_pointer_manager_handle_leave(), fl_pointer_manager_new(), and i.

## ◆ TEST() [10/13]

TEST | ( | FlPointerManagerTest | ,
|  | EnterLeaveLeave |
| ) |  |

Definition at line 91 of file fl_pointer_manager_test.cc.

91 {
92 g_autoptr(FlDartProject) project = fl_dart_project_new();
93 g_autoptr(FlEngine) engine = fl_engine_new(project);
94
95 g_autoptr(GError) error = nullptr;
96 EXPECT_TRUE(fl_engine_start(engine, &error));
97 EXPECT_EQ(error, nullptr);
98
99 std::vector<FlutterPointerEvent> pointer_events;
100 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
101 SendPointerEvent,
102 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
103 size_t events_count) {
104 for (size_t i = 0; i < events_count; i++) {
105 pointer_events.push_back(events[i]);
106 }
107
108 return kSuccess;
109 }));
110
111 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
112 fl_pointer_manager_handle_enter(manager, 1234, kFlutterPointerDeviceKindMouse,
113 1.0, 2.0);
114 fl_pointer_manager_handle_leave(manager, 1235, kFlutterPointerDeviceKindMouse,
115 3.0, 4.0);
116 // Duplicate leave is ignored
117 fl_pointer_manager_handle_leave(manager, 1235, kFlutterPointerDeviceKindMouse,
118 5.0, 6.0);
119
120 EXPECT_EQ(pointer_events.size(), 2u);
121
122 EXPECT_EQ(pointer_events[0].timestamp, 1234000u);
123 EXPECT_EQ(pointer_events[0].x, 1.0);
124 EXPECT_EQ(pointer_events[0].y, 2.0);
125 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
126 EXPECT_EQ(pointer_events[0].buttons, 0);
127 EXPECT_EQ(pointer_events[0].view_id, 42);
128
129 EXPECT_EQ(pointer_events[1].timestamp, 1235000u);
130 EXPECT_EQ(pointer_events[1].x, 3.0);
131 EXPECT_EQ(pointer_events[1].y, 4.0);
132 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
133 EXPECT_EQ(pointer_events[1].buttons, 0);
134 EXPECT_EQ(pointer_events[1].view_id, 42);
135 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_enter(), fl_pointer_manager_handle_leave(), fl_pointer_manager_new(), and i.

## ◆ TEST() [11/13]

TEST | ( | FlPointerManagerTest | ,
|  | Motion |
| ) |  |

Definition at line 470 of file fl_pointer_manager_test.cc.

470 {
471 g_autoptr(FlDartProject) project = fl_dart_project_new();
472 g_autoptr(FlEngine) engine = fl_engine_new(project);
473
474 g_autoptr(GError) error = nullptr;
475 EXPECT_TRUE(fl_engine_start(engine, &error));
476 EXPECT_EQ(error, nullptr);
477
478 std::vector<FlutterPointerEvent> pointer_events;
479 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
480 SendPointerEvent,
481 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
482 size_t events_count) {
483 for (size_t i = 0; i < events_count; i++) {
484 pointer_events.push_back(events[i]);
485 }
486
487 return kSuccess;
488 }));
489
490 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
491 fl_pointer_manager_handle_motion(manager, 1234,
492 kFlutterPointerDeviceKindMouse, 1.0, 2.0);
493 fl_pointer_manager_handle_motion(manager, 1235,
494 kFlutterPointerDeviceKindMouse, 3.0, 4.0);
495 fl_pointer_manager_handle_motion(manager, 1236,
496 kFlutterPointerDeviceKindMouse, 5.0, 6.0);
497
498 EXPECT_EQ(pointer_events.size(), 4u);
499
500 // Ignore first synthetic enter event
501 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
502 EXPECT_EQ(pointer_events[1].x, 1.0);
503 EXPECT_EQ(pointer_events[1].y, 2.0);
504 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
505 EXPECT_EQ(pointer_events[1].buttons, 0);
506 EXPECT_EQ(pointer_events[1].view_id, 42);
507 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
508 EXPECT_EQ(pointer_events[2].x, 3.0);
509 EXPECT_EQ(pointer_events[2].y, 4.0);
510 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
511 EXPECT_EQ(pointer_events[2].buttons, 0);
512 EXPECT_EQ(pointer_events[2].view_id, 42);
513 EXPECT_EQ(pointer_events[3].timestamp, 1236000u);
514 EXPECT_EQ(pointer_events[3].x, 5.0);
515 EXPECT_EQ(pointer_events[3].y, 6.0);
516 EXPECT_EQ(pointer_events[3].device_kind, kFlutterPointerDeviceKindMouse);
517 EXPECT_EQ(pointer_events[3].buttons, 0);
518 EXPECT_EQ(pointer_events[3].view_id, 42);
519 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_motion(), fl_pointer_manager_new(), and i.

## ◆ TEST() [12/13]

TEST | ( | FlPointerManagerTest | ,
|  | NoButtonPressButtonRelease |
| ) |  |

Definition at line 441 of file fl_pointer_manager_test.cc.

441 {
442 g_autoptr(FlDartProject) project = fl_dart_project_new();
443 g_autoptr(FlEngine) engine = fl_engine_new(project);
444
445 g_autoptr(GError) error = nullptr;
446 EXPECT_TRUE(fl_engine_start(engine, &error));
447 EXPECT_EQ(error, nullptr);
448
449 std::vector<FlutterPointerEvent> pointer_events;
450 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
451 SendPointerEvent,
452 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
453 size_t events_count) {
454 for (size_t i = 0; i < events_count; i++) {
455 pointer_events.push_back(events[i]);
456 }
457
458 return kSuccess;
459 }));
460
461 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
462 // Release without associated press, will be ignored
463 fl_pointer_manager_handle_button_release(
464 manager, 1235, kFlutterPointerDeviceKindMouse, 5.0, 9.0,
465 kFlutterPointerButtonMousePrimary);
466
467 EXPECT_EQ(pointer_events.size(), 0u);
468 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_new(), and i.

## ◆ TEST() [13/13]

TEST | ( | FlPointerManagerTest | ,
|  | NoEnterButtonPress |
| ) |  |

Definition at line 181 of file fl_pointer_manager_test.cc.

181 {
182 g_autoptr(FlDartProject) project = fl_dart_project_new();
183 g_autoptr(FlEngine) engine = fl_engine_new(project);
184
185 g_autoptr(GError) error = nullptr;
186 EXPECT_TRUE(fl_engine_start(engine, &error));
187 EXPECT_EQ(error, nullptr);
188
189 std::vector<FlutterPointerEvent> pointer_events;
190 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
191 SendPointerEvent,
192 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
193 size_t events_count) {
194 for (size_t i = 0; i < events_count; i++) {
195 pointer_events.push_back(events[i]);
196 }
197
198 return kSuccess;
199 }));
200
201 g_autoptr(FlPointerManager) manager = fl_pointer_manager_new(42, engine);
202 fl_pointer_manager_handle_button_press(
203 manager, 1234, kFlutterPointerDeviceKindMouse, 4.0, 8.0,
204 kFlutterPointerButtonMousePrimary);
205
206 EXPECT_EQ(pointer_events.size(), 2u);
207
208 // Synthetic enter events
209 EXPECT_EQ(pointer_events[0].timestamp, 1234000u);
210 EXPECT_EQ(pointer_events[0].x, 4.0);
211 EXPECT_EQ(pointer_events[0].y, 8.0);
212 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
213 EXPECT_EQ(pointer_events[0].buttons, 0);
214 EXPECT_EQ(pointer_events[0].view_id, 42);
215
216 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
217 EXPECT_EQ(pointer_events[1].x, 4.0);
218 EXPECT_EQ(pointer_events[1].y, 8.0);
219 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
220 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
221 EXPECT_EQ(pointer_events[1].view_id, 42);
222 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_new(), and i.