mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-27 10:26:12 +00:00
98 lines
2.5 KiB
Text
98 lines
2.5 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
|
|
|
|
// Test the propagation of maximum and minimum size through nested grid layouts
|
|
|
|
Btn := Rectangle {
|
|
property <string> text;
|
|
|
|
t := Text {
|
|
text: root.text;
|
|
width: 100%; height: 100%;
|
|
}
|
|
|
|
accessible-label: text;
|
|
accessible-role: button;
|
|
}
|
|
|
|
Cb := Rectangle {
|
|
property <string> text;
|
|
accessible-label: text;
|
|
t := Text { }
|
|
accessible-description <=> t.text;
|
|
accessible-role: checkbox;
|
|
accessible-checked: true;
|
|
}
|
|
|
|
component ComboBox inherits Rectangle {
|
|
accessible-role: combobox;
|
|
accessible-label: "mycombo";
|
|
Rectangle {
|
|
accessible-role: text;
|
|
accessible-label: "innerlabel";
|
|
}
|
|
}
|
|
|
|
TestCase := Rectangle {
|
|
width: 300phx;
|
|
height: 300phx;
|
|
|
|
vl := VerticalLayout {
|
|
b1 := Btn {
|
|
text: "plus";
|
|
}
|
|
|
|
txt := Text {
|
|
text: "automatic text value";
|
|
}
|
|
|
|
|
|
b2 := Btn {
|
|
text : "minus";
|
|
}
|
|
|
|
cb := Cb { text: "hello"; }
|
|
|
|
ComboBox {}
|
|
}
|
|
|
|
for t in ["abc"] : Text { text: t; accessible-description: t; }
|
|
|
|
property<AccessibleRole> materialized_b1_role: b1.accessible_role;
|
|
property<string> materialized_b2_label: b2.accessible-label;
|
|
property<string> materialized_vl_label: vl.accessible-label;
|
|
property<AccessibleRole> materialized_vl_role: vl.accessible-role;
|
|
property<AccessibleRole> materialized_txt_role: txt.accessible-role;
|
|
property<string> materialized_txt_label: txt.accessible-label;
|
|
|
|
property <bool> test:
|
|
materialized_b1_role == AccessibleRole.button && materialized_b2_label == "minus"
|
|
&& materialized_vl_label == "" && materialized_vl_role == AccessibleRole.none
|
|
&& materialized_txt_label == "automatic text value" && materialized_txt_role == AccessibleRole.text
|
|
&& cb.accessible-checked && !b1.accessible-checked;
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert(instance.get_test());
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
assert!(instance.get_test());
|
|
|
|
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "mycombo").collect::<Vec<_>>().len(), 1);
|
|
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "innerlabel").collect::<Vec<_>>().len(), 1);
|
|
```
|
|
|
|
```js
|
|
var instance = new slint.TestCase();
|
|
assert(instance.test);
|
|
```
|
|
|
|
*/
|