| Flutter Linux Embedder |

Classes | Functions
fl_scrolling_manager_test.cc File Reference
`#include "flutter/shell/platform/linux/fl_scrolling_manager.h"`
`#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include <cstring>`
`#include <vector>`
`#include "gtest/gtest.h"`

Go to the source code of this file.

## Classes
struct | _FakeGdkDevice

## Functions
GdkDevice * | makeFakeDevice (GdkInputSource source)
| TEST (FlScrollingManagerTest, DiscreteDirectional)
| TEST (FlScrollingManagerTest, DiscreteScrolling)
| TEST (FlScrollingManagerTest, Panning)
| TEST (FlScrollingManagerTest, Zooming)
| TEST (FlScrollingManagerTest, Rotating)
| TEST (FlScrollingManagerTest, SynchronizedZoomingAndRotating)
| TEST (FlScrollingManagerTest, UnsynchronizedZoomingAndRotating)

## Function Documentation

## ◆ makeFakeDevice()

GdkDevice* makeFakeDevice | ( | GdkInputSource | source | ) |

Definition at line 20 of file fl_scrolling_manager_test.cc.

20 {
21 _FakeGdkDevice* device =
22 static_cast<_FakeGdkDevice*>(g_malloc0(sizeof(_FakeGdkDevice)));
23 device->source = source;
24 // Bully the type checker
25 (reinterpret_cast<GTypeInstance*>(device))->g_class =
26 static_cast<GTypeClass*>(g_malloc0(sizeof(GTypeClass)));
27 (reinterpret_cast<GTypeInstance*>(device))->g_class->g_type = GDK_TYPE_DEVICE;
28 return reinterpret_cast<GdkDevice*>(device);
29 }

References _FakeGdkDevice::source.

Referenced by TEST().

## ◆ TEST() [1/7]

TEST | ( | FlScrollingManagerTest | ,
|  | DiscreteDirectional |
| ) |  |

Definition at line 31 of file fl_scrolling_manager_test.cc.

31 {
32 g_autoptr(FlDartProject) project = fl_dart_project_new();
33 g_autoptr(FlEngine) engine = fl_engine_new(project);
34
35 g_autoptr(GError) error = nullptr;
36 EXPECT_TRUE(fl_engine_start(engine, &error));
37 EXPECT_EQ(error, nullptr);
38
39 std::vector<FlutterPointerEvent> pointer_events;
40 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
41 SendPointerEvent,
42 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
43 size_t events_count) {
44 for (size_t i = 0; i < events_count; i++) {
45 pointer_events.push_back(events[i]);
46 }
47
48 return kSuccess;
49 }));
50
51 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
52
53 GdkDevice* mouse = makeFakeDevice(GDK_SOURCE_MOUSE);
54 GdkEventScroll* event =
55 reinterpret_cast<GdkEventScroll*>(gdk_event_new(GDK_SCROLL));
56 event->time = 1;
57 event->x = 4.0;
58 event->y = 8.0;
59 event->device = mouse;
60 event->direction = GDK_SCROLL_UP;
61 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
62 EXPECT_EQ(pointer_events.size(), 1u);
63 EXPECT_EQ(pointer_events[0].x, 4.0);
64 EXPECT_EQ(pointer_events[0].y, 8.0);
65 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
66 EXPECT_EQ(pointer_events[0].timestamp,
67 1000lu); // Milliseconds -> Microseconds
68 EXPECT_EQ(pointer_events[0].scroll_delta_x, 0);
69 EXPECT_EQ(pointer_events[0].scroll_delta_y, 53 * -1.0);
70 event->direction = GDK_SCROLL_DOWN;
71 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
72 EXPECT_EQ(pointer_events.size(), 2u);
73 EXPECT_EQ(pointer_events[1].x, 4.0);
74 EXPECT_EQ(pointer_events[1].y, 8.0);
75 EXPECT_EQ(pointer_events[1].device_kind, kFlutterPointerDeviceKindMouse);
76 EXPECT_EQ(pointer_events[1].timestamp,
77 1000lu); // Milliseconds -> Microseconds
78 EXPECT_EQ(pointer_events[1].scroll_delta_x, 0);
79 EXPECT_EQ(pointer_events[1].scroll_delta_y, 53 * 1.0);
80 event->direction = GDK_SCROLL_LEFT;
81 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
82 EXPECT_EQ(pointer_events.size(), 3u);
83 EXPECT_EQ(pointer_events[2].x, 4.0);
84 EXPECT_EQ(pointer_events[2].y, 8.0);
85 EXPECT_EQ(pointer_events[2].device_kind, kFlutterPointerDeviceKindMouse);
86 EXPECT_EQ(pointer_events[2].timestamp,
87 1000lu); // Milliseconds -> Microseconds
88 EXPECT_EQ(pointer_events[2].scroll_delta_x, 53 * -1.0);
89 EXPECT_EQ(pointer_events[2].scroll_delta_y, 0);
90 event->direction = GDK_SCROLL_RIGHT;
91 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
92 EXPECT_EQ(pointer_events.size(), 4u);
93 EXPECT_EQ(pointer_events[3].x, 4.0);
94 EXPECT_EQ(pointer_events[3].y, 8.0);
95 EXPECT_EQ(pointer_events[3].device_kind, kFlutterPointerDeviceKindMouse);
96 EXPECT_EQ(pointer_events[3].timestamp,
97 1000lu); // Milliseconds -> Microseconds
98 EXPECT_EQ(pointer_events[3].scroll_delta_x, 53 * 1.0);
99 EXPECT_EQ(pointer_events[3].scroll_delta_y, 0);
100 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_scroll_event(), fl_scrolling_manager_new(), i, and makeFakeDevice().

