| 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 | TestCase := Rectangle { |
| 5 | width: 300phx; |
| 6 | height: 300phx; |
| 7 | |
| 8 | GridLayout { |
| 9 | spacing: 0phx; |
| 10 | padding: 0phx; |
| 11 | |
| 12 | Row { |
| 13 | rect1 := Rectangle { background: red; horizontal-stretch: 2;} |
| 14 | } |
| 15 | |
| 16 | Row { |
| 17 | rect2 := Rectangle { background: green; horizontal-stretch: 2; } |
| 18 | ig := GridLayout { |
| 19 | spacing: 4phx; |
| 20 | padding: 0phx; |
| 21 | rect3 := Rectangle { background: black; } |
| 22 | rect4 := Rectangle { background: blue; } |
| 23 | rect5 := Rectangle { background: red; row: 1; } |
| 24 | rect6 := Rectangle { background: green; } |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 148phx && rect1.height == 148phx; |
| 30 | property <bool> rect2_pos_ok: rect2.x == 0phx && rect2.y == 148phx && rect2.width == 148phx && rect2.height == 152phx; |
| 31 | property <bool> rect3_pos_ok: ig.x + rect3.x == 148phx && ig.y + rect3.y == 148phx && rect3.width == 74phx && rect3.height == 74phx; |
| 32 | property <bool> rect4_pos_ok: ig.x + rect4.x == 226phx && ig.y + rect4.y == 148phx && rect4.width == 74phx && rect4.height == 74phx; |
| 33 | property <bool> rect5_pos_ok: ig.x + rect5.x == 148phx && ig.y + rect5.y == 226phx && rect5.width == 74phx && rect5.height == 74phx; |
| 34 | property <bool> rect6_pos_ok: ig.x + rect6.x == 226phx && ig.y + rect6.y == 226phx && rect6.width == 74phx && rect6.height == 74phx; |
| 35 | |
| 36 | property <bool> test: rect1_pos_ok && rect2_pos_ok && rect3_pos_ok && rect4_pos_ok && rect5_pos_ok && rect6_pos_ok; |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | |
| 41 | ```cpp |
| 42 | auto handle = TestCase::create(); |
| 43 | const TestCase &instance = *handle; |
| 44 | assert(instance.get_rect1_pos_ok()); |
| 45 | assert(instance.get_rect2_pos_ok()); |
| 46 | assert(instance.get_rect3_pos_ok()); |
| 47 | assert(instance.get_rect4_pos_ok()); |
| 48 | assert(instance.get_rect5_pos_ok()); |
| 49 | assert(instance.get_rect6_pos_ok()); |
| 50 | ``` |
| 51 | |
| 52 | |
| 53 | ```rust |
| 54 | let instance = TestCase::new().unwrap(); |
| 55 | assert!(instance.get_rect1_pos_ok()); |
| 56 | assert!(instance.get_rect2_pos_ok()); |
| 57 | assert!(instance.get_rect3_pos_ok()); |
| 58 | assert!(instance.get_rect4_pos_ok()); |
| 59 | assert!(instance.get_rect5_pos_ok()); |
| 60 | assert!(instance.get_rect6_pos_ok()); |
| 61 | ``` |
| 62 | |
| 63 | */ |
| 64 | |