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.
109 lines
2.7 KiB
Text
109 lines
2.7 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: 600phx;
|
|
height: 300phx;
|
|
|
|
Rectangle {
|
|
width: 300phx;
|
|
height: 300phx;
|
|
GridLayout {
|
|
spacing: 10phx;
|
|
Row {
|
|
Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
|
|
rect1 := Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
}
|
|
|
|
Row {
|
|
Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
|
|
rect2 := Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
out property <bool> rect1_pos_ok: rect1.x == 15phx && rect1.y == 0phx;
|
|
out property <bool> rect2_pos_ok: rect2.x == 15phx && rect2.y == 15phx;
|
|
|
|
Rectangle {
|
|
width: 300phx;
|
|
height: 300phx;
|
|
GridLayout {
|
|
spacing-horizontal: 20phx;
|
|
spacing-vertical: 30phx;
|
|
spacing: 10phx;
|
|
Row {
|
|
Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
|
|
rect3 := Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
}
|
|
|
|
Row {
|
|
Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
|
|
rect4 := Rectangle {
|
|
width: 5phx;
|
|
height: 5phx;
|
|
background: red;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
out property <bool> rect3_pos_ok: rect3.x == 25phx && rect3.y == 0phx;
|
|
out property <bool> rect4_pos_ok: rect4.x == 25phx && rect4.y == 35phx;
|
|
|
|
out property <bool> test: rect1_pos_ok && rect2_pos_ok &&rect3_pos_ok && rect4_pos_ok;
|
|
}
|
|
|
|
/*
|
|
|
|
```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_rect4_pos_ok());
|
|
```
|
|
|
|
|
|
```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_rect4_pos_ok());
|
|
```
|
|
|
|
*/
|