## ◆ TEST() [2/7]

TEST | ( | FlScrollingManagerTest | ,
|  | DiscreteScrolling |
| ) |  |

Definition at line 102 of file fl_scrolling_manager_test.cc.

102 {
103 g_autoptr(FlDartProject) project = fl_dart_project_new();
104 g_autoptr(FlEngine) engine = fl_engine_new(project);
105
106 g_autoptr(GError) error = nullptr;
107 EXPECT_TRUE(fl_engine_start(engine, &error));
108 EXPECT_EQ(error, nullptr);
109
110 std::vector<FlutterPointerEvent> pointer_events;
111 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
112 SendPointerEvent,
113 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
114 size_t events_count) {
115 for (size_t i = 0; i < events_count; i++) {
116 pointer_events.push_back(events[i]);
117 }
118
119 return kSuccess;
120 }));
121
122 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
123
124 GdkDevice* mouse = makeFakeDevice(GDK_SOURCE_MOUSE);
125 GdkEventScroll* event =
126 reinterpret_cast<GdkEventScroll*>(gdk_event_new(GDK_SCROLL));
127 event->time = 1;
128 event->x = 4.0;
129 event->y = 8.0;
130 event->delta_x = 1.0;
131 event->delta_y = 2.0;
132 event->device = mouse;
133 event->direction = GDK_SCROLL_SMOOTH;
134 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
135 EXPECT_EQ(pointer_events.size(), 1u);
136 EXPECT_EQ(pointer_events[0].x, 4.0);
137 EXPECT_EQ(pointer_events[0].y, 8.0);
138 EXPECT_EQ(pointer_events[0].device_kind, kFlutterPointerDeviceKindMouse);
139 EXPECT_EQ(pointer_events[0].timestamp,
140 1000lu); // Milliseconds -> Microseconds
141 EXPECT_EQ(pointer_events[0].scroll_delta_x, 53 * 1.0);
142 EXPECT_EQ(pointer_events[0].scroll_delta_y, 53 * 2.0);
143 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_scroll_event(), fl_scrolling_manager_new(), i, and makeFakeDevice().

## ◆ TEST() [3/7]

TEST | ( | FlScrollingManagerTest | ,
|  | Panning |
| ) |  |

