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

67 lines
1.8 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 */
// Regression test for a panic in the compiler
TestCase := Rectangle {
width: 300phx;
height: 300phx;
property<int> value: 1;
for c[index] in [#f00, #00f, #0a0]: Rectangle {
y: index * height;
width: parent.width;
height: 100phx;
GridLayout {
Rectangle {
background: c;
TouchArea {
width: parent.width;
height: parent.height;
clicked => {
value += index;
}
}
}
}
}
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
sixtyfps::testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
sixtyfps::testing::send_mouse_click(&instance, 190., 190.);
assert_eq(instance.get_value(), 1+1);
sixtyfps::testing::send_mouse_click(&instance, 5., 290.);
assert_eq(instance.get_value(), 1+1+2);
```
```rust
let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
sixtyfps::testing::send_mouse_click(&instance, 190., 190.);
assert_eq!(instance.get_value(), 1+1);
sixtyfps::testing::send_mouse_click(&instance, 5., 290.);
assert_eq!(instance.get_value(), 1+1+2);
```
// FIXME: JS test because layout are not computed
*/