1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/elements"# ] |
2 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
3 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
4 | |
5 | TestCase := Window { |
6 | |
7 | |
8 | width: 500phx; |
9 | height: 500phx; |
10 | no-frame: false; |
11 | |
12 | f := Flickable { |
13 | x: 10phx; |
14 | y: 10phx; |
15 | width: parent.width - 20phx; |
16 | height: parent.height - 20phx; |
17 | viewport_width: 2100phx; |
18 | viewport_height: 2100phx; |
19 | |
20 | flicked => { |
21 | root.flicked += viewport_x/1phx * 100000 + viewport_y/1phx; |
22 | } |
23 | |
24 | inner_ta := TouchArea { |
25 | x: 150phx; |
26 | y: 150phx; |
27 | width: 50phx; |
28 | height: 50phx; |
29 | Rectangle { |
30 | background: parent.pressed ? blue : parent.has_hover ? green : red; |
31 | } |
32 | clicked => { |
33 | root.clicked = mouse_x/1phx * 100000 + mouse_y/1phx; |
34 | } |
35 | } |
36 | |
37 | } |
38 | |
39 | property<length> offset_x: -f.viewport_x; |
40 | property<length> offset_y: -f.viewport_y; |
41 | property<bool> inner_ta_pressed: inner_ta.pressed; |
42 | property<bool> inner_ta_has_hover: inner_ta.has_hover; |
43 | property<int> clicked; |
44 | property <int> flicked; |
45 | } |
46 | |
47 | /* |
48 | |
49 | ```rust |
50 | // Test that basic scrolling works, and that releasing the mouse animates |
51 | use slint::{platform::WindowEvent, platform::PointerEventButton, LogicalPosition}; |
52 | let instance = TestCase::new().unwrap(); |
53 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(300.0, 100.0) }); |
54 | slint_testing::mock_elapsed_time(5000); |
55 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(300.0, 100.0), button: PointerEventButton::Left }); |
56 | assert_eq!(instance.get_offset_x(), 0.); |
57 | assert_eq!(instance.get_offset_y(), 0.); |
58 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(200.0, 50.0) }); |
59 | assert_eq!(instance.get_offset_x(), 100.); |
60 | assert_eq!(instance.get_offset_y(), 50.); |
61 | slint_testing::mock_elapsed_time(200); |
62 | assert_eq!(instance.get_offset_x(), 100.); |
63 | assert_eq!(instance.get_offset_y(), 50.); |
64 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(100.0, 50.0) }); |
65 | assert_eq!(instance.get_offset_x(), 200.); |
66 | assert_eq!(instance.get_offset_y(), 50.); |
67 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(100.0, 50.0), button: PointerEventButton::Left }); |
68 | // Start of the animation, the position is still unchanged |
69 | assert_eq!(instance.get_offset_x(), 200.); |
70 | assert_eq!(instance.get_offset_y(), 50.); |
71 | slint_testing::mock_elapsed_time(50); |
72 | // middle of the animation |
73 | assert!(instance.get_offset_x() > 210.); |
74 | assert!(instance.get_offset_y() > 60.); |
75 | assert!(instance.get_offset_x() < 290.); |
76 | assert!(instance.get_offset_y() < 70.); |
77 | |
78 | slint_testing::mock_elapsed_time(200); |
79 | // end of the animation |
80 | assert_eq!(instance.get_offset_x(), 450.); |
81 | assert_eq!(instance.get_offset_y(), 112.5); |
82 | slint_testing::mock_elapsed_time(50); |
83 | assert_eq!(instance.get_offset_x(), 450.); |
84 | assert_eq!(instance.get_offset_y(), 112.5); |
85 | |
86 | assert!(!instance.get_inner_ta_pressed()); |
87 | assert!(!instance.get_inner_ta_has_hover()); |
88 | assert_eq!(instance.get_clicked(), 0); |
89 | ``` |
90 | |
91 | ```rust |
92 | // Test interaction with inner mouse area |
93 | use slint::{platform::WindowEvent, platform::PointerEventButton, LogicalPosition}; |
94 | let instance = TestCase::new().unwrap(); |
95 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(175.0, 175.0) }); |
96 | assert!(!instance.get_inner_ta_pressed()); |
97 | assert!(instance.get_inner_ta_has_hover()); |
98 | assert_eq!(instance.get_clicked(), 0); |
99 | slint_testing::mock_elapsed_time(5000); |
100 | assert!(!instance.get_inner_ta_pressed()); |
101 | assert!(instance.get_inner_ta_has_hover()); |
102 | assert_eq!(instance.get_clicked(), 0); |
103 | |
104 | // Start a press |
105 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(175.0, 175.0), button: PointerEventButton::Left }); |
106 | //assert!(!instance.get_inner_ta_pressed()); |
107 | assert!(instance.get_inner_ta_has_hover()); |
108 | assert_eq!(instance.get_clicked(), 0); |
109 | // Release almost immediately |
110 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(178.0, 173.0), button: PointerEventButton::Left }); |
111 | assert!(!instance.get_inner_ta_pressed()); |
112 | assert!(instance.get_inner_ta_has_hover()); |
113 | assert_eq!(instance.get_clicked(), 18_00013); |
114 | assert_eq!(instance.get_offset_x(), 0.); |
115 | assert_eq!(instance.get_offset_y(), 0.); |
116 | |
117 | instance.set_clicked(-1); |
118 | |
119 | slint_testing::mock_elapsed_time(1000); |
120 | |
121 | // - Press, move a triny, then release quickly: should click |
122 | // Start a press |
123 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(165.0, 175.0), button: PointerEventButton::Left }); |
124 | assert!(!instance.get_inner_ta_pressed()); |
125 | assert!(instance.get_inner_ta_has_hover()); |
126 | assert_eq!(instance.get_clicked(), -1); |
127 | // make a small move |
128 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(166.0, 174.0) }); |
129 | assert!(!instance.get_inner_ta_pressed()); |
130 | assert!(instance.get_inner_ta_has_hover()); |
131 | slint_testing::mock_elapsed_time(30); |
132 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(167.0, 175.0) }); |
133 | assert!(!instance.get_inner_ta_pressed()); |
134 | // and release |
135 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(165.0, 174.0), button: PointerEventButton::Left }); |
136 | assert!(!instance.get_inner_ta_pressed()); |
137 | assert!(instance.get_inner_ta_has_hover()); |
138 | assert_eq!(instance.get_clicked(), 5_00014); |
139 | assert_eq!(instance.get_offset_x(), 0.); |
140 | assert_eq!(instance.get_offset_y(), 0.); |
141 | |
142 | instance.set_clicked(-1); |
143 | |
144 | // Start a press |
145 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(175.0, 175.0), button: PointerEventButton::Left }); |
146 | assert!(!instance.get_inner_ta_pressed()); |
147 | assert!(instance.get_inner_ta_has_hover()); |
148 | assert_eq!(instance.get_clicked(), -1); |
149 | assert_eq!(instance.get_offset_x(), 0.); |
150 | assert_eq!(instance.get_offset_y(), 0.); |
151 | |
152 | //wait a delay |
153 | slint_testing::mock_elapsed_time(300); |
154 | assert!(instance.get_inner_ta_pressed()); // only now we are pressed |
155 | assert!(instance.get_inner_ta_has_hover()); |
156 | assert_eq!(instance.get_clicked(), -1); |
157 | assert_eq!(instance.get_offset_x(), 0.); |
158 | assert_eq!(instance.get_offset_y(), 0.); |
159 | |
160 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(100.0, 120.0) }); |
161 | assert!(!instance.get_inner_ta_pressed()); // We should no longer be pressed |
162 | // no hover when the flickable is flicking |
163 | assert!(!instance.get_inner_ta_has_hover()); |
164 | assert_eq!(instance.get_clicked(), -1); // not clicked |
165 | assert_eq!(instance.get_offset_x(), 75.); |
166 | assert_eq!(instance.get_offset_y(), 55.); |
167 | |
168 | slint_testing::mock_elapsed_time(10000); |
169 | |
170 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(100.0, 120.0), button: PointerEventButton::Left }); |
171 | assert!(!instance.get_inner_ta_pressed()); |
172 | assert!(instance.get_inner_ta_has_hover()); |
173 | assert_eq!(instance.get_clicked(), -1); // not clicked |
174 | assert_eq!(instance.get_offset_x(), 75.); |
175 | assert_eq!(instance.get_offset_y(), 55.); |
176 | |
177 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(200.0, 50.0) }); |
178 | slint_testing::mock_elapsed_time(1000); |
179 | |
180 | assert!(!instance.get_inner_ta_pressed()); |
181 | assert!(!instance.get_inner_ta_has_hover()); |
182 | assert_eq!(instance.get_clicked(), -1); |
183 | assert!((instance.get_offset_x() - 75.).abs() < 5.); // only small animation on release |
184 | assert!((instance.get_offset_y() - 55.).abs() < 5.); |
185 | |
186 | ``` |
187 | |
188 | ```rust |
189 | // Test wheel events |
190 | use slint::{LogicalPosition, platform::{WindowEvent, Key} }; |
191 | let instance = TestCase::new().unwrap(); |
192 | instance.window().dispatch_event(WindowEvent::PointerScrolled { position: LogicalPosition::new(175.0, 175.0), delta_x: -30.0, delta_y: -50.0 }); |
193 | assert_eq!(instance.get_offset_x(), 30.); |
194 | assert_eq!(instance.get_offset_y(), 50.); |
195 | |
196 | // When shift is pressed, it invert the direction |
197 | // (this test don't work on macos because on macos the backend does the inversion, not the core lib) |
198 | if !cfg!(target_os = "macos") { |
199 | slint_testing::send_keyboard_char(&instance, Key::Shift.into(), true); |
200 | instance.window().dispatch_event(WindowEvent::PointerScrolled { position: LogicalPosition::new(175.0, 175.0), delta_x: 15.0, delta_y: -60.0 }); |
201 | slint_testing::send_keyboard_char(&instance, Key::Shift.into(), false); |
202 | assert_eq!(instance.get_offset_x(), 30. + 60.); |
203 | assert_eq!(instance.get_offset_y(), 50. - 15.); |
204 | } |
205 | ``` |
206 | |
207 | ```rust |
208 | // Test flicked-Callback behaviour |
209 | use slint::{LogicalPosition, platform::{WindowEvent, PointerEventButton} }; |
210 | let instance = TestCase::new().unwrap(); |
211 | assert_eq!(instance.get_flicked(), 0); |
212 | |
213 | // test scrolling behaviour |
214 | instance.window().dispatch_event(WindowEvent::PointerScrolled { position: LogicalPosition::new(175.0, 175.0), delta_x: -30.0, delta_y: -50.0 }); |
215 | dbg!(instance.get_flicked()); |
216 | assert_eq!(instance.get_flicked(), -3000050); //flicked got called after scrolling |
217 | instance.set_flicked(0); |
218 | |
219 | // test dragging bevaviour |
220 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(175.0, 175.0), button: PointerEventButton::Left }); |
221 | slint_testing::mock_elapsed_time(300); |
222 | assert_eq!(instance.get_flicked(), 0); //flicked didn't get called by just pressing |
223 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(100.0, 120.0) }); |
224 | slint_testing::mock_elapsed_time(10000); |
225 | assert_eq!(instance.get_flicked(), -10500105); //flicked got called during drag |
226 | instance.set_flicked(0); |
227 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(100.0, 120.0), button: PointerEventButton::Left }); |
228 | assert_eq!(instance.get_flicked(), -10500105); //flicked got called after drag |
229 | instance.set_flicked(0); |
230 | |
231 | ``` |
232 | */ |
233 | } |
234 | |
235 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
236 | use i_slint_backend_testing as slint_testing; |
237 | slint_testing::init(); |
238 | // Test that basic scrolling works, and that releasing the mouse animates |
239 | use slint::{platform::WindowEvent, platform::PointerEventButton, LogicalPosition}; |
240 | let instance = TestCase::new().unwrap(); |
241 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(300.0, 100.0) }); |
242 | slint_testing::mock_elapsed_time(5000); |
243 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(300.0, 100.0), button: PointerEventButton::Left }); |
244 | assert_eq!(instance.get_offset_x(), 0.); |
245 | assert_eq!(instance.get_offset_y(), 0.); |
246 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(200.0, 50.0) }); |
247 | assert_eq!(instance.get_offset_x(), 100.); |
248 | assert_eq!(instance.get_offset_y(), 50.); |
249 | slint_testing::mock_elapsed_time(200); |
250 | assert_eq!(instance.get_offset_x(), 100.); |
251 | assert_eq!(instance.get_offset_y(), 50.); |
252 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(100.0, 50.0) }); |
253 | assert_eq!(instance.get_offset_x(), 200.); |
254 | assert_eq!(instance.get_offset_y(), 50.); |
255 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(100.0, 50.0), button: PointerEventButton::Left }); |
256 | // Start of the animation, the position is still unchanged |
257 | assert_eq!(instance.get_offset_x(), 200.); |
258 | assert_eq!(instance.get_offset_y(), 50.); |
259 | slint_testing::mock_elapsed_time(50); |
260 | // middle of the animation |
261 | assert!(instance.get_offset_x() > 210.); |
262 | assert!(instance.get_offset_y() > 60.); |
263 | assert!(instance.get_offset_x() < 290.); |
264 | assert!(instance.get_offset_y() < 70.); |
265 | |
266 | slint_testing::mock_elapsed_time(200); |
267 | // end of the animation |
268 | assert_eq!(instance.get_offset_x(), 450.); |
269 | assert_eq!(instance.get_offset_y(), 112.5); |
270 | slint_testing::mock_elapsed_time(50); |
271 | assert_eq!(instance.get_offset_x(), 450.); |
272 | assert_eq!(instance.get_offset_y(), 112.5); |
273 | |
274 | assert!(!instance.get_inner_ta_pressed()); |
275 | assert!(!instance.get_inner_ta_has_hover()); |
276 | assert_eq!(instance.get_clicked(), 0); |
277 | Ok(()) |
278 | } |
279 | #[test ] fn t_1() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
280 | use i_slint_backend_testing as slint_testing; |
281 | slint_testing::init(); |
282 | // Test interaction with inner mouse area |
283 | use slint::{platform::WindowEvent, platform::PointerEventButton, LogicalPosition}; |
284 | let instance = TestCase::new().unwrap(); |
285 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(175.0, 175.0) }); |
286 | assert!(!instance.get_inner_ta_pressed()); |
287 | assert!(instance.get_inner_ta_has_hover()); |
288 | assert_eq!(instance.get_clicked(), 0); |
289 | slint_testing::mock_elapsed_time(5000); |
290 | assert!(!instance.get_inner_ta_pressed()); |
291 | assert!(instance.get_inner_ta_has_hover()); |
292 | assert_eq!(instance.get_clicked(), 0); |
293 | |
294 | // Start a press |
295 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(175.0, 175.0), button: PointerEventButton::Left }); |
296 | //assert!(!instance.get_inner_ta_pressed()); |
297 | assert!(instance.get_inner_ta_has_hover()); |
298 | assert_eq!(instance.get_clicked(), 0); |
299 | // Release almost immediately |
300 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(178.0, 173.0), button: PointerEventButton::Left }); |
301 | assert!(!instance.get_inner_ta_pressed()); |
302 | assert!(instance.get_inner_ta_has_hover()); |
303 | assert_eq!(instance.get_clicked(), 18_00013); |
304 | assert_eq!(instance.get_offset_x(), 0.); |
305 | assert_eq!(instance.get_offset_y(), 0.); |
306 | |
307 | instance.set_clicked(-1); |
308 | |
309 | slint_testing::mock_elapsed_time(1000); |
310 | |
311 | // - Press, move a triny, then release quickly: should click |
312 | // Start a press |
313 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(165.0, 175.0), button: PointerEventButton::Left }); |
314 | assert!(!instance.get_inner_ta_pressed()); |
315 | assert!(instance.get_inner_ta_has_hover()); |
316 | assert_eq!(instance.get_clicked(), -1); |
317 | // make a small move |
318 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(166.0, 174.0) }); |
319 | assert!(!instance.get_inner_ta_pressed()); |
320 | assert!(instance.get_inner_ta_has_hover()); |
321 | slint_testing::mock_elapsed_time(30); |
322 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(167.0, 175.0) }); |
323 | assert!(!instance.get_inner_ta_pressed()); |
324 | // and release |
325 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(165.0, 174.0), button: PointerEventButton::Left }); |
326 | assert!(!instance.get_inner_ta_pressed()); |
327 | assert!(instance.get_inner_ta_has_hover()); |
328 | assert_eq!(instance.get_clicked(), 5_00014); |
329 | assert_eq!(instance.get_offset_x(), 0.); |
330 | assert_eq!(instance.get_offset_y(), 0.); |
331 | |
332 | instance.set_clicked(-1); |
333 | |
334 | // Start a press |
335 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(175.0, 175.0), button: PointerEventButton::Left }); |
336 | assert!(!instance.get_inner_ta_pressed()); |
337 | assert!(instance.get_inner_ta_has_hover()); |
338 | assert_eq!(instance.get_clicked(), -1); |
339 | assert_eq!(instance.get_offset_x(), 0.); |
340 | assert_eq!(instance.get_offset_y(), 0.); |
341 | |
342 | //wait a delay |
343 | slint_testing::mock_elapsed_time(300); |
344 | assert!(instance.get_inner_ta_pressed()); // only now we are pressed |
345 | assert!(instance.get_inner_ta_has_hover()); |
346 | assert_eq!(instance.get_clicked(), -1); |
347 | assert_eq!(instance.get_offset_x(), 0.); |
348 | assert_eq!(instance.get_offset_y(), 0.); |
349 | |
350 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(100.0, 120.0) }); |
351 | assert!(!instance.get_inner_ta_pressed()); // We should no longer be pressed |
352 | // no hover when the flickable is flicking |
353 | assert!(!instance.get_inner_ta_has_hover()); |
354 | assert_eq!(instance.get_clicked(), -1); // not clicked |
355 | assert_eq!(instance.get_offset_x(), 75.); |
356 | assert_eq!(instance.get_offset_y(), 55.); |
357 | |
358 | slint_testing::mock_elapsed_time(10000); |
359 | |
360 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(100.0, 120.0), button: PointerEventButton::Left }); |
361 | assert!(!instance.get_inner_ta_pressed()); |
362 | assert!(instance.get_inner_ta_has_hover()); |
363 | assert_eq!(instance.get_clicked(), -1); // not clicked |
364 | assert_eq!(instance.get_offset_x(), 75.); |
365 | assert_eq!(instance.get_offset_y(), 55.); |
366 | |
367 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(200.0, 50.0) }); |
368 | slint_testing::mock_elapsed_time(1000); |
369 | |
370 | assert!(!instance.get_inner_ta_pressed()); |
371 | assert!(!instance.get_inner_ta_has_hover()); |
372 | assert_eq!(instance.get_clicked(), -1); |
373 | assert!((instance.get_offset_x() - 75.).abs() < 5.); // only small animation on release |
374 | assert!((instance.get_offset_y() - 55.).abs() < 5.); |
375 | |
376 | Ok(()) |
377 | } |
378 | #[test ] fn t_2() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
379 | use i_slint_backend_testing as slint_testing; |
380 | slint_testing::init(); |
381 | // Test wheel events |
382 | use slint::{LogicalPosition, platform::{WindowEvent, Key} }; |
383 | let instance = TestCase::new().unwrap(); |
384 | instance.window().dispatch_event(WindowEvent::PointerScrolled { position: LogicalPosition::new(x:175.0, y:175.0), delta_x: -30.0, delta_y: -50.0 }); |
385 | assert_eq!(instance.get_offset_x(), 30.); |
386 | assert_eq!(instance.get_offset_y(), 50.); |
387 | |
388 | // When shift is pressed, it invert the direction |
389 | // (this test don't work on macos because on macos the backend does the inversion, not the core lib) |
390 | if !cfg!(target_os = "macos" ) { |
391 | slint_testing::send_keyboard_char(&instance, string:Key::Shift.into(), pressed:true); |
392 | instance.window().dispatch_event(WindowEvent::PointerScrolled { position: LogicalPosition::new(x:175.0, y:175.0), delta_x: 15.0, delta_y: -60.0 }); |
393 | slint_testing::send_keyboard_char(&instance, string:Key::Shift.into(), pressed:false); |
394 | assert_eq!(instance.get_offset_x(), 30. + 60.); |
395 | assert_eq!(instance.get_offset_y(), 50. - 15.); |
396 | } |
397 | Ok(()) |
398 | } |
399 | #[test ] fn t_3() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
400 | use i_slint_backend_testing as slint_testing; |
401 | slint_testing::init(); |
402 | // Test flicked-Callback behaviour |
403 | use slint::{LogicalPosition, platform::{WindowEvent, PointerEventButton} }; |
404 | let instance = TestCase::new().unwrap(); |
405 | assert_eq!(instance.get_flicked(), 0); |
406 | |
407 | // test scrolling behaviour |
408 | instance.window().dispatch_event(WindowEvent::PointerScrolled { position: LogicalPosition::new(175.0, 175.0), delta_x: -30.0, delta_y: -50.0 }); |
409 | dbg!(instance.get_flicked()); |
410 | assert_eq!(instance.get_flicked(), -3000050); //flicked got called after scrolling |
411 | instance.set_flicked(0); |
412 | |
413 | // test dragging bevaviour |
414 | instance.window().dispatch_event(WindowEvent::PointerPressed { position: LogicalPosition::new(175.0, 175.0), button: PointerEventButton::Left }); |
415 | slint_testing::mock_elapsed_time(300); |
416 | assert_eq!(instance.get_flicked(), 0); //flicked didn't get called by just pressing |
417 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(100.0, 120.0) }); |
418 | slint_testing::mock_elapsed_time(10000); |
419 | assert_eq!(instance.get_flicked(), -10500105); //flicked got called during drag |
420 | instance.set_flicked(0); |
421 | instance.window().dispatch_event(WindowEvent::PointerReleased { position: LogicalPosition::new(100.0, 120.0), button: PointerEventButton::Left }); |
422 | assert_eq!(instance.get_flicked(), -10500105); //flicked got called after drag |
423 | instance.set_flicked(0); |
424 | |
425 | Ok(()) |
426 | } |