1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/callbacks"# ] |
2 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
3 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
4 | |
5 | // Verify that the init callback is invoked in the correct order |
6 | |
7 | export global InitOrder := { |
8 | property <string> observed-order: "start" ; |
9 | } |
10 | |
11 | |
12 | TestCase := Rectangle { |
13 | width: 300phx; |
14 | height: 300phx; |
15 | init => { |
16 | InitOrder.observed-order += "|root" ; |
17 | } |
18 | |
19 | |
20 | HorizontalLayout { |
21 | for i in ["hello" , "world" ]: Rectangle { |
22 | preferred-width: 10px; |
23 | init => { |
24 | InitOrder.observed-order +="|" + i; |
25 | } |
26 | } |
27 | } |
28 | |
29 | property <string> expected_order: "start|root|hello|world" ; |
30 | |
31 | property <bool> test: root.preferred-width == 20px && InitOrder.observed-order == expected_order; |
32 | } |
33 | |
34 | /* |
35 | ```rust |
36 | let instance = TestCase::new().unwrap(); |
37 | |
38 | assert!(instance.get_test()); |
39 | ``` |
40 | |
41 | ```cpp |
42 | auto handle = TestCase::create(); |
43 | const TestCase &instance = *handle; |
44 | assert(instance.get_test()); |
45 | ``` |
46 | |
47 | |
48 | ```js |
49 | var instance = new slint.TestCase({}); |
50 | assert(instance.test); |
51 | ``` |
52 | |
53 | |
54 | */ |
55 | } |
56 | |
57 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
58 | use i_slint_backend_testing as slint_testing; |
59 | slint_testing::init(); |
60 | let instance = TestCase::new().unwrap(); |
61 | |
62 | assert!(instance.get_test()); |
63 | Ok(()) |
64 | } |