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 | OpacityTwoWay := Rectangle { |
6 | property <float> sub_opacity <=> rect.opacity; |
7 | rect := Rectangle { |
8 | opacity: 0.75; |
9 | } |
10 | } |
11 | |
12 | Compo := Rectangle { |
13 | preferred-height: 10px; |
14 | property<int> foo <=> self.bar; |
15 | property<int> bar: 120; |
16 | } |
17 | |
18 | export TestCase := Window { |
19 | compo0 := Compo { foo: compo1.foo + 20; } |
20 | compo1 := Compo {} |
21 | compo2 := Compo { foo: compo1.foo + 10; } |
22 | |
23 | Rectangle { |
24 | otw := OpacityTwoWay { sub_opacity: 0.5; } |
25 | otw2 := OpacityTwoWay { sub_opacity: 0.5; } |
26 | } |
27 | |
28 | property <int> override_bar: 22; |
29 | force_instance := VerticalLayout { |
30 | if true : Compo { bar <=> override_bar; } |
31 | } |
32 | |
33 | property <int> compo0_foo: compo0.foo; |
34 | property <int> compo2_foo: compo2.foo; |
35 | property <float> otw_opacity <=> otw.sub_opacity; |
36 | |
37 | property <bool> test_override_bar: force_instance.preferred-height == 10px && override_bar == 22; |
38 | |
39 | property <bool> test: compo0_foo == 140 && compo2_foo == 130 && otw_opacity == 0.5 && otw2.sub_opacity == 0.5 && test_override_bar; |
40 | } |
41 | |
42 | /* |
43 | |
44 | ```rust |
45 | let instance = TestCase::new().unwrap(); |
46 | assert_eq!(instance.get_compo0_foo(), 140); |
47 | assert_eq!(instance.get_compo2_foo(), 130); |
48 | assert_eq!(instance.get_otw_opacity(), 0.5); |
49 | assert!(instance.get_test_override_bar(), "override_bar = {}", instance.get_override_bar()); |
50 | assert!(instance.get_test()); |
51 | ``` |
52 | |
53 | |
54 | |
55 | ```cpp |
56 | auto handle = TestCase::create(); |
57 | const TestCase &instance = *handle; |
58 | assert_eq(instance.get_compo0_foo(), 140); |
59 | assert_eq(instance.get_compo2_foo(), 130); |
60 | assert_eq(instance.get_otw_opacity(), 0.5); |
61 | assert(instance.get_test()); |
62 | ``` |
63 | |
64 | |
65 | ```js |
66 | let instance = new slint.TestCase({}); |
67 | assert.equal(instance.compo0_foo, 140); |
68 | assert.equal(instance.compo2_foo, 130); |
69 | assert.equal(instance.otw_opacity, 0.5); |
70 | assert(instance.test); |
71 | ``` |
72 | |
73 | */ |
74 | } |
75 | |
76 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
77 | use i_slint_backend_testing as slint_testing; |
78 | slint_testing::init(); |
79 | let instance = TestCase::new().unwrap(); |
80 | assert_eq!(instance.get_compo0_foo(), 140); |
81 | assert_eq!(instance.get_compo2_foo(), 130); |
82 | assert_eq!(instance.get_otw_opacity(), 0.5); |
83 | assert!(instance.get_test_override_bar(), "override_bar = {}" , instance.get_override_bar()); |
84 | assert!(instance.get_test()); |
85 | Ok(()) |
86 | } |