1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | export component TestCase { |
5 | in property <int> xx : 1000; |
6 | out property <int> yy: xx * 10; |
7 | animate yy { |
8 | duration: 1s; |
9 | easing: linear; |
10 | } |
11 | } |
12 | |
13 | /* |
14 | |
15 | ```rust |
16 | let instance = TestCase::new().unwrap(); |
17 | instance.set_xx(500); |
18 | // It's the first time we query the value: so no animation |
19 | assert_eq!(instance.get_yy(), 5000); |
20 | instance.set_xx(1000); |
21 | // now it is animated |
22 | slint_testing::mock_elapsed_time(500); |
23 | assert_eq!(instance.get_yy(), 7500); |
24 | instance.set_xx(500); |
25 | slint_testing::mock_elapsed_time(500); |
26 | assert_eq!(instance.get_yy(), 7500 - 2500/2); |
27 | slint_testing::mock_elapsed_time(5000); |
28 | instance.set_xx(1000); |
29 | assert_eq!(instance.get_yy(), 7500 - 2500/2); // even if time has passed, since we reset the xx value, it is as if no time had passed |
30 | slint_testing::mock_elapsed_time(500); |
31 | instance.set_xx(1000); |
32 | slint_testing::mock_elapsed_time(250); |
33 | assert_eq!(instance.get_yy(), 9063); |
34 | slint_testing::mock_elapsed_time(250); |
35 | assert_eq!(instance.get_yy(), 10000); |
36 | ``` |
37 | |
38 | |
39 | */ |
40 | |