slint/tests/cases/layout/grid_min_max.60
2021-08-17 22:38:16 +02:00

72 lines
1.9 KiB
Text

/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
// Test the maximum and minimum size within a grid layout
TestCase := Rectangle {
width: 300phx;
height: 300phx;
GridLayout {
padding: 0phx;
spacing: 1phx;
Row {
rect1 := Rectangle {
background: red;
min_width: 50phx;
min_height: 20phx;
max_height: 20phx;
}
rect2 := Rectangle {
background: blue;
}
}
Row {
rect3 := Rectangle {
background: green;
max_width: 60phx;
}
rect4 := Rectangle {
background: red;
}
rect5 := Rectangle {
background: black;
max_width: 100phx;
}
}
}
property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 60phx && rect1.height == 20phx;
property <bool> rect2_pos_ok: rect2.x == 61phx && rect2.y == 0phx && rect2.width == 138phx && rect2.height == 20phx;
property <bool> rect3_pos_ok: rect3.x == 0phx && rect3.y == 21phx && rect3.width == 60phx && rect3.height == 279phx;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_rect1_pos_ok());
assert(instance.get_rect2_pos_ok());
assert(instance.get_rect3_pos_ok());
```
```rust
let instance = TestCase::new();
assert!(instance.get_rect1_pos_ok());
assert!(instance.get_rect2_pos_ok());
assert!(instance.get_rect3_pos_ok());
```
// FIXME:: interpreter test
*/