| 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 | export 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 |
| 36 | auto handle = TestCase::create(); |
| 37 | const TestCase &instance = *handle; |
| 38 | |
| 39 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 40 | assert_eq(instance.get_value(), -10); |
| 41 | |
| 42 | slint_testing::send_mouse_click(&instance, 25., 25.); |
| 43 | assert_eq(instance.get_value(), 8); |
| 44 | |
| 45 | slint_testing::send_mouse_click(&instance, 45., 15.); |
| 46 | assert_eq(instance.get_value(), 9); |
| 47 | ``` |
| 48 | |
| 49 | |
| 50 | ```rust |
| 51 | let instance = TestCase::new().unwrap(); |
| 52 | |
| 53 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 54 | assert_eq!(instance.get_value(), -10); |
| 55 | |
| 56 | slint_testing::send_mouse_click(&instance, 25., 25.); |
| 57 | assert_eq!(instance.get_value(), 8); |
| 58 | |
| 59 | slint_testing::send_mouse_click(&instance, 45., 15.); |
| 60 | assert_eq!(instance.get_value(), 9); |
| 61 | |
| 62 | ``` |
| 63 | |
| 64 | ```js |
| 65 | var instance = new slint.TestCase(); |
| 66 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
| 67 | assert.equal(instance.value, -10); |
| 68 | |
| 69 | instance.cond1 = true; |
| 70 | slintlib.private_api.send_mouse_click(instance, 25., 25.); |
| 71 | assert.equal(instance.value, 8); |
| 72 | |
| 73 | instance.cond1 = false; |
| 74 | slintlib.private_api.send_mouse_click(instance, 45., 15.); |
| 75 | assert.equal(instance.value, 9); |
| 76 | ``` |
| 77 | */ |
| 78 | |