Definition at line 145 of file fl_scrolling_manager_test.cc.

145 {
146 g_autoptr(FlDartProject) project = fl_dart_project_new();
147 g_autoptr(FlEngine) engine = fl_engine_new(project);
148
149 g_autoptr(GError) error = nullptr;
150 EXPECT_TRUE(fl_engine_start(engine, &error));
151 EXPECT_EQ(error, nullptr);
152
153 std::vector<FlutterPointerEvent> pointer_events;
154 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
155 SendPointerEvent,
156 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
157 size_t events_count) {
158 for (size_t i = 0; i < events_count; i++) {
159 pointer_events.push_back(events[i]);
160 }
161
162 return kSuccess;
163 }));
164
165 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
166
167 GdkDevice* touchpad = makeFakeDevice(GDK_SOURCE_TOUCHPAD);
168 GdkEventScroll* event =
169 reinterpret_cast<GdkEventScroll*>(gdk_event_new(GDK_SCROLL));
170 event->time = 1;
171 event->x = 4.0;
172 event->y = 8.0;
173 event->delta_x = 1.0;
174 event->delta_y = 2.0;
175 event->device = touchpad;
176 event->direction = GDK_SCROLL_SMOOTH;
177 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
178 EXPECT_EQ(pointer_events.size(), 2u);
179 EXPECT_EQ(pointer_events[0].x, 4.0);
180 EXPECT_EQ(pointer_events[0].y, 8.0);
181 EXPECT_EQ(pointer_events[0].timestamp,
182 1000lu); // Milliseconds -> Microseconds
183 EXPECT_EQ(pointer_events[0].phase, kPanZoomStart);
184 EXPECT_EQ(pointer_events[1].x, 4.0);
185 EXPECT_EQ(pointer_events[1].y, 8.0);
186 EXPECT_EQ(pointer_events[1].timestamp,
187 1000lu); // Milliseconds -> Microseconds
188 EXPECT_EQ(pointer_events[1].phase, kPanZoomUpdate);
189 EXPECT_EQ(pointer_events[1].pan_x, 53 * -1.0); // directions get swapped
190 EXPECT_EQ(pointer_events[1].pan_y, 53 * -2.0);
191 EXPECT_EQ(pointer_events[1].scale, 1.0);
192 EXPECT_EQ(pointer_events[1].rotation, 0.0);
193 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
194 EXPECT_EQ(pointer_events.size(), 3u);
195 EXPECT_EQ(pointer_events[2].x, 4.0);
196 EXPECT_EQ(pointer_events[2].y, 8.0);
197 EXPECT_EQ(pointer_events[2].timestamp,
198 1000lu); // Milliseconds -> Microseconds
199 EXPECT_EQ(pointer_events[2].phase, kPanZoomUpdate);
200 EXPECT_EQ(pointer_events[2].pan_x, 53 * -2.0); // directions get swapped
201 EXPECT_EQ(pointer_events[2].pan_y, 53 * -4.0);
202 EXPECT_EQ(pointer_events[2].scale, 1.0);
203 EXPECT_EQ(pointer_events[2].rotation, 0.0);
204 event->is_stop = true;
205 fl_scrolling_manager_handle_scroll_event(manager, event, 1.0);
206 EXPECT_EQ(pointer_events.size(), 4u);
207 EXPECT_EQ(pointer_events[3].x, 4.0);
208 EXPECT_EQ(pointer_events[3].y, 8.0);
209 EXPECT_EQ(pointer_events[3].timestamp,
210 1000lu); // Milliseconds -> Microseconds
211 EXPECT_EQ(pointer_events[3].phase, kPanZoomEnd);
212 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_scroll_event(), fl_scrolling_manager_new(), i, and makeFakeDevice().

## ◆ TEST() [4/7]

TEST | ( | FlScrollingManagerTest | ,
|  | Rotating |
| ) |  |

Definition at line 261 of file fl_scrolling_manager_test.cc.

