1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/layout"# ] |
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 | TestCase := Rectangle { |
6 | width: 300phx; |
7 | height: 300phx; |
8 | |
9 | layout := GridLayout { |
10 | spacing: 0phx; |
11 | padding: 0phx; |
12 | Row { |
13 | rect1 := Rectangle { |
14 | background: red; |
15 | rowspan: 1; |
16 | } |
17 | rect2 := Rectangle { |
18 | background: blue; |
19 | } |
20 | } |
21 | |
22 | Row { |
23 | rect3 := Rectangle { |
24 | background: green; |
25 | } |
26 | } |
27 | } |
28 | |
29 | property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 150phx && rect1.height == 150phx; |
30 | property <bool> rect2_pos_ok: rect2.x == 150phx && rect2.y == 0phx && rect2.width == 150phx && rect2.height == 150phx; |
31 | property <bool> rect3_pos_ok: rect3.x == 0phx && rect3.y == 150phx && rect3.width == 150phx && rect3.height == 150phx; |
32 | property <length> layout_width: layout.width; |
33 | } |
34 | |
35 | /* |
36 | |
37 | ```cpp |
38 | auto handle = TestCase::create(); |
39 | const TestCase &instance = *handle; |
40 | assert(instance.get_rect1_pos_ok()); |
41 | assert(instance.get_rect2_pos_ok()); |
42 | assert(instance.get_rect3_pos_ok()); |
43 | assert_eq(instance.get_layout_width(), 300); |
44 | ``` |
45 | |
46 | |
47 | ```rust |
48 | let instance = TestCase::new().unwrap(); |
49 | assert!(instance.get_rect1_pos_ok()); |
50 | assert!(instance.get_rect2_pos_ok()); |
51 | assert!(instance.get_rect3_pos_ok()); |
52 | assert_eq!(instance.get_layout_width(), 300.); |
53 | ``` |
54 | |
55 | // FIXME! interpreter test |
56 | |
57 | */ |
58 | } |
59 | |
60 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
61 | use i_slint_backend_testing as slint_testing; |
62 | slint_testing::init(); |
63 | let instance = TestCase::new().unwrap(); |
64 | assert!(instance.get_rect1_pos_ok()); |
65 | assert!(instance.get_rect2_pos_ok()); |
66 | assert!(instance.get_rect3_pos_ok()); |
67 | assert_eq!(instance.get_layout_width(), 300.); |
68 | Ok(()) |
69 | } |