1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/layout"#]
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 := Window {
6 width: 300px;
7 height: 300px;
8 if (true) : Rectangle {
9 background: black;
10 VerticalLayout {
11 Rectangle {
12 background: blue;
13 TouchArea { clicked => { last_clicked = 1; } }
14 }
15 Rectangle {
16 background: red;
17 TouchArea { clicked => { last_clicked = 2; } }
18 }
19 }
20 }
21 property<int> last_clicked;
22}
23/*
24```cpp
25auto handle = TestCase::create();
26const TestCase &instance = *handle;
27assert_eq(instance.get_last_clicked(), 0);
28slint_testing::send_mouse_click(&instance, 15., 145.);
29assert_eq(instance.get_last_clicked(), 1);
30slint_testing::send_mouse_click(&instance, 15., 155.);
31assert_eq(instance.get_last_clicked(), 2);
32```
33
34
35```rust
36let instance = TestCase::new().unwrap();
37assert_eq!(instance.get_last_clicked(), 0);
38slint_testing::send_mouse_click(&instance, 15., 145.);
39assert_eq!(instance.get_last_clicked(), 1);
40slint_testing::send_mouse_click(&instance, 15., 155.);
41assert_eq!(instance.get_last_clicked(), 2);
42```
43
44```js
45var instance = new slint.TestCase();
46assert.equal(instance.last_clicked, 0);
47slintlib.private_api.send_mouse_click(instance, 15., 145.);
48assert.equal(instance.last_clicked, 1);
49slintlib.private_api.send_mouse_click(instance, 15., 155.);
50assert.equal(instance.last_clicked, 2);
51```
52*/
53}
54
55#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
56 use i_slint_backend_testing as slint_testing;
57 slint_testing::init();
58 let instance = TestCase::new().unwrap();
59 assert_eq!(instance.get_last_clicked(), 0);
60 slint_testing::send_mouse_click(&instance, x:15., y:145.);
61 assert_eq!(instance.get_last_clicked(), 1);
62 slint_testing::send_mouse_click(&instance, x:15., y:155.);
63 assert_eq!(instance.get_last_clicked(), 2);
64 Ok(())
65}