261 {
262 g_autoptr(FlDartProject) project = fl_dart_project_new();
263 g_autoptr(FlEngine) engine = fl_engine_new(project);
264
265 g_autoptr(GError) error = nullptr;
266 EXPECT_TRUE(fl_engine_start(engine, &error));
267 EXPECT_EQ(error, nullptr);
268
269 std::vector<FlutterPointerEvent> pointer_events;
270 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
271 SendPointerEvent,
272 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
273 size_t events_count) {
274 for (size_t i = 0; i < events_count; i++) {
275 pointer_events.push_back(events[i]);
276 }
277
278 return kSuccess;
279 }));
280
281 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
282
283 size_t time_start = g_get_real_time();
284 fl_scrolling_manager_handle_rotation_begin(manager);
285 EXPECT_EQ(pointer_events.size(), 1u);
286 EXPECT_EQ(pointer_events[0].x, 0);
287 EXPECT_EQ(pointer_events[0].y, 0);
288 EXPECT_EQ(pointer_events[0].phase, kPanZoomStart);
289 EXPECT_GE(pointer_events[0].timestamp, time_start);
290 fl_scrolling_manager_handle_rotation_update(manager, 0.5);
291 EXPECT_EQ(pointer_events.size(), 2u);
292 EXPECT_EQ(pointer_events[1].x, 0);
293 EXPECT_EQ(pointer_events[1].y, 0);
294 EXPECT_EQ(pointer_events[1].phase, kPanZoomUpdate);
295 EXPECT_GE(pointer_events[1].timestamp, pointer_events[0].timestamp);
296 EXPECT_EQ(pointer_events[1].pan_x, 0);
297 EXPECT_EQ(pointer_events[1].pan_y, 0);
298 EXPECT_EQ(pointer_events[1].scale, 1.0);
299 EXPECT_EQ(pointer_events[1].rotation, 0.5);
300 fl_scrolling_manager_handle_rotation_end(manager);
301 EXPECT_EQ(pointer_events.size(), 3u);
302 EXPECT_EQ(pointer_events[2].x, 0);
303 EXPECT_EQ(pointer_events[2].y, 0);
304 EXPECT_EQ(pointer_events[2].phase, kPanZoomEnd);
305 EXPECT_GE(pointer_events[2].timestamp, pointer_events[1].timestamp);
306 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_rotation_begin(), fl_scrolling_manager_handle_rotation_end(), fl_scrolling_manager_handle_rotation_update(), fl_scrolling_manager_new(), and i.

## ◆ TEST() [5/7]

TEST | ( | FlScrollingManagerTest | ,
|  | SynchronizedZoomingAndRotating |
| ) |  |

Definition at line 308 of file fl_scrolling_manager_test.cc.

