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
5TestCase := 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
34auto handle = TestCase::create();
35const TestCase &instance = *handle;
36
37// condition is false
38slint_testing::send_mouse_click(&instance, 5., 5.);
39assert_eq(instance.get_top_level(), 42);
40
41instance.set_cond1(true);
42slint_testing::send_mouse_click(&instance, 5., 5.);
43assert_eq(instance.get_top_level(), 92);
44
45instance.set_cond1(false);
46slint_testing::send_mouse_click(&instance, 5., 5.);
47assert_eq(instance.get_top_level(), 92);
48```
49
50
51```rust
52let instance = TestCase::new().unwrap();
53
54slint_testing::send_mouse_click(&instance, 5., 5.);
55assert_eq!(instance.get_top_level(), 42);
56
57instance.set_cond1(true);
58slint_testing::send_mouse_click(&instance, 5., 5.);
59assert_eq!(instance.get_top_level(), 92);
60
61instance.set_cond1(false);
62slint_testing::send_mouse_click(&instance, 5., 5.);
63assert_eq!(instance.get_top_level(), 92);
64```
65
66```js
67var instance = new slint.TestCase();
68slintlib.private_api.send_mouse_click(instance, 5., 5.);
69assert.equal(instance.top_level, 42);
70
71instance.cond1 = true;
72slintlib.private_api.send_mouse_click(instance, 5., 5.);
73assert.equal(instance.top_level, 92);
74
75instance.cond1 = false;
76slintlib.private_api.send_mouse_click(instance, 5., 5.);
77assert.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}