6 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
9 #include "gtest/gtest.h"
11 TEST(FlPointerManagerTest, EnterLeave) {
15 g_autoptr(GError)
error =
nullptr;
17 EXPECT_EQ(
error,
nullptr);
19 std::vector<FlutterPointerEvent> pointer_events;
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]);
37 EXPECT_EQ(pointer_events.size(), 2u);
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);
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);
54 TEST(FlPointerManagerTest, EnterEnter) {
58 g_autoptr(GError)
error =
nullptr;
60 EXPECT_EQ(
error,
nullptr);
62 std::vector<FlutterPointerEvent> pointer_events;
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]);
81 EXPECT_EQ(pointer_events.size(), 1u);
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);
91 TEST(FlPointerManagerTest, EnterLeaveLeave) {
95 g_autoptr(GError)
error =
nullptr;
97 EXPECT_EQ(
error,
nullptr);
99 std::vector<FlutterPointerEvent> pointer_events;
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]);
120 EXPECT_EQ(pointer_events.size(), 2u);
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);
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);
137 TEST(FlPointerManagerTest, EnterButtonPress) {
141 g_autoptr(GError)
error =
nullptr;
143 EXPECT_EQ(
error,
nullptr);
145 std::vector<FlutterPointerEvent> pointer_events;
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]);
161 kFlutterPointerDeviceKindMouse, 4.0,
162 8.0, GDK_BUTTON_PRIMARY);
164 EXPECT_EQ(pointer_events.size(), 2u);
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);
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);
181 TEST(FlPointerManagerTest, NoEnterButtonPress) {
185 g_autoptr(GError)
error =
nullptr;
187 EXPECT_EQ(
error,
nullptr);
189 std::vector<FlutterPointerEvent> pointer_events;
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]);
203 kFlutterPointerDeviceKindMouse, 4.0,
204 8.0, GDK_BUTTON_PRIMARY);
206 EXPECT_EQ(pointer_events.size(), 2u);
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);
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);
224 TEST(FlPointerManagerTest, ButtonPressButtonReleasePrimary) {
228 g_autoptr(GError)
error =
nullptr;
230 EXPECT_EQ(
error,
nullptr);
232 std::vector<FlutterPointerEvent> pointer_events;
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]);
246 kFlutterPointerDeviceKindMouse, 4.0,
247 8.0, GDK_BUTTON_PRIMARY);
249 kFlutterPointerDeviceKindMouse, 5.0,
250 9.0, GDK_BUTTON_PRIMARY);
252 EXPECT_EQ(pointer_events.size(), 3u);
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);
269 TEST(FlPointerManagerTest, ButtonPressButtonReleaseSecondary) {
273 g_autoptr(GError)
error =
nullptr;
275 EXPECT_EQ(
error,
nullptr);
277 std::vector<FlutterPointerEvent> pointer_events;
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]);
291 kFlutterPointerDeviceKindMouse, 4.0,
292 8.0, GDK_BUTTON_SECONDARY);
294 kFlutterPointerDeviceKindMouse, 5.0,
295 9.0, GDK_BUTTON_SECONDARY);
297 EXPECT_EQ(pointer_events.size(), 3u);
300 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
301 EXPECT_EQ(pointer_events[1].x, 4.0);
302 EXPECT_EQ(pointer_events[1].y, 8.0);
303 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
304 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMouseSecondary);
305 EXPECT_EQ(pointer_events[1].view_id, 42);
306 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
307 EXPECT_EQ(pointer_events[2].x, 5.0);
308 EXPECT_EQ(pointer_events[2].y, 9.0);
309 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
310 EXPECT_EQ(pointer_events[2].buttons, 0);
311 EXPECT_EQ(pointer_events[2].view_id, 42);
314 TEST(FlPointerManagerTest, ButtonPressButtonReleaseMiddle) {
318 g_autoptr(GError)
error =
nullptr;
320 EXPECT_EQ(
error,
nullptr);
322 std::vector<FlutterPointerEvent> pointer_events;
325 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
326 size_t events_count) {
327 for (
size_t i = 0;
i < events_count;
i++) {
328 pointer_events.push_back(events[
i]);
336 kFlutterPointerDeviceKindMouse, 4.0,
337 8.0, GDK_BUTTON_MIDDLE);
339 kFlutterPointerDeviceKindMouse, 5.0,
340 9.0, GDK_BUTTON_MIDDLE);
342 EXPECT_EQ(pointer_events.size(), 3u);
345 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
346 EXPECT_EQ(pointer_events[1].x, 4.0);
347 EXPECT_EQ(pointer_events[1].y, 8.0);
348 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
349 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMouseMiddle);
350 EXPECT_EQ(pointer_events[1].view_id, 42);
351 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
352 EXPECT_EQ(pointer_events[2].x, 5.0);
353 EXPECT_EQ(pointer_events[2].y, 9.0);
354 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
355 EXPECT_EQ(pointer_events[2].buttons, 0);
356 EXPECT_EQ(pointer_events[2].view_id, 42);
359 TEST(FlPointerManagerTest, ButtonPressButtonReleaseBack) {
363 g_autoptr(GError)
error =
nullptr;
365 EXPECT_EQ(
error,
nullptr);
367 std::vector<FlutterPointerEvent> pointer_events;
370 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
371 size_t events_count) {
372 for (
size_t i = 0;
i < events_count;
i++) {
373 pointer_events.push_back(events[
i]);
382 manager, 1234, kFlutterPointerDeviceKindMouse, 4.0, 8.0, 8);
384 manager, 1235, kFlutterPointerDeviceKindMouse, 5.0, 9.0, 8);
386 EXPECT_EQ(pointer_events.size(), 3u);
389 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
390 EXPECT_EQ(pointer_events[1].x, 4.0);
391 EXPECT_EQ(pointer_events[1].y, 8.0);
392 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
393 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMouseBack);
394 EXPECT_EQ(pointer_events[1].view_id, 42);
395 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
396 EXPECT_EQ(pointer_events[2].x, 5.0);
397 EXPECT_EQ(pointer_events[2].y, 9.0);
398 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
399 EXPECT_EQ(pointer_events[2].buttons, 0);
400 EXPECT_EQ(pointer_events[2].view_id, 42);
403 TEST(FlPointerManagerTest, ButtonPressButtonReleaseForward) {
407 g_autoptr(GError)
error =
nullptr;
409 EXPECT_EQ(
error,
nullptr);
411 std::vector<FlutterPointerEvent> pointer_events;
414 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
415 size_t events_count) {
416 for (
size_t i = 0;
i < events_count;
i++) {
417 pointer_events.push_back(events[
i]);
426 manager, 1234, kFlutterPointerDeviceKindMouse, 4.0, 8.0, 9);
428 manager, 1235, kFlutterPointerDeviceKindMouse, 5.0, 9.0, 9);
430 EXPECT_EQ(pointer_events.size(), 3u);
433 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
434 EXPECT_EQ(pointer_events[1].x, 4.0);
435 EXPECT_EQ(pointer_events[1].y, 8.0);
436 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
437 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMouseForward);
438 EXPECT_EQ(pointer_events[1].view_id, 42);
439 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
440 EXPECT_EQ(pointer_events[2].x, 5.0);
441 EXPECT_EQ(pointer_events[2].y, 9.0);
442 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
443 EXPECT_EQ(pointer_events[2].buttons, 0);
444 EXPECT_EQ(pointer_events[2].view_id, 42);
447 TEST(FlPointerManagerTest, ButtonPressButtonReleaseThreeButtons) {
451 g_autoptr(GError)
error =
nullptr;
453 EXPECT_EQ(
error,
nullptr);
455 std::vector<FlutterPointerEvent> pointer_events;
458 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
459 size_t events_count) {
460 for (
size_t i = 0;
i < events_count;
i++) {
461 pointer_events.push_back(events[
i]);
470 kFlutterPointerDeviceKindMouse, 1.0,
471 2.0, GDK_BUTTON_PRIMARY);
473 kFlutterPointerDeviceKindMouse, 3.0,
474 4.0, GDK_BUTTON_SECONDARY);
476 kFlutterPointerDeviceKindMouse, 5.0,
477 6.0, GDK_BUTTON_MIDDLE);
479 kFlutterPointerDeviceKindMouse, 7.0,
480 8.0, GDK_BUTTON_MIDDLE);
482 kFlutterPointerDeviceKindMouse, 9.0,
483 10.0, GDK_BUTTON_SECONDARY);
485 manager, 1239, kFlutterPointerDeviceKindMouse, 11.0, 12.0,
486 kFlutterPointerButtonMousePrimary);
488 EXPECT_EQ(pointer_events.size(), 7u);
491 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
492 EXPECT_EQ(pointer_events[1].x, 1.0);
493 EXPECT_EQ(pointer_events[1].y, 2.0);
494 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
495 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
496 EXPECT_EQ(pointer_events[2].x, 3.0);
497 EXPECT_EQ(pointer_events[2].y, 4.0);
498 EXPECT_EQ(pointer_events[2].buttons, kFlutterPointerButtonMousePrimary |
499 kFlutterPointerButtonMouseSecondary);
500 EXPECT_EQ(pointer_events[3].timestamp, 1236000u);
501 EXPECT_EQ(pointer_events[3].x, 5.0);
502 EXPECT_EQ(pointer_events[3].y, 6.0);
503 EXPECT_EQ(pointer_events[3].buttons, kFlutterPointerButtonMousePrimary |
504 kFlutterPointerButtonMouseSecondary |
505 kFlutterPointerButtonMouseMiddle);
506 EXPECT_EQ(pointer_events[4].timestamp, 1237000u);
507 EXPECT_EQ(pointer_events[4].x, 7.0);
508 EXPECT_EQ(pointer_events[4].y, 8.0);
509 EXPECT_EQ(pointer_events[4].buttons, kFlutterPointerButtonMousePrimary |
510 kFlutterPointerButtonMouseSecondary);
511 EXPECT_EQ(pointer_events[5].timestamp, 1238000u);
512 EXPECT_EQ(pointer_events[5].x, 9.0);
513 EXPECT_EQ(pointer_events[5].y, 10.0);
514 EXPECT_EQ(pointer_events[5].buttons, kFlutterPointerButtonMousePrimary);
515 EXPECT_EQ(pointer_events[6].timestamp, 1239000u);
516 EXPECT_EQ(pointer_events[6].x, 11.0);
517 EXPECT_EQ(pointer_events[6].y, 12.0);
518 EXPECT_EQ(pointer_events[6].buttons, 0);
521 TEST(FlPointerManagerTest, ButtonPressButtonPressButtonRelease) {
525 g_autoptr(GError)
error =
nullptr;
527 EXPECT_EQ(
error,
nullptr);
529 std::vector<FlutterPointerEvent> pointer_events;
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]);
543 kFlutterPointerDeviceKindMouse, 4.0,
544 8.0, GDK_BUTTON_PRIMARY);
547 kFlutterPointerDeviceKindMouse, 6.0,
548 10.0, GDK_BUTTON_PRIMARY);
550 kFlutterPointerDeviceKindMouse, 5.0,
551 9.0, GDK_BUTTON_PRIMARY);
553 EXPECT_EQ(pointer_events.size(), 3u);
556 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
557 EXPECT_EQ(pointer_events[1].x, 4.0);
558 EXPECT_EQ(pointer_events[1].y, 8.0);
559 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
560 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
561 EXPECT_EQ(pointer_events[1].view_id, 42);
562 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
563 EXPECT_EQ(pointer_events[2].x, 5.0);
564 EXPECT_EQ(pointer_events[2].y, 9.0);
565 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
566 EXPECT_EQ(pointer_events[2].buttons, 0);
567 EXPECT_EQ(pointer_events[2].view_id, 42);
570 TEST(FlPointerManagerTest, ButtonPressButtonReleaseButtonRelease) {
574 g_autoptr(GError)
error =
nullptr;
576 EXPECT_EQ(
error,
nullptr);
578 std::vector<FlutterPointerEvent> pointer_events;
581 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
582 size_t events_count) {
583 for (
size_t i = 0;
i < events_count;
i++) {
584 pointer_events.push_back(events[
i]);
592 kFlutterPointerDeviceKindMouse, 4.0,
593 8.0, GDK_BUTTON_PRIMARY);
595 kFlutterPointerDeviceKindMouse, 5.0,
596 9.0, GDK_BUTTON_PRIMARY);
599 kFlutterPointerDeviceKindMouse, 6.0,
600 10.0, GDK_BUTTON_PRIMARY);
602 EXPECT_EQ(pointer_events.size(), 3u);
605 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
606 EXPECT_EQ(pointer_events[1].x, 4.0);
607 EXPECT_EQ(pointer_events[1].y, 8.0);
608 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
609 EXPECT_EQ(pointer_events[1].buttons, kFlutterPointerButtonMousePrimary);
610 EXPECT_EQ(pointer_events[1].view_id, 42);
611 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
612 EXPECT_EQ(pointer_events[2].x, 5.0);
613 EXPECT_EQ(pointer_events[2].y, 9.0);
614 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
615 EXPECT_EQ(pointer_events[2].buttons, 0);
616 EXPECT_EQ(pointer_events[2].view_id, 42);
619 TEST(FlPointerManagerTest, NoButtonPressButtonRelease) {
623 g_autoptr(GError)
error =
nullptr;
625 EXPECT_EQ(
error,
nullptr);
627 std::vector<FlutterPointerEvent> pointer_events;
630 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
631 size_t events_count) {
632 for (
size_t i = 0;
i < events_count;
i++) {
633 pointer_events.push_back(events[
i]);
642 kFlutterPointerDeviceKindMouse, 5.0,
643 9.0, GDK_BUTTON_PRIMARY);
645 EXPECT_EQ(pointer_events.size(), 0u);
648 TEST(FlPointerManagerTest, Motion) {
652 g_autoptr(GError)
error =
nullptr;
654 EXPECT_EQ(
error,
nullptr);
656 std::vector<FlutterPointerEvent> pointer_events;
659 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
660 size_t events_count) {
661 for (
size_t i = 0;
i < events_count;
i++) {
662 pointer_events.push_back(events[
i]);
670 kFlutterPointerDeviceKindMouse, 1.0, 2.0);
672 kFlutterPointerDeviceKindMouse, 3.0, 4.0);
674 kFlutterPointerDeviceKindMouse, 5.0, 6.0);
676 EXPECT_EQ(pointer_events.size(), 4u);
679 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
680 EXPECT_EQ(pointer_events[1].x, 1.0);
681 EXPECT_EQ(pointer_events[1].y, 2.0);
682 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
683 EXPECT_EQ(pointer_events[1].buttons, 0);
684 EXPECT_EQ(pointer_events[1].view_id, 42);
685 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
686 EXPECT_EQ(pointer_events[2].x, 3.0);
687 EXPECT_EQ(pointer_events[2].y, 4.0);
688 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
689 EXPECT_EQ(pointer_events[2].buttons, 0);
690 EXPECT_EQ(pointer_events[2].view_id, 42);
691 EXPECT_EQ(pointer_events[3].timestamp, 1236000u);
692 EXPECT_EQ(pointer_events[3].x, 5.0);
693 EXPECT_EQ(pointer_events[3].y, 6.0);
694 EXPECT_EQ(pointer_events[3].device_kind, kFlutterPointerDeviceKindMouse);
695 EXPECT_EQ(pointer_events[3].buttons, 0);
696 EXPECT_EQ(pointer_events[3].view_id, 42);
699 TEST(FlPointerManagerTest, Drag) {
703 g_autoptr(GError)
error =
nullptr;
705 EXPECT_EQ(
error,
nullptr);
707 std::vector<FlutterPointerEvent> pointer_events;
710 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
711 size_t events_count) {
712 for (
size_t i = 0;
i < events_count;
i++) {
713 pointer_events.push_back(events[
i]);
721 kFlutterPointerDeviceKindMouse, 1.0, 2.0);
723 kFlutterPointerDeviceKindMouse, 3.0,
724 4.0, GDK_BUTTON_PRIMARY);
726 kFlutterPointerDeviceKindMouse, 5.0, 6.0);
728 kFlutterPointerDeviceKindMouse, 7.0,
729 8.0, GDK_BUTTON_PRIMARY);
731 kFlutterPointerDeviceKindMouse, 9.0, 10.0);
733 EXPECT_EQ(pointer_events.size(), 6u);
736 EXPECT_EQ(pointer_events[1].timestamp, 1234000u);
737 EXPECT_EQ(pointer_events[1].x, 1.0);
738 EXPECT_EQ(pointer_events[1].y, 2.0);
739 EXPECT_EQ(pointer_events[1].buttons, 0);
740 EXPECT_EQ(pointer_events[1].view_id, 42);
741 EXPECT_EQ(pointer_events[2].timestamp, 1235000u);
742 EXPECT_EQ(pointer_events[2].x, 3.0);
743 EXPECT_EQ(pointer_events[2].y, 4.0);
744 EXPECT_EQ(pointer_events[2].buttons, kFlutterPointerButtonMousePrimary);
745 EXPECT_EQ(pointer_events[2].view_id, 42);
746 EXPECT_EQ(pointer_events[3].timestamp, 1236000u);
747 EXPECT_EQ(pointer_events[3].x, 5.0);
748 EXPECT_EQ(pointer_events[3].y, 6.0);
749 EXPECT_EQ(pointer_events[3].buttons, kFlutterPointerButtonMousePrimary);
750 EXPECT_EQ(pointer_events[3].view_id, 42);
751 EXPECT_EQ(pointer_events[4].timestamp, 1237000u);
752 EXPECT_EQ(pointer_events[4].x, 7.0);
753 EXPECT_EQ(pointer_events[4].y, 8.0);
754 EXPECT_EQ(pointer_events[4].buttons, 0);
755 EXPECT_EQ(pointer_events[4].view_id, 42);
756 EXPECT_EQ(pointer_events[5].timestamp, 1238000u);
757 EXPECT_EQ(pointer_events[5].x, 9.0);
758 EXPECT_EQ(pointer_events[5].y, 10.0);
759 EXPECT_EQ(pointer_events[5].buttons, 0);
760 EXPECT_EQ(pointer_events[5].view_id, 42);
763 TEST(FlPointerManagerTest, DeviceKind) {
767 g_autoptr(GError)
error =
nullptr;
769 EXPECT_EQ(
error,
nullptr);
771 std::vector<FlutterPointerEvent> pointer_events;
774 ([&pointer_events](
auto engine,
const FlutterPointerEvent* events,
775 size_t events_count) {
776 for (
size_t i = 0;
i < events_count;
i++) {
777 pointer_events.push_back(events[
i]);
785 kFlutterPointerDeviceKindTrackpad, 1.0, 2.0);
787 kFlutterPointerDeviceKindTrackpad, 1.0,
788 2.0, GDK_BUTTON_PRIMARY);
790 kFlutterPointerDeviceKindTrackpad, 3.0, 4.0);
792 kFlutterPointerDeviceKindTrackpad,
793 3.0, 4.0, GDK_BUTTON_PRIMARY);
795 kFlutterPointerDeviceKindTrackpad, 3.0, 4.0);
797 EXPECT_EQ(pointer_events.size(), 5u);
799 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindTrackpad);
800 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindTrackpad);
801 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindTrackpad);
802 EXPECT_EQ(pointer_events[3].device_kind, kFlutterPointerDeviceKindTrackpad);
803 EXPECT_EQ(pointer_events[4].device_kind, kFlutterPointerDeviceKindTrackpad);