308 {
309 g_autoptr(FlDartProject) project = fl_dart_project_new();
310 g_autoptr(FlEngine) engine = fl_engine_new(project);
311
312 g_autoptr(GError) error = nullptr;
313 EXPECT_TRUE(fl_engine_start(engine, &error));
314 EXPECT_EQ(error, nullptr);
315
316 std::vector<FlutterPointerEvent> pointer_events;
317 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
318 SendPointerEvent,
319 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
320 size_t events_count) {
321 for (size_t i = 0; i < events_count; i++) {
322 pointer_events.push_back(events[i]);
323 }
324
325 return kSuccess;
326 }));
327
328 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
329
330 size_t time_start = g_get_real_time();
331 fl_scrolling_manager_handle_zoom_begin(manager);
332 EXPECT_EQ(pointer_events.size(), 1u);
333 EXPECT_EQ(pointer_events[0].x, 0);
334 EXPECT_EQ(pointer_events[0].y, 0);
335 EXPECT_EQ(pointer_events[0].phase, kPanZoomStart);
336 EXPECT_GE(pointer_events[0].timestamp, time_start);
337 fl_scrolling_manager_handle_zoom_update(manager, 1.1);
338 EXPECT_EQ(pointer_events.size(), 2u);
339 EXPECT_EQ(pointer_events[1].x, 0);
340 EXPECT_EQ(pointer_events[1].y, 0);
341 EXPECT_EQ(pointer_events[1].phase, kPanZoomUpdate);
342 EXPECT_GE(pointer_events[1].timestamp, pointer_events[0].timestamp);
343 EXPECT_EQ(pointer_events[1].pan_x, 0);
344 EXPECT_EQ(pointer_events[1].pan_y, 0);
345 EXPECT_EQ(pointer_events[1].scale, 1.1);
346 EXPECT_EQ(pointer_events[1].rotation, 0);
347 fl_scrolling_manager_handle_rotation_begin(manager);
348 EXPECT_EQ(pointer_events.size(), 2u);
349 fl_scrolling_manager_handle_rotation_update(manager, 0.5);
350 EXPECT_EQ(pointer_events.size(), 3u);
351 EXPECT_EQ(pointer_events[2].x, 0);
352 EXPECT_EQ(pointer_events[2].y, 0);
353 EXPECT_EQ(pointer_events[2].phase, kPanZoomUpdate);
354 EXPECT_GE(pointer_events[2].timestamp, pointer_events[1].timestamp);
355 EXPECT_EQ(pointer_events[2].pan_x, 0);
356 EXPECT_EQ(pointer_events[2].pan_y, 0);
357 EXPECT_EQ(pointer_events[2].scale, 1.1);
358 EXPECT_EQ(pointer_events[2].rotation, 0.5);
359 fl_scrolling_manager_handle_zoom_end(manager);
360 // End event should only be sent after both zoom and rotate complete.
361 EXPECT_EQ(pointer_events.size(), 3u);
362 fl_scrolling_manager_handle_rotation_end(manager);
363 EXPECT_EQ(pointer_events.size(), 4u);
364 EXPECT_EQ(pointer_events[3].x, 0);
365 EXPECT_EQ(pointer_events[3].y, 0);
366 EXPECT_EQ(pointer_events[3].phase, kPanZoomEnd);
367 EXPECT_GE(pointer_events[3].timestamp, pointer_events[2].timestamp);
368 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_rotation_begin(), fl_scrolling_manager_handle_rotation_end(), fl_scrolling_manager_handle_rotation_update(), fl_scrolling_manager_handle_zoom_begin(), fl_scrolling_manager_handle_zoom_end(), fl_scrolling_manager_handle_zoom_update(), fl_scrolling_manager_new(), and i.

## ◆ TEST() [6/7]

TEST | ( | FlScrollingManagerTest | ,
|  | UnsynchronizedZoomingAndRotating |
| ) |  |

Definition at line 372 of file fl_scrolling_manager_test.cc.

