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 | GridLayout { |
10 | spacing: 0phx; |
11 | padding: 0phx; |
12 | |
13 | Row { |
14 | rect1 := Rectangle { background: red; horizontal-stretch: 2;} |
15 | } |
16 | |
17 | Row { |
18 | rect2 := Rectangle { background: green; horizontal-stretch: 2; } |
19 | ig := GridLayout { |
20 | spacing: 4phx; |
21 | padding: 0phx; |
22 | rect3 := Rectangle { background: black; } |
23 | rect4 := Rectangle { background: blue; } |
24 | rect5 := Rectangle { background: red; row: 1; } |
25 | rect6 := Rectangle { background: green; } |
26 | } |
27 | } |
28 | } |
29 | |
30 | property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 148phx && rect1.height == 148phx; |
31 | property <bool> rect2_pos_ok: rect2.x == 0phx && rect2.y == 148phx && rect2.width == 148phx && rect2.height == 152phx; |
32 | property <bool> rect3_pos_ok: ig.x + rect3.x == 148phx && ig.y + rect3.y == 148phx && rect3.width == 74phx && rect3.height == 74phx; |
33 | property <bool> rect4_pos_ok: ig.x + rect4.x == 226phx && ig.y + rect4.y == 148phx && rect4.width == 74phx && rect4.height == 74phx; |
34 | property <bool> rect5_pos_ok: ig.x + rect5.x == 148phx && ig.y + rect5.y == 226phx && rect5.width == 74phx && rect5.height == 74phx; |
35 | property <bool> rect6_pos_ok: ig.x + rect6.x == 226phx && ig.y + rect6.y == 226phx && rect6.width == 74phx && rect6.height == 74phx; |
36 | |
37 | property <bool> test: rect1_pos_ok && rect2_pos_ok && rect3_pos_ok && rect4_pos_ok && rect5_pos_ok && rect6_pos_ok; |
38 | } |
39 | |
40 | /* |
41 | |
42 | ```cpp |
43 | auto handle = TestCase::create(); |
44 | const TestCase &instance = *handle; |
45 | assert(instance.get_rect1_pos_ok()); |
46 | assert(instance.get_rect2_pos_ok()); |
47 | assert(instance.get_rect3_pos_ok()); |
48 | assert(instance.get_rect4_pos_ok()); |
49 | assert(instance.get_rect5_pos_ok()); |
50 | assert(instance.get_rect6_pos_ok()); |
51 | ``` |
52 | |
53 | |
54 | ```rust |
55 | let instance = TestCase::new().unwrap(); |
56 | assert!(instance.get_rect1_pos_ok()); |
57 | assert!(instance.get_rect2_pos_ok()); |
58 | assert!(instance.get_rect3_pos_ok()); |
59 | assert!(instance.get_rect4_pos_ok()); |
60 | assert!(instance.get_rect5_pos_ok()); |
61 | assert!(instance.get_rect6_pos_ok()); |
62 | ``` |
63 | |
64 | */ |
65 | } |
66 | |
67 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
68 | use i_slint_backend_testing as slint_testing; |
69 | slint_testing::init(); |
70 | let instance = TestCase::new().unwrap(); |
71 | assert!(instance.get_rect1_pos_ok()); |
72 | assert!(instance.get_rect2_pos_ok()); |
73 | assert!(instance.get_rect3_pos_ok()); |
74 | assert!(instance.get_rect4_pos_ok()); |
75 | assert!(instance.get_rect5_pos_ok()); |
76 | assert!(instance.get_rect6_pos_ok()); |
77 | Ok(()) |
78 | } |