mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
I kept seeing distracting warnings when working with these testcases, and it's better to have good examples when writing new testcases. I didn't touch the issue_*.slint regression tests, so those will still be testing the old syntax.
58 lines
1.8 KiB
Text
58 lines
1.8 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 Rectangle {
|
|
width: 300phx;
|
|
height: 300phx;
|
|
|
|
layout := GridLayout {
|
|
spacing: 0phx;
|
|
padding: 0phx;
|
|
Row {
|
|
rect1 := Rectangle {
|
|
background: red;
|
|
rowspan: 1;
|
|
}
|
|
rect2 := Rectangle {
|
|
background: blue;
|
|
}
|
|
}
|
|
|
|
Row {
|
|
rect3 := Rectangle {
|
|
background: green;
|
|
}
|
|
}
|
|
}
|
|
|
|
out property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 150phx && rect1.height == 150phx;
|
|
out property <bool> rect2_pos_ok: rect2.x == 150phx && rect2.y == 0phx && rect2.width == 150phx && rect2.height == 150phx;
|
|
out property <bool> rect3_pos_ok: rect3.x == 0phx && rect3.y == 150phx && rect3.width == 150phx && rect3.height == 150phx;
|
|
out property <bool> row_col_ok: rect1.row == 0 && rect1.col == 0 && rect2.row == 0 && rect2.col == 1 && rect3.row == 1 && rect3.col == 0;
|
|
out property <length> layout_width: layout.width;
|
|
|
|
out property <bool> test: rect1_pos_ok && rect2_pos_ok && rect3_pos_ok && row_col_ok && layout_width == 300phx;
|
|
}
|
|
|
|
/*
|
|
|
|
```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());
|
|
assert(instance.get_row_col_ok());
|
|
assert_eq(instance.get_layout_width(), 300);
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
assert!(instance.get_rect1_pos_ok());
|
|
assert!(instance.get_rect2_pos_ok());
|
|
assert!(instance.get_rect3_pos_ok());
|
|
assert!(instance.get_row_col_ok());
|
|
assert_eq!(instance.get_layout_width(), 300.);
|
|
```
|
|
*/
|