1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4export TestCase := Rectangle {
5 width: 100phx;
6 height: 100phx;
7 property<int> value: -10;
8
9 HorizontalLayout {
10
11 Rectangle { background: orange; }
12
13 for i in [
14 {color: #0f0, value: 8, },
15 {color: #00f, value: 9, },
16 {color: #f00, value: 10, },
17 ] : Rectangle {
18 background: i.color;
19 TouchArea {
20 width: 100%;
21 height: 100%;
22 clicked => {
23 root.value = i.value;
24 }
25 }
26 }
27
28 Rectangle { background: pink; }
29 }
30}
31
32// There should be 5 rectangle: so 100 divided by 5 is 20.
33
34/*
35```cpp
36auto handle = TestCase::create();
37const TestCase &instance = *handle;
38
39slint_testing::send_mouse_click(&instance, 5., 5.);
40assert_eq(instance.get_value(), -10);
41
42slint_testing::send_mouse_click(&instance, 25., 25.);
43assert_eq(instance.get_value(), 8);
44
45slint_testing::send_mouse_click(&instance, 45., 15.);
46assert_eq(instance.get_value(), 9);
47```
48
49
50```rust
51let instance = TestCase::new().unwrap();
52
53slint_testing::send_mouse_click(&instance, 5., 5.);
54assert_eq!(instance.get_value(), -10);
55
56slint_testing::send_mouse_click(&instance, 25., 25.);
57assert_eq!(instance.get_value(), 8);
58
59slint_testing::send_mouse_click(&instance, 45., 15.);
60assert_eq!(instance.get_value(), 9);
61
62```
63
64```js
65var instance = new slint.TestCase();
66slintlib.private_api.send_mouse_click(instance, 5., 5.);
67assert.equal(instance.value, -10);
68
69instance.cond1 = true;
70slintlib.private_api.send_mouse_click(instance, 25., 25.);
71assert.equal(instance.value, 8);
72
73instance.cond1 = false;
74slintlib.private_api.send_mouse_click(instance, 45., 15.);
75assert.equal(instance.value, 9);
76```
77*/
78