| 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 | TestCase := Window { |
| 5 | width: 100px; |
| 6 | height: 100px; |
| 7 | property<int> niceness: 33; |
| 8 | greeting := TouchArea { |
| 9 | clicked => { root.niceness += 1; } |
| 10 | t:= Text { |
| 11 | text: "Hello world" ; |
| 12 | } |
| 13 | |
| 14 | states [ |
| 15 | rude when root.niceness <= 0: {visible: false;} |
| 16 | mannered when root.niceness > 100: {t.text: "Hello, dearest world" ; t.font-size: 32px;} |
| 17 | ] |
| 18 | } |
| 19 | |
| 20 | property <bool> test: greeting.visible; |
| 21 | } |
| 22 | |
| 23 | |
| 24 | /* |
| 25 | ```cpp |
| 26 | auto handle = TestCase::create(); |
| 27 | const TestCase &instance = *handle; |
| 28 | assert(instance.get_test()); |
| 29 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 30 | assert_eq(instance.get_niceness(), 34); |
| 31 | |
| 32 | instance.set_niceness(-1); |
| 33 | assert(!instance.get_test()); |
| 34 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 35 | assert_eq(instance.get_niceness(), -1); |
| 36 | |
| 37 | ``` |
| 38 | |
| 39 | |
| 40 | ```rust |
| 41 | let instance = TestCase::new().unwrap(); |
| 42 | assert!(instance.get_test()); |
| 43 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 44 | assert_eq!(instance.get_niceness(), 34); |
| 45 | |
| 46 | instance.set_niceness(-1); |
| 47 | assert!(!instance.get_test()); |
| 48 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 49 | assert_eq!(instance.get_niceness(), -1); |
| 50 | ``` |
| 51 | |
| 52 | |
| 53 | */ |
| 54 | |