372 {
373 g_autoptr(FlDartProject) project = fl_dart_project_new();
374 g_autoptr(FlEngine) engine = fl_engine_new(project);
375
376 g_autoptr(GError) error = nullptr;
377 EXPECT_TRUE(fl_engine_start(engine, &error));
378 EXPECT_EQ(error, nullptr);
379
380 std::vector<FlutterPointerEvent> pointer_events;
381 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
382 SendPointerEvent,
383 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
384 size_t events_count) {
385 for (size_t i = 0; i < events_count; i++) {
386 pointer_events.push_back(events[i]);
387 }
388
389 return kSuccess;
390 }));
391
392 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
393
394 size_t time_start = g_get_real_time();
395 fl_scrolling_manager_handle_zoom_begin(manager);
396 EXPECT_EQ(pointer_events.size(), 1u);
397 EXPECT_EQ(pointer_events[0].x, 0);
398 EXPECT_EQ(pointer_events[0].y, 0);
399 EXPECT_EQ(pointer_events[0].phase, kPanZoomStart);
400 EXPECT_GE(pointer_events[0].timestamp, time_start);
401 fl_scrolling_manager_handle_zoom_update(manager, 1.1);
402 EXPECT_EQ(pointer_events.size(), 2u);
403 EXPECT_EQ(pointer_events[1].x, 0);
404 EXPECT_EQ(pointer_events[1].y, 0);
405 EXPECT_EQ(pointer_events[1].phase, kPanZoomUpdate);
406 EXPECT_GE(pointer_events[1].timestamp, pointer_events[0].timestamp);
407 EXPECT_EQ(pointer_events[1].pan_x, 0);
408 EXPECT_EQ(pointer_events[1].pan_y, 0);
409 EXPECT_EQ(pointer_events[1].scale, 1.1);
410 EXPECT_EQ(pointer_events[1].rotation, 0);
411 fl_scrolling_manager_handle_rotation_begin(manager);
412 EXPECT_EQ(pointer_events.size(), 2u);
413 fl_scrolling_manager_handle_rotation_update(manager, 0.5);
414 EXPECT_EQ(pointer_events.size(), 3u);
415 EXPECT_EQ(pointer_events[2].x, 0);
416 EXPECT_EQ(pointer_events[2].y, 0);
417 EXPECT_EQ(pointer_events[2].phase, kPanZoomUpdate);
418 EXPECT_GE(pointer_events[2].timestamp, pointer_events[1].timestamp);
419 EXPECT_EQ(pointer_events[2].pan_x, 0);
420 EXPECT_EQ(pointer_events[2].pan_y, 0);
421 EXPECT_EQ(pointer_events[2].scale, 1.1);
422 EXPECT_EQ(pointer_events[2].rotation, 0.5);
423 fl_scrolling_manager_handle_zoom_end(manager);
424 EXPECT_EQ(pointer_events.size(), 3u);
425 fl_scrolling_manager_handle_rotation_update(manager, 1.0);
426 EXPECT_EQ(pointer_events.size(), 4u);
427 EXPECT_EQ(pointer_events[3].x, 0);
428 EXPECT_EQ(pointer_events[3].y, 0);
429 EXPECT_EQ(pointer_events[3].phase, kPanZoomUpdate);
430 EXPECT_GE(pointer_events[3].timestamp, pointer_events[2].timestamp);
431 EXPECT_EQ(pointer_events[3].pan_x, 0);
432 EXPECT_EQ(pointer_events[3].pan_y, 0);
433 EXPECT_EQ(pointer_events[3].scale, 1.1);
434 EXPECT_EQ(pointer_events[3].rotation, 1.0);
435 fl_scrolling_manager_handle_rotation_end(manager);
436 EXPECT_EQ(pointer_events.size(), 5u);
437 EXPECT_EQ(pointer_events[4].x, 0);
438 EXPECT_EQ(pointer_events[4].y, 0);
439 EXPECT_EQ(pointer_events[4].phase, kPanZoomEnd);
440 EXPECT_GE(pointer_events[4].timestamp, pointer_events[3].timestamp);
441 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_rotation_begin(), fl_scrolling_manager_handle_rotation_end(), fl_scrolling_manager_handle_rotation_update(), fl_scrolling_manager_handle_zoom_begin(), fl_scrolling_manager_handle_zoom_end(), fl_scrolling_manager_handle_zoom_update(), fl_scrolling_manager_new(), and i.

## ◆ TEST() [7/7]

TEST | ( | FlScrollingManagerTest | ,
|  | Zooming |
| ) |  |

Definition at line 214 of file fl_scrolling_manager_test.cc.

