slint/tests/cases/layout/grid_span.slint
David Faure fa7817981d layout tests: add missing compiler-based tests
Those were interpreter-only tests, better check the compiled case too.
2025-10-07 09:01:14 +02:00

76 lines
2 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
export component TestCase inherits Window {
width: 400phx;
height: 400phx;
GridLayout {
spacing: 10phx;
padding: 50phx;
rr := Rectangle {
background: red;
row: 0; col: 0;
colspan: 2;
max_width: 30phx;
}
rb := Rectangle {
background: blue;
row: 2; col: 1;
colspan: 2;
max_width: 40phx;
}
rg := Rectangle {
background: green;
row: 3; col: 1;
horizontal_stretch: 0;
preferred_width: 20phx;
}
ry := Rectangle {
background: yellow;
min_height: 200phx;
col: 3;
row: 0;
rowspan: 2;
horizontal_stretch: 0;
vertical_stretch: 0;
}
zero := Rectangle {
background: black;
row: 3; col: 1;
rowspan: 0;
colspan: 2;
horizontal_stretch: 10;
vertical_stretch: 10;
}
zero2 := Rectangle {
col: 5;
colspan: 0;
}
}
out property <bool> test: {
rr.x == 50phx && rr.y == 50phx && rr.width == 30phx && rr.height == (200phx - 10phx) / 2 && rr.colspan == 2 &&
rb.width == 40phx && rg.width == 20phx && rg.height == (400phx - 200phx - 100phx - 20phx) / 2 && rg.colspan == 1 &&
zero.height == 0 && zero.width == rb.width && zero.x == rb.x && zero.y == rg.y &&
zero2.height == rg.height && zero2.width == 0 && zero2.x > rb.x && zero2.y == rg.y && zero2.rowspan == 1 && zero2.colspan == 0
}
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
```
```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_test());
```
*/