slint/tests/cases/layout/height_for_width.60
2021-07-02 15:55:54 +02:00

87 lines
2.6 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 */
//include_path: ../../../examples/printerdemo/ui/images/
TestCase := Rectangle {
width: 500phx;
height: 2000phx;
VerticalLayout {
padding: 0px;
spacing: 0px;
top_image := Image {
source: @image-url("cat_preview_round.png");
}
HorizontalLayout {
padding: 0px;
spacing: 0px;
Rectangle {
background: yellow;
width: 300phx;
}
second_image := Image {
source: @image-url("cat_preview_round.png");
}
}
Rectangle {
background: pink;
GridLayout {
spacing: 0;
padding: 0;
Row {
Rectangle { }
}
Row {
hfw_rect := Rectangle {
background: orange;
height: width / 2;
}
Rectangle { }
}
}
}
Image { }
}
property <length> top_image_height: top_image.height;
property <length> second_image_height: second_image.height;
property <length> second_image_width: second_image.width;
property <bool> hfw_rect_ok: hfw_rect.width == 250phx && hfw_rect.height == 125phx;
property <bool> test: top_image_height == 750phx && second_image_width == 200phx && second_image_height == 300phx && hfw_rect_ok;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.get_top_image_height(), 750.);
assert_eq(instance.get_second_image_width(), 200.);
assert_eq(instance.get_second_image_height(), 300.);
assert(instance.get_hfw_rect_ok());
```
```rust
let instance = TestCase::new();
assert_eq!(instance.get_top_image_height(), 750.);
assert_eq!(instance.get_second_image_width(), 200.);
assert_eq!(instance.get_second_image_height(), 300.);
assert!(instance.get_hfw_rect_ok());
```
```js
var instance = new sixtyfps.TestCase();
assert.equal(instance.top_image_height, 750.);
assert.equal(instance.second_image_width, 200.);
assert.equal(instance.second_image_height, 300.);
assert(instance.hfw_rect_ok);
```
*/