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
6
7
8TestCase := Rectangle {
9 width: 100phx;
10 height: 100phx;
11
12 property<length> xx: 50phx;
13 property<length> ww <=> first.width;
14
15 first := TouchArea {
16 x <=> parent.xx;
17 width: 50phx;
18 enabled <=> second.enabled;
19 height: 15phx;
20 clicked => { result += 40; }
21 }
22
23 second := TouchArea {
24 x <=> parent.xx;
25 width <=> root.ww;
26 height <=> first.height;
27 clicked => { result += 300; }
28 y: 50phx;
29 }
30
31 property <int> result: 5;
32}
33
34
35
36/*
37
38```rust
39let instance = TestCase::new().unwrap();
40slint_testing::send_mouse_click(&instance, 70., 5.);
41slint_testing::send_mouse_click(&instance, 85., 55.);
42assert_eq!(instance.get_result(), 345);
43instance.set_xx(0.);
44slint_testing::send_mouse_click(&instance, 5., 10.);
45slint_testing::send_mouse_click(&instance, 5., 60.);
46assert_eq!(instance.get_result(), 685);
47
48```
49
50
51
52```cpp
53auto handle = TestCase::create();
54const TestCase &instance = *handle;
55slint_testing::send_mouse_click(&instance, 70., 5.);
56slint_testing::send_mouse_click(&instance, 85., 55.);
57assert_eq(instance.get_result(), 345);
58instance.set_xx(0.);
59slint_testing::send_mouse_click(&instance, 5., 10.);
60slint_testing::send_mouse_click(&instance, 5., 60.);
61assert_eq(instance.get_result(), 685);
62```
63
64
65```js
66let instance = new slint.TestCase({});
67slintlib.private_api.send_mouse_click(instance, 70., 5.);
68slintlib.private_api.send_mouse_click(instance, 85., 55.);
69assert.equal(instance.result, 345);
70instance.xx = 0;
71slintlib.private_api.send_mouse_click(instance, 5., 10.);
72slintlib.private_api.send_mouse_click(instance, 5., 60.);
73assert.equal(instance.result, 685);
74```
75
76*/
77}
78
79#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
80 use i_slint_backend_testing as slint_testing;
81 slint_testing::init();
82 let instance = TestCase::new().unwrap();
83 slint_testing::send_mouse_click(&instance, x:70., y:5.);
84 slint_testing::send_mouse_click(&instance, x:85., y:55.);
85 assert_eq!(instance.get_result(), 345);
86 instance.set_xx(0.);
87 slint_testing::send_mouse_click(&instance, x:5., y:10.);
88 slint_testing::send_mouse_click(&instance, x:5., y:60.);
89 assert_eq!(instance.get_result(), 685);
90
91 Ok(())
92}