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 | // Test the maximum and minimum size within a grid layout |
6 | |
7 | TestCase := Rectangle { |
8 | width: 300phx; |
9 | height: 300phx; |
10 | |
11 | GridLayout { |
12 | padding: 0phx; |
13 | spacing: 1phx; |
14 | Row { |
15 | rect1 := Rectangle { |
16 | background: red; |
17 | min_width: 50phx; |
18 | min_height: 20phx; |
19 | max_height: 20phx; |
20 | |
21 | } |
22 | rect2 := Rectangle { |
23 | background: blue; |
24 | } |
25 | } |
26 | |
27 | Row { |
28 | rect3 := Rectangle { |
29 | background: green; |
30 | max_width: 60phx; |
31 | } |
32 | rect4 := Rectangle { |
33 | background: red; |
34 | } |
35 | rect5 := Rectangle { |
36 | background: black; |
37 | max_width: 100phx; |
38 | } |
39 | } |
40 | } |
41 | |
42 | property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 60phx && rect1.height == 20phx; |
43 | property <bool> rect2_pos_ok: rect2.x == 61phx && rect2.y == 0phx && rect2.width == 138phx && rect2.height == 20phx; |
44 | property <bool> rect3_pos_ok: rect3.x == 0phx && rect3.y == 21phx && rect3.width == 60phx && rect3.height == 279phx; |
45 | } |
46 | |
47 | /* |
48 | |
49 | ```cpp |
50 | auto handle = TestCase::create(); |
51 | const TestCase &instance = *handle; |
52 | assert(instance.get_rect1_pos_ok()); |
53 | assert(instance.get_rect2_pos_ok()); |
54 | assert(instance.get_rect3_pos_ok()); |
55 | ``` |
56 | |
57 | |
58 | ```rust |
59 | let instance = TestCase::new().unwrap(); |
60 | assert!(instance.get_rect1_pos_ok()); |
61 | assert!(instance.get_rect2_pos_ok()); |
62 | assert!(instance.get_rect3_pos_ok()); |
63 | ``` |
64 | |
65 | // FIXME:: interpreter test |
66 | |
67 | */ |
68 | } |
69 | |
70 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
71 | use i_slint_backend_testing as slint_testing; |
72 | slint_testing::init(); |
73 | let instance = TestCase::new().unwrap(); |
74 | assert!(instance.get_rect1_pos_ok()); |
75 | assert!(instance.get_rect2_pos_ok()); |
76 | assert!(instance.get_rect3_pos_ok()); |
77 | Ok(()) |
78 | } |