| 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 | |
| 5 | TestCase := 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 |
| 26 | auto handle = TestCase::create(); |
| 27 | const TestCase &instance = *handle; |
| 28 | |
| 29 | slint_testing::send_mouse_click(&instance, 37., 27.); |
| 30 | assert_eq(instance.get_clicked(), 0); |
| 31 | |
| 32 | instance.set_condition(true); |
| 33 | slint_testing::send_mouse_click(&instance, 37., 27.); |
| 34 | assert_eq(instance.get_clicked(), 1); |
| 35 | |
| 36 | ``` |
| 37 | |
| 38 | |
| 39 | ```rust |
| 40 | let instance = TestCase::new().unwrap(); |
| 41 | slint_testing::send_mouse_click(&instance, 37., 27.); |
| 42 | assert_eq!(instance.get_clicked(), 0); |
| 43 | |
| 44 | instance.set_condition(true); |
| 45 | slint_testing::send_mouse_click(&instance, 37., 27.); |
| 46 | assert_eq!(instance.get_clicked(), 1); |
| 47 | |
| 48 | |
| 49 | ``` |
| 50 | |
| 51 | */ |
| 52 | |