1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/models"# ] |
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 := Rectangle { |
6 | width: 100phx; |
7 | height: 100phx; |
8 | background: white; |
9 | property<int> top_level: 42; |
10 | |
11 | property<bool> cond1; |
12 | property<bool> cond2; |
13 | property<bool> cond3; |
14 | |
15 | if (cond1) : TouchArea { |
16 | width: parent.width; |
17 | height: root.height; |
18 | property<int> xx: root.top_level; |
19 | clicked => { |
20 | root.top_level += self.xx + 8; |
21 | } |
22 | } |
23 | |
24 | if (cond1 ? cond2 : cond3) : Rectangle { |
25 | background: root.background; |
26 | } |
27 | } |
28 | |
29 | |
30 | |
31 | |
32 | /* |
33 | ```cpp |
34 | auto handle = TestCase::create(); |
35 | const TestCase &instance = *handle; |
36 | |
37 | // condition is false |
38 | slint_testing::send_mouse_click(&instance, 5., 5.); |
39 | assert_eq(instance.get_top_level(), 42); |
40 | |
41 | instance.set_cond1(true); |
42 | slint_testing::send_mouse_click(&instance, 5., 5.); |
43 | assert_eq(instance.get_top_level(), 92); |
44 | |
45 | instance.set_cond1(false); |
46 | slint_testing::send_mouse_click(&instance, 5., 5.); |
47 | assert_eq(instance.get_top_level(), 92); |
48 | ``` |
49 | |
50 | |
51 | ```rust |
52 | let instance = TestCase::new().unwrap(); |
53 | |
54 | slint_testing::send_mouse_click(&instance, 5., 5.); |
55 | assert_eq!(instance.get_top_level(), 42); |
56 | |
57 | instance.set_cond1(true); |
58 | slint_testing::send_mouse_click(&instance, 5., 5.); |
59 | assert_eq!(instance.get_top_level(), 92); |
60 | |
61 | instance.set_cond1(false); |
62 | slint_testing::send_mouse_click(&instance, 5., 5.); |
63 | assert_eq!(instance.get_top_level(), 92); |
64 | ``` |
65 | |
66 | ```js |
67 | var instance = new slint.TestCase(); |
68 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
69 | assert.equal(instance.top_level, 42); |
70 | |
71 | instance.cond1 = true; |
72 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
73 | assert.equal(instance.top_level, 92); |
74 | |
75 | instance.cond1 = false; |
76 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
77 | assert.equal(instance.top_level, 92); |
78 | ``` |
79 | */ |
80 | } |
81 | |
82 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
83 | use i_slint_backend_testing as slint_testing; |
84 | slint_testing::init(); |
85 | let instance = TestCase::new().unwrap(); |
86 | |
87 | slint_testing::send_mouse_click(&instance, x:5., y:5.); |
88 | assert_eq!(instance.get_top_level(), 42); |
89 | |
90 | instance.set_cond1(true); |
91 | slint_testing::send_mouse_click(&instance, x:5., y:5.); |
92 | assert_eq!(instance.get_top_level(), 92); |
93 | |
94 | instance.set_cond1(false); |
95 | slint_testing::send_mouse_click(&instance, x:5., y:5.); |
96 | assert_eq!(instance.get_top_level(), 92); |
97 | Ok(()) |
98 | } |