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
4export 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
16let instance = TestCase::new().unwrap();
17instance.set_xx(500);
18// It's the first time we query the value: so no animation
19assert_eq!(instance.get_yy(), 5000);
20instance.set_xx(1000);
21// now it is animated
22slint_testing::mock_elapsed_time(500);
23assert_eq!(instance.get_yy(), 7500);
24instance.set_xx(500);
25slint_testing::mock_elapsed_time(500);
26assert_eq!(instance.get_yy(), 7500 - 2500/2);
27slint_testing::mock_elapsed_time(5000);
28instance.set_xx(1000);
29assert_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
30slint_testing::mock_elapsed_time(500);
31instance.set_xx(1000);
32slint_testing::mock_elapsed_time(250);
33assert_eq!(instance.get_yy(), 9063);
34slint_testing::mock_elapsed_time(250);
35assert_eq!(instance.get_yy(), 10000);
36```
37
38
39*/
40