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
4
5TestCase := Rectangle {
6 height: 100phx;
7 width: 100phx;
8 property <int> clicked;
9 property <bool> condition;
10
11 if true : TouchArea {
12 visible: condition;
13 clicked => { root.clicked += 1; }
14 }
15
16 HorizontalLayout {
17 for xx in [10] : TouchArea {
18 visible: false;
19 clicked => { root.clicked += xx; }
20 }
21 }
22}
23
24/*
25```cpp
26auto handle = TestCase::create();
27const TestCase &instance = *handle;
28
29slint_testing::send_mouse_click(&instance, 37., 27.);
30assert_eq(instance.get_clicked(), 0);
31
32instance.set_condition(true);
33slint_testing::send_mouse_click(&instance, 37., 27.);
34assert_eq(instance.get_clicked(), 1);
35
36```
37
38
39```rust
40let instance = TestCase::new().unwrap();
41slint_testing::send_mouse_click(&instance, 37., 27.);
42assert_eq!(instance.get_clicked(), 0);
43
44instance.set_condition(true);
45slint_testing::send_mouse_click(&instance, 37., 27.);
46assert_eq!(instance.get_clicked(), 1);
47
48
49```
50
51*/
52