Flutter Engine
pointer_data_packet_converter_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/lib/ui/window/pointer_data_packet_converter.h"
6 
7 #include <cstring>
8 
9 #include "gtest/gtest.h"
10 
11 namespace flutter {
12 namespace testing {
13 
15  PointerData::Change change,
16  int64_t device,
17  double dx,
18  double dy,
19  int64_t buttons) {
20  data.time_stamp = 0;
21  data.change = change;
24  data.device = device;
25  data.pointer_identifier = 0;
26  data.physical_x = dx;
27  data.physical_y = dy;
28  data.physical_delta_x = 0.0;
29  data.physical_delta_y = 0.0;
30  data.buttons = buttons;
31  data.obscured = 0;
32  data.synthesized = 0;
33  data.pressure = 0.0;
34  data.pressure_min = 0.0;
35  data.pressure_max = 0.0;
36  data.distance = 0.0;
37  data.distance_max = 0.0;
38  data.size = 0.0;
39  data.radius_major = 0.0;
40  data.radius_minor = 0.0;
41  data.radius_min = 0.0;
42  data.radius_max = 0.0;
43  data.orientation = 0.0;
44  data.tilt = 0.0;
45  data.platformData = 0;
46  data.scroll_delta_x = 0.0;
47  data.scroll_delta_y = 0.0;
48 }
49 
51  PointerData::Change change,
52  PointerData::SignalKind signal_kind,
53  int64_t device,
54  double dx,
55  double dy,
56  double scroll_delta_x,
57  double scroll_delta_y,
58  int64_t buttons) {
59  data.time_stamp = 0;
60  data.change = change;
62  data.signal_kind = signal_kind;
63  data.device = device;
64  data.pointer_identifier = 0;
65  data.physical_x = dx;
66  data.physical_y = dy;
67  data.physical_delta_x = 0.0;
68  data.physical_delta_y = 0.0;
69  data.buttons = buttons;
70  data.obscured = 0;
71  data.synthesized = 0;
72  data.pressure = 0.0;
73  data.pressure_min = 0.0;
74  data.pressure_max = 0.0;
75  data.distance = 0.0;
76  data.distance_max = 0.0;
77  data.size = 0.0;
78  data.radius_major = 0.0;
79  data.radius_minor = 0.0;
80  data.radius_min = 0.0;
81  data.radius_max = 0.0;
82  data.orientation = 0.0;
83  data.tilt = 0.0;
84  data.platformData = 0;
85  data.scroll_delta_x = scroll_delta_x;
86  data.scroll_delta_y = scroll_delta_y;
87 }
88 
89 void UnpackPointerPacket(std::vector<PointerData>& output, // NOLINT
90  std::unique_ptr<PointerDataPacket> packet) {
91  size_t kBytesPerPointerData = kPointerDataFieldCount * kBytesPerField;
92  auto buffer = packet->data();
93  size_t buffer_length = buffer.size();
94 
95  for (size_t i = 0; i < buffer_length / kBytesPerPointerData; i++) {
96  PointerData pointer_data;
97  memcpy(&pointer_data, &buffer[i * kBytesPerPointerData],
98  sizeof(PointerData));
99  output.push_back(pointer_data);
100  }
101  packet.reset();
102 }
103 
104 TEST(PointerDataPacketConverterTest, CanConvetPointerDataPacket) {
105  PointerDataPacketConverter converter;
106  auto packet = std::make_unique<PointerDataPacket>(6);
107  PointerData data;
109  packet->SetPointerData(0, data);
111  packet->SetPointerData(1, data);
113  packet->SetPointerData(2, data);
115  packet->SetPointerData(3, data);
117  packet->SetPointerData(4, data);
119  0);
120  packet->SetPointerData(5, data);
121  auto converted_packet = converter.Convert(std::move(packet));
122 
123  std::vector<PointerData> result;
124  UnpackPointerPacket(result, std::move(converted_packet));
125 
126  ASSERT_EQ(result.size(), (size_t)6);
127  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
128  ASSERT_EQ(result[0].synthesized, 0);
129 
130  ASSERT_EQ(result[1].change, PointerData::Change::kHover);
131  ASSERT_EQ(result[1].synthesized, 0);
132  ASSERT_EQ(result[1].physical_delta_x, 3.0);
133  ASSERT_EQ(result[1].physical_delta_y, 0.0);
134 
135  ASSERT_EQ(result[2].change, PointerData::Change::kDown);
136  ASSERT_EQ(result[2].pointer_identifier, 1);
137  ASSERT_EQ(result[2].synthesized, 0);
138 
139  ASSERT_EQ(result[3].change, PointerData::Change::kMove);
140  ASSERT_EQ(result[3].pointer_identifier, 1);
141  ASSERT_EQ(result[3].synthesized, 0);
142  ASSERT_EQ(result[3].physical_delta_x, 0.0);
143  ASSERT_EQ(result[3].physical_delta_y, 4.0);
144 
145  ASSERT_EQ(result[4].change, PointerData::Change::kUp);
146  ASSERT_EQ(result[4].pointer_identifier, 1);
147  ASSERT_EQ(result[4].synthesized, 0);
148 
149  ASSERT_EQ(result[5].change, PointerData::Change::kRemove);
150  ASSERT_EQ(result[5].synthesized, 0);
151 }
152 
153 TEST(PointerDataPacketConverterTest, CanSynthesizeDownAndUp) {
154  PointerDataPacketConverter converter;
155  auto packet = std::make_unique<PointerDataPacket>(4);
156  PointerData data;
158  packet->SetPointerData(0, data);
160  packet->SetPointerData(1, data);
162  packet->SetPointerData(2, data);
164  0);
165  packet->SetPointerData(3, data);
166  auto converted_packet = converter.Convert(std::move(packet));
167 
168  std::vector<PointerData> result;
169  UnpackPointerPacket(result, std::move(converted_packet));
170 
171  ASSERT_EQ(result.size(), (size_t)6);
172  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
173  ASSERT_EQ(result[0].synthesized, 0);
174 
175  // A hover should be synthesized.
176  ASSERT_EQ(result[1].change, PointerData::Change::kHover);
177  ASSERT_EQ(result[1].synthesized, 1);
178  ASSERT_EQ(result[1].physical_delta_x, 3.0);
179  ASSERT_EQ(result[1].physical_delta_y, 0.0);
180  ASSERT_EQ(result[1].buttons, 0);
181 
182  ASSERT_EQ(result[2].change, PointerData::Change::kDown);
183  ASSERT_EQ(result[2].pointer_identifier, 1);
184  ASSERT_EQ(result[2].synthesized, 0);
185  ASSERT_EQ(result[2].buttons, 1);
186 
187  // A move should be synthesized.
188  ASSERT_EQ(result[3].change, PointerData::Change::kMove);
189  ASSERT_EQ(result[3].pointer_identifier, 1);
190  ASSERT_EQ(result[3].synthesized, 1);
191  ASSERT_EQ(result[3].physical_delta_x, 0.0);
192  ASSERT_EQ(result[3].physical_delta_y, 4.0);
193  ASSERT_EQ(result[3].buttons, 1);
194 
195  ASSERT_EQ(result[4].change, PointerData::Change::kUp);
196  ASSERT_EQ(result[4].pointer_identifier, 1);
197  ASSERT_EQ(result[4].synthesized, 0);
198  ASSERT_EQ(result[4].buttons, 0);
199 
200  ASSERT_EQ(result[5].change, PointerData::Change::kRemove);
201  ASSERT_EQ(result[5].synthesized, 0);
202 }
203 
204 TEST(PointerDataPacketConverterTest, CanUpdatePointerIdentifier) {
205  PointerDataPacketConverter converter;
206  auto packet = std::make_unique<PointerDataPacket>(7);
207  PointerData data;
209  packet->SetPointerData(0, data);
211  packet->SetPointerData(1, data);
213  packet->SetPointerData(2, data);
215  packet->SetPointerData(3, data);
217  packet->SetPointerData(4, data);
219  packet->SetPointerData(5, data);
221  0);
222  packet->SetPointerData(6, data);
223  auto converted_packet = converter.Convert(std::move(packet));
224 
225  std::vector<PointerData> result;
226  UnpackPointerPacket(result, std::move(converted_packet));
227 
228  ASSERT_EQ(result.size(), (size_t)7);
229  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
230  ASSERT_EQ(result[0].synthesized, 0);
231 
232  ASSERT_EQ(result[1].change, PointerData::Change::kDown);
233  ASSERT_EQ(result[1].pointer_identifier, 1);
234  ASSERT_EQ(result[1].synthesized, 0);
235 
236  ASSERT_EQ(result[2].change, PointerData::Change::kUp);
237  ASSERT_EQ(result[2].pointer_identifier, 1);
238  ASSERT_EQ(result[2].synthesized, 0);
239 
240  // Pointer count increase to 2.
241  ASSERT_EQ(result[3].change, PointerData::Change::kDown);
242  ASSERT_EQ(result[3].pointer_identifier, 2);
243  ASSERT_EQ(result[3].synthesized, 0);
244 
245  ASSERT_EQ(result[4].change, PointerData::Change::kMove);
246  ASSERT_EQ(result[4].pointer_identifier, 2);
247  ASSERT_EQ(result[4].synthesized, 0);
248  ASSERT_EQ(result[4].physical_delta_x, 3.0);
249  ASSERT_EQ(result[4].physical_delta_y, 0.0);
250 
251  ASSERT_EQ(result[5].change, PointerData::Change::kUp);
252  ASSERT_EQ(result[5].pointer_identifier, 2);
253  ASSERT_EQ(result[5].synthesized, 0);
254 
255  ASSERT_EQ(result[6].change, PointerData::Change::kRemove);
256  ASSERT_EQ(result[6].synthesized, 0);
257 }
258 
259 TEST(PointerDataPacketConverterTest, AlwaysForwardMoveEvent) {
260  PointerDataPacketConverter converter;
261  auto packet = std::make_unique<PointerDataPacket>(4);
262  PointerData data;
264  packet->SetPointerData(0, data);
266  packet->SetPointerData(1, data);
267  // Creates a move event without a location change.
269  packet->SetPointerData(2, data);
271  packet->SetPointerData(3, data);
272 
273  auto converted_packet = converter.Convert(std::move(packet));
274 
275  std::vector<PointerData> result;
276  UnpackPointerPacket(result, std::move(converted_packet));
277 
278  ASSERT_EQ(result.size(), (size_t)4);
279  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
280  ASSERT_EQ(result[0].synthesized, 0);
281 
282  ASSERT_EQ(result[1].change, PointerData::Change::kDown);
283  ASSERT_EQ(result[1].pointer_identifier, 1);
284  ASSERT_EQ(result[1].synthesized, 0);
285 
286  // Does not filter out the move event.
287  ASSERT_EQ(result[2].change, PointerData::Change::kMove);
288  ASSERT_EQ(result[2].pointer_identifier, 1);
289  ASSERT_EQ(result[2].synthesized, 0);
290 
291  ASSERT_EQ(result[3].change, PointerData::Change::kUp);
292  ASSERT_EQ(result[3].pointer_identifier, 1);
293  ASSERT_EQ(result[3].synthesized, 0);
294 }
295 
296 TEST(PointerDataPacketConverterTest, CanWorkWithDifferentDevices) {
297  PointerDataPacketConverter converter;
298  auto packet = std::make_unique<PointerDataPacket>(12);
299  PointerData data;
301  packet->SetPointerData(0, data);
303  packet->SetPointerData(1, data);
305  packet->SetPointerData(2, data);
307  packet->SetPointerData(3, data);
309  packet->SetPointerData(4, data);
311  packet->SetPointerData(5, data);
313  packet->SetPointerData(6, data);
315  packet->SetPointerData(7, data);
317  packet->SetPointerData(8, data);
319  packet->SetPointerData(9, data);
321  0);
322  packet->SetPointerData(10, data);
324  0);
325  packet->SetPointerData(11, data);
326  auto converted_packet = converter.Convert(std::move(packet));
327 
328  std::vector<PointerData> result;
329  UnpackPointerPacket(result, std::move(converted_packet));
330 
331  ASSERT_EQ(result.size(), (size_t)12);
332  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
333  ASSERT_EQ(result[0].device, 0);
334  ASSERT_EQ(result[0].synthesized, 0);
335 
336  ASSERT_EQ(result[1].change, PointerData::Change::kDown);
337  ASSERT_EQ(result[1].device, 0);
338  ASSERT_EQ(result[1].pointer_identifier, 1);
339  ASSERT_EQ(result[1].synthesized, 0);
340 
341  ASSERT_EQ(result[2].change, PointerData::Change::kAdd);
342  ASSERT_EQ(result[2].device, 1);
343  ASSERT_EQ(result[2].synthesized, 0);
344 
345  ASSERT_EQ(result[3].change, PointerData::Change::kDown);
346  ASSERT_EQ(result[3].device, 1);
347  ASSERT_EQ(result[3].pointer_identifier, 2);
348  ASSERT_EQ(result[3].synthesized, 0);
349 
350  ASSERT_EQ(result[4].change, PointerData::Change::kUp);
351  ASSERT_EQ(result[4].device, 0);
352  ASSERT_EQ(result[4].pointer_identifier, 1);
353  ASSERT_EQ(result[4].synthesized, 0);
354 
355  ASSERT_EQ(result[5].change, PointerData::Change::kDown);
356  ASSERT_EQ(result[5].device, 0);
357  ASSERT_EQ(result[5].pointer_identifier, 3);
358  ASSERT_EQ(result[5].synthesized, 0);
359 
360  ASSERT_EQ(result[6].change, PointerData::Change::kMove);
361  ASSERT_EQ(result[6].device, 1);
362  ASSERT_EQ(result[6].pointer_identifier, 2);
363  ASSERT_EQ(result[6].synthesized, 0);
364  ASSERT_EQ(result[6].physical_delta_x, 0.0);
365  ASSERT_EQ(result[6].physical_delta_y, 4.0);
366 
367  ASSERT_EQ(result[7].change, PointerData::Change::kMove);
368  ASSERT_EQ(result[7].device, 0);
369  ASSERT_EQ(result[7].pointer_identifier, 3);
370  ASSERT_EQ(result[7].synthesized, 0);
371  ASSERT_EQ(result[7].physical_delta_x, 3.0);
372  ASSERT_EQ(result[7].physical_delta_y, 0.0);
373 
374  ASSERT_EQ(result[8].change, PointerData::Change::kUp);
375  ASSERT_EQ(result[8].device, 1);
376  ASSERT_EQ(result[8].pointer_identifier, 2);
377  ASSERT_EQ(result[8].synthesized, 0);
378 
379  ASSERT_EQ(result[9].change, PointerData::Change::kUp);
380  ASSERT_EQ(result[9].device, 0);
381  ASSERT_EQ(result[9].pointer_identifier, 3);
382  ASSERT_EQ(result[9].synthesized, 0);
383 
384  ASSERT_EQ(result[10].change, PointerData::Change::kRemove);
385  ASSERT_EQ(result[10].device, 0);
386  ASSERT_EQ(result[10].synthesized, 0);
387 
388  ASSERT_EQ(result[11].change, PointerData::Change::kRemove);
389  ASSERT_EQ(result[11].device, 1);
390  ASSERT_EQ(result[11].synthesized, 0);
391 }
392 
393 TEST(PointerDataPacketConverterTest, CanSynthesizeAdd) {
394  PointerDataPacketConverter converter;
395  auto packet = std::make_unique<PointerDataPacket>(2);
396  PointerData data;
398  1);
399  packet->SetPointerData(0, data);
401  packet->SetPointerData(1, data);
402  auto converted_packet = converter.Convert(std::move(packet));
403 
404  std::vector<PointerData> result;
405  UnpackPointerPacket(result, std::move(converted_packet));
406 
407  ASSERT_EQ(result.size(), (size_t)4);
408  // A add should be synthesized.
409  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
410  ASSERT_EQ(result[0].physical_x, 330.0);
411  ASSERT_EQ(result[0].physical_y, 450.0);
412  ASSERT_EQ(result[0].synthesized, 1);
413  ASSERT_EQ(result[0].buttons, 0);
414 
415  ASSERT_EQ(result[1].change, PointerData::Change::kDown);
416  ASSERT_EQ(result[1].physical_x, 330.0);
417  ASSERT_EQ(result[1].physical_y, 450.0);
418  ASSERT_EQ(result[1].synthesized, 0);
419  ASSERT_EQ(result[1].buttons, 1);
420 
421  // A move should be synthesized.
422  ASSERT_EQ(result[2].change, PointerData::Change::kMove);
423  ASSERT_EQ(result[2].physical_delta_x, -330.0);
424  ASSERT_EQ(result[2].physical_delta_y, -450.0);
425  ASSERT_EQ(result[2].physical_x, 0.0);
426  ASSERT_EQ(result[2].physical_y, 0.0);
427  ASSERT_EQ(result[2].synthesized, 1);
428  ASSERT_EQ(result[2].buttons, 1);
429 
430  ASSERT_EQ(result[3].change, PointerData::Change::kUp);
431  ASSERT_EQ(result[3].physical_x, 0.0);
432  ASSERT_EQ(result[3].physical_y, 0.0);
433  ASSERT_EQ(result[3].synthesized, 0);
434  ASSERT_EQ(result[3].buttons, 0);
435 }
436 
437 TEST(PointerDataPacketConverterTest, CanHandleThreeFingerGesture) {
438  // Regression test https://github.com/flutter/flutter/issues/20517.
439  PointerDataPacketConverter converter;
440  PointerData data;
441  std::vector<PointerData> result;
442  // First finger down.
443  auto packet = std::make_unique<PointerDataPacket>(1);
445  packet->SetPointerData(0, data);
446  auto converted_packet = converter.Convert(std::move(packet));
447  UnpackPointerPacket(result, std::move(converted_packet));
448  // Second finger down.
449  packet = std::make_unique<PointerDataPacket>(1);
451  1);
452  packet->SetPointerData(0, data);
453  converted_packet = converter.Convert(std::move(packet));
454  UnpackPointerPacket(result, std::move(converted_packet));
455  // Triggers three cancels.
456  packet = std::make_unique<PointerDataPacket>(3);
458  0);
459  packet->SetPointerData(0, data);
461  0);
462  packet->SetPointerData(1, data);
464  0);
465  packet->SetPointerData(2, data);
466  converted_packet = converter.Convert(std::move(packet));
467  UnpackPointerPacket(result, std::move(converted_packet));
468 
469  ASSERT_EQ(result.size(), (size_t)6);
470  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
471  ASSERT_EQ(result[0].device, 0);
472  ASSERT_EQ(result[0].physical_x, 0.0);
473  ASSERT_EQ(result[0].physical_y, 0.0);
474  ASSERT_EQ(result[0].synthesized, 1);
475  ASSERT_EQ(result[0].buttons, 0);
476 
477  ASSERT_EQ(result[1].change, PointerData::Change::kDown);
478  ASSERT_EQ(result[1].device, 0);
479  ASSERT_EQ(result[1].physical_x, 0.0);
480  ASSERT_EQ(result[1].physical_y, 0.0);
481  ASSERT_EQ(result[1].synthesized, 0);
482  ASSERT_EQ(result[1].buttons, 1);
483 
484  ASSERT_EQ(result[2].change, PointerData::Change::kAdd);
485  ASSERT_EQ(result[2].device, 1);
486  ASSERT_EQ(result[2].physical_x, 33.0);
487  ASSERT_EQ(result[2].physical_y, 44.0);
488  ASSERT_EQ(result[2].synthesized, 1);
489  ASSERT_EQ(result[2].buttons, 0);
490 
491  ASSERT_EQ(result[3].change, PointerData::Change::kDown);
492  ASSERT_EQ(result[3].device, 1);
493  ASSERT_EQ(result[3].physical_x, 33.0);
494  ASSERT_EQ(result[3].physical_y, 44.0);
495  ASSERT_EQ(result[3].synthesized, 0);
496  ASSERT_EQ(result[3].buttons, 1);
497 
498  ASSERT_EQ(result[4].change, PointerData::Change::kCancel);
499  ASSERT_EQ(result[4].device, 1);
500  ASSERT_EQ(result[4].physical_x, 33.0);
501  ASSERT_EQ(result[4].physical_y, 44.0);
502  ASSERT_EQ(result[4].synthesized, 0);
503 
504  ASSERT_EQ(result[5].change, PointerData::Change::kCancel);
505  ASSERT_EQ(result[5].device, 0);
506  ASSERT_EQ(result[5].physical_x, 0.0);
507  ASSERT_EQ(result[5].physical_y, 0.0);
508  ASSERT_EQ(result[5].synthesized, 0);
509  // Third cancel should be dropped
510 }
511 
512 TEST(PointerDataPacketConverterTest, CanConvetScroll) {
513  PointerDataPacketConverter converter;
514  auto packet = std::make_unique<PointerDataPacket>(5);
515  PointerData data;
517  PointerData::SignalKind::kNone, 0, 0.0, 0.0,
518  0.0, 0.0, 0);
519  packet->SetPointerData(0, data);
521  PointerData::SignalKind::kNone, 1, 0.0, 0.0,
522  0.0, 0.0, 0);
523  packet->SetPointerData(1, data);
525  PointerData::SignalKind::kNone, 1, 0.0, 0.0,
526  0.0, 0.0, 1);
527  packet->SetPointerData(2, data);
530  34.0, 30.0, 0.0, 0);
531  packet->SetPointerData(3, data);
534  49.0, 50.0, 0.0, 0);
535  packet->SetPointerData(4, data);
536  auto converted_packet = converter.Convert(std::move(packet));
537 
538  std::vector<PointerData> result;
539  UnpackPointerPacket(result, std::move(converted_packet));
540 
541  ASSERT_EQ(result.size(), (size_t)7);
542  ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
543  ASSERT_EQ(result[0].signal_kind, PointerData::SignalKind::kNone);
544  ASSERT_EQ(result[0].device, 0);
545  ASSERT_EQ(result[0].physical_x, 0.0);
546  ASSERT_EQ(result[0].physical_y, 0.0);
547  ASSERT_EQ(result[0].synthesized, 0);
548 
549  ASSERT_EQ(result[1].change, PointerData::Change::kAdd);
550  ASSERT_EQ(result[1].signal_kind, PointerData::SignalKind::kNone);
551  ASSERT_EQ(result[1].device, 1);
552  ASSERT_EQ(result[1].physical_x, 0.0);
553  ASSERT_EQ(result[1].physical_y, 0.0);
554  ASSERT_EQ(result[1].synthesized, 0);
555 
556  ASSERT_EQ(result[2].change, PointerData::Change::kDown);
557  ASSERT_EQ(result[2].signal_kind, PointerData::SignalKind::kNone);
558  ASSERT_EQ(result[2].device, 1);
559  ASSERT_EQ(result[2].physical_x, 0.0);
560  ASSERT_EQ(result[2].physical_y, 0.0);
561  ASSERT_EQ(result[2].synthesized, 0);
562 
563  // Converter will synthesize a hover to position for device 0.
564  ASSERT_EQ(result[3].change, PointerData::Change::kHover);
565  ASSERT_EQ(result[3].signal_kind, PointerData::SignalKind::kNone);
566  ASSERT_EQ(result[3].device, 0);
567  ASSERT_EQ(result[3].physical_x, 34.0);
568  ASSERT_EQ(result[3].physical_y, 34.0);
569  ASSERT_EQ(result[3].physical_delta_x, 34.0);
570  ASSERT_EQ(result[3].physical_delta_y, 34.0);
571  ASSERT_EQ(result[3].buttons, 0);
572  ASSERT_EQ(result[3].synthesized, 1);
573 
574  ASSERT_EQ(result[4].change, PointerData::Change::kHover);
575  ASSERT_EQ(result[4].signal_kind, PointerData::SignalKind::kScroll);
576  ASSERT_EQ(result[4].device, 0);
577  ASSERT_EQ(result[4].physical_x, 34.0);
578  ASSERT_EQ(result[4].physical_y, 34.0);
579  ASSERT_EQ(result[4].scroll_delta_x, 30.0);
580  ASSERT_EQ(result[4].scroll_delta_y, 0.0);
581 
582  // Converter will synthesize a move to position for device 1.
583  ASSERT_EQ(result[5].change, PointerData::Change::kMove);
584  ASSERT_EQ(result[5].signal_kind, PointerData::SignalKind::kNone);
585  ASSERT_EQ(result[5].device, 1);
586  ASSERT_EQ(result[5].physical_x, 49.0);
587  ASSERT_EQ(result[5].physical_y, 49.0);
588  ASSERT_EQ(result[5].physical_delta_x, 49.0);
589  ASSERT_EQ(result[5].physical_delta_y, 49.0);
590  ASSERT_EQ(result[5].buttons, 1);
591  ASSERT_EQ(result[5].synthesized, 1);
592 
593  ASSERT_EQ(result[6].change, PointerData::Change::kHover);
594  ASSERT_EQ(result[6].signal_kind, PointerData::SignalKind::kScroll);
595  ASSERT_EQ(result[6].device, 1);
596  ASSERT_EQ(result[6].physical_x, 49.0);
597  ASSERT_EQ(result[6].physical_y, 49.0);
598  ASSERT_EQ(result[6].scroll_delta_x, 50.0);
599  ASSERT_EQ(result[6].scroll_delta_y, 0.0);
600 }
601 
602 } // namespace testing
603 } // namespace flutter
static constexpr int kBytesPerField
Definition: pointer_data.h:14
static constexpr int kPointerDataFieldCount
Definition: pointer_data.h:13
SignalKind signal_kind
Definition: pointer_data.h:65
int64_t pointer_identifier
Definition: pointer_data.h:67
std::unique_ptr< PointerDataPacket > Convert(std::unique_ptr< PointerDataPacket > packet)
Converts pointer data packet into a form that framework understands. The raw pointer data packet from...
GAsyncResult * result
void CreateSimulatedMousePointerData(PointerData &data, PointerData::Change change, PointerData::SignalKind signal_kind, int64_t device, double dx, double dy, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
void CreateSimulatedPointerData(PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, int64_t buttons)
void UnpackPointerPacket(std::vector< PointerData > &output, std::unique_ptr< PointerDataPacket > packet)
static const uint8_t buffer[]
TEST(DisplayListCanvas, DrawPaint)