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
6export global InitOrder := {
7 property <string> observed-order: "start";
8}
9
10
11TestCase := 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
35let instance = TestCase::new().unwrap();
36
37assert!(instance.get_test());
38```
39
40```cpp
41auto handle = TestCase::create();
42const TestCase &instance = *handle;
43assert(instance.get_test());
44```
45
46
47```js
48var instance = new slint.TestCase({});
49assert(instance.test);
50```
51
52
53*/
54