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: 300phx;
7 height: 300phx;
8
9 property<[int]> xs: [1, 2, 3];
10 property<[int]> ys: [10, 20, 30];
11
12 VerticalLayout {
13 padding: 0px;
14 spacing: 0px;
15 for x_[i] in xs: HorizontalLayout {
16 padding: 0px;
17 spacing: 0px;
18 for y_[j] in ys: Rectangle {
19 TouchArea {
20 clicked => {
21 last_clicked = x_ + y_;
22 }
23 }
24 Text { text: (x_ + y_); }
25 }
26 }
27 }
28
29 property<int> last_clicked;
30}
31/*
32```cpp
33auto handle = TestCase::create();
34const TestCase &instance = *handle;
35
36slint_testing::send_mouse_click(&instance, 5., 95.);
37assert_eq(instance.get_last_clicked(), 11);
38slint_testing::send_mouse_click(&instance, 105., 205.);
39assert_eq(instance.get_last_clicked(), 23);
40slint_testing::send_mouse_click(&instance, 95., 195.);
41assert_eq(instance.get_last_clicked(), 12);
42slint_testing::send_mouse_click(&instance, 295., 56.);
43assert_eq(instance.get_last_clicked(), 31);
44```
45
46
47```rust
48let instance = TestCase::new().unwrap();
49
50slint_testing::send_mouse_click(&instance, 5., 95.);
51assert_eq!(instance.get_last_clicked(), 11);
52slint_testing::send_mouse_click(&instance, 105., 205.);
53assert_eq!(instance.get_last_clicked(), 23);
54slint_testing::send_mouse_click(&instance, 95., 195.);
55assert_eq!(instance.get_last_clicked(), 12);
56slint_testing::send_mouse_click(&instance, 295., 56.);
57assert_eq!(instance.get_last_clicked(), 31);
58
59```
60
61```js
62var instance = new slint.TestCase();
63
64slintlib.private_api.send_mouse_click(instance, 5., 95.);
65assert.equal(instance.last_clicked, 11);
66slintlib.private_api.send_mouse_click(instance, 105., 205.);
67assert.equal(instance.last_clicked, 23);
68slintlib.private_api.send_mouse_click(instance, 95., 195.);
69assert.equal(instance.last_clicked, 12);
70slintlib.private_api.send_mouse_click(instance, 295., 56.);
71assert.equal(instance.last_clicked, 31);
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
81 slint_testing::send_mouse_click(&instance, x:5., y:95.);
82 assert_eq!(instance.get_last_clicked(), 11);
83 slint_testing::send_mouse_click(&instance, x:105., y:205.);
84 assert_eq!(instance.get_last_clicked(), 23);
85 slint_testing::send_mouse_click(&instance, x:95., y:195.);
86 assert_eq!(instance.get_last_clicked(), 12);
87 slint_testing::send_mouse_click(&instance, x:295., y:56.);
88 assert_eq!(instance.get_last_clicked(), 31);
89
90 Ok(())
91}