214 {
215 g_autoptr(FlDartProject) project = fl_dart_project_new();
216 g_autoptr(FlEngine) engine = fl_engine_new(project);
217
218 g_autoptr(GError) error = nullptr;
219 EXPECT_TRUE(fl_engine_start(engine, &error));
220 EXPECT_EQ(error, nullptr);
221
222 std::vector<FlutterPointerEvent> pointer_events;
223 fl_engine_get_embedder_api(engine)->SendPointerEvent = MOCK_ENGINE_PROC(
224 SendPointerEvent,
225 ([&pointer_events](auto engine, const FlutterPointerEvent* events,
226 size_t events_count) {
227 for (size_t i = 0; i < events_count; i++) {
228 pointer_events.push_back(events[i]);
229 }
230
231 return kSuccess;
232 }));
233
234 g_autoptr(FlScrollingManager) manager = fl_scrolling_manager_new(engine, 0);
235
236 size_t time_start = g_get_real_time();
237 fl_scrolling_manager_handle_zoom_begin(manager);
238 EXPECT_EQ(pointer_events.size(), 1u);
239 EXPECT_EQ(pointer_events[0].x, 0);
240 EXPECT_EQ(pointer_events[0].y, 0);
241 EXPECT_EQ(pointer_events[0].phase, kPanZoomStart);
242 EXPECT_GE(pointer_events[0].timestamp, time_start);
243 fl_scrolling_manager_handle_zoom_update(manager, 1.1);
244 EXPECT_EQ(pointer_events.size(), 2u);
245 EXPECT_EQ(pointer_events[1].x, 0);
246 EXPECT_EQ(pointer_events[1].y, 0);
247 EXPECT_EQ(pointer_events[1].phase, kPanZoomUpdate);
248 EXPECT_GE(pointer_events[1].timestamp, pointer_events[0].timestamp);
249 EXPECT_EQ(pointer_events[1].pan_x, 0);
250 EXPECT_EQ(pointer_events[1].pan_y, 0);
251 EXPECT_EQ(pointer_events[1].scale, 1.1);
252 EXPECT_EQ(pointer_events[1].rotation, 0);
253 fl_scrolling_manager_handle_zoom_end(manager);
254 EXPECT_EQ(pointer_events.size(), 3u);
255 EXPECT_EQ(pointer_events[2].x, 0);
256 EXPECT_EQ(pointer_events[2].y, 0);
257 EXPECT_EQ(pointer_events[2].phase, kPanZoomEnd);
258 EXPECT_GE(pointer_events[2].timestamp, pointer_events[1].timestamp);
259 }

References error, fl_dart_project_new(), fl_engine_get_embedder_api(), fl_engine_new(), fl_engine_start(), fl_scrolling_manager_handle_zoom_begin(), fl_scrolling_manager_handle_zoom_end(), fl_scrolling_manager_handle_zoom_update(), fl_scrolling_manager_new(), and i.

_FakeGdkDevice
Definition: fl_scrolling_manager_test.cc:15
fl_engine_get_embedder_api
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
Definition: fl_engine.cc:661
fl_scrolling_manager_handle_zoom_end
void fl_scrolling_manager_handle_zoom_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:235
fl_scrolling_manager_handle_scroll_event
void fl_scrolling_manager_handle_scroll_event(FlScrollingManager *self, GdkEventScroll *scroll_event, gint scale_factor)
Definition: fl_scrolling_manager.cc:71
i
int i
Definition: fl_socket_accessible.cc:18
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:50
_FakeGdkDevice::source
GdkInputSource source
Definition: fl_scrolling_manager_test.cc:18
fl_scrolling_manager_handle_zoom_update
void fl_scrolling_manager_handle_zoom_update(FlScrollingManager *self, gdouble scale)
Definition: fl_scrolling_manager.cc:220
fl_scrolling_manager_handle_rotation_update
void fl_scrolling_manager_handle_rotation_update(FlScrollingManager *self, gdouble rotation)
Definition: fl_scrolling_manager.cc:171
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_scrolling_manager_handle_rotation_end
void fl_scrolling_manager_handle_rotation_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:186
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:544
fl_scrolling_manager_handle_rotation_begin
void fl_scrolling_manager_handle_rotation_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:153
fl_scrolling_manager_new
FlScrollingManager * fl_scrolling_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_scrolling_manager.cc:47
makeFakeDevice
GdkDevice * makeFakeDevice(GdkInputSource source)
Definition: fl_scrolling_manager_test.cc:20
fl_scrolling_manager_handle_zoom_begin
void fl_scrolling_manager_handle_zoom_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:202