1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/bindings"# ] |
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 | Sub := Rectangle { |
6 | property <bool> cond; |
7 | property <float> child_opacity: inner.opacity; |
8 | inner := Rectangle { |
9 | opacity: cond ? 0 : 1; |
10 | animate opacity { duration: 1s; } |
11 | background: green; |
12 | } |
13 | } |
14 | |
15 | TestCase := Rectangle { |
16 | property cond <=> s.cond; |
17 | property val <=> s.child_opacity; |
18 | s := Sub {} |
19 | } |
20 | |
21 | /* |
22 | |
23 | ```rust |
24 | let instance = TestCase::new().unwrap(); |
25 | assert_eq!(instance.get_val(), 1.); |
26 | instance.set_cond(true); |
27 | assert_eq!(instance.get_val(), 1.); |
28 | slint_testing::mock_elapsed_time(500); |
29 | assert_eq!(instance.get_val(), 0.5); |
30 | slint_testing::mock_elapsed_time(500); |
31 | assert_eq!(instance.get_val(), 0.); |
32 | |
33 | ``` |
34 | |
35 | */ |
36 | } |
37 | |
38 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
39 | use i_slint_backend_testing as slint_testing; |
40 | slint_testing::init(); |
41 | let instance = TestCase::new().unwrap(); |
42 | assert_eq!(instance.get_val(), 1.); |
43 | instance.set_cond(true); |
44 | assert_eq!(instance.get_val(), 1.); |
45 | slint_testing::mock_elapsed_time(time_in_ms:500); |
46 | assert_eq!(instance.get_val(), 0.5); |
47 | slint_testing::mock_elapsed_time(time_in_ms:500); |
48 | assert_eq!(instance.get_val(), 0.); |
49 | |
50 | Ok(()) |
51 | } |