| 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 | // Verify that the init callback is invoked in the correct order |
| 5 | |
| 6 | export global InitOrder := { |
| 7 | property <string> observed-order: "start" ; |
| 8 | } |
| 9 | |
| 10 | |
| 11 | TestCase := Rectangle { |
| 12 | width: 300phx; |
| 13 | height: 300phx; |
| 14 | init => { |
| 15 | InitOrder.observed-order += "|root" ; |
| 16 | } |
| 17 | |
| 18 | |
| 19 | HorizontalLayout { |
| 20 | for i in ["hello" , "world" ]: Rectangle { |
| 21 | preferred-width: 10px; |
| 22 | init => { |
| 23 | InitOrder.observed-order +="|" + i; |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | property <string> expected_order: "start|root|hello|world" ; |
| 29 | |
| 30 | property <bool> test: root.preferred-width == 20px && InitOrder.observed-order == expected_order; |
| 31 | } |
| 32 | |
| 33 | /* |
| 34 | ```rust |
| 35 | let instance = TestCase::new().unwrap(); |
| 36 | |
| 37 | assert!(instance.get_test()); |
| 38 | ``` |
| 39 | |
| 40 | ```cpp |
| 41 | auto handle = TestCase::create(); |
| 42 | const TestCase &instance = *handle; |
| 43 | assert(instance.get_test()); |
| 44 | ``` |
| 45 | |
| 46 | |
| 47 | ```js |
| 48 | var instance = new slint.TestCase({}); |
| 49 | assert(instance.test); |
| 50 | ``` |
| 51 | |
| 52 | |
| 53 | */ |
| 54 | |