mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-26 18:06:26 +00:00
Keep merging elements, but remember the boundaries in the debug info, separated by a slash.
Also fixed tests that rely on accessible-label being set only once. For example
```
Button { text: "foo"; }
```
will certainly have "foo" as accessible-label on `Button`, but its internal `Text` element has
an implicit "accessible-label" set to the same
value.
So don't rely on that for now but search by id instead.
71 lines
2.1 KiB
Text
71 lines
2.1 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
|
|
|
|
|
|
import { SpinBox } from "std-widgets.slint";
|
|
export component TestCase inherits Window {
|
|
width: 100px;
|
|
height: 100px;
|
|
spin_min_pos := SpinBox {
|
|
accessible-label: "spinbox";
|
|
minimum: 10;
|
|
}
|
|
|
|
out property <int> pos-val <=> spin-min-pos.value;
|
|
spin_min_default := SpinBox { }
|
|
|
|
out property <int> default-min <=> spin-min-default.minimum;
|
|
out property <int> default-val <=> spin-min-default.value;
|
|
|
|
spin_min_neg := SpinBox {
|
|
minimum: -10;
|
|
}
|
|
|
|
out property <int> neg-val <=> spin-min-neg.value;
|
|
}
|
|
|
|
/*
|
|
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
|
|
assert_eq!(instance.get_pos_val(), 10);
|
|
assert_eq!(instance.get_default_min(), 0);
|
|
assert_eq!(instance.get_default_val(), 0);
|
|
assert_eq!(instance.get_neg_val(), -10);
|
|
|
|
let mut label_search = slint_testing::ElementHandle::find_by_element_id(&instance, "TestCase::spin-min-pos").collect::<Vec<_>>();
|
|
assert_eq!(label_search.len(), 1);
|
|
let spinbox = label_search.pop().unwrap();
|
|
assert_eq!(spinbox.accessible_value_maximum(), Some(100f32));
|
|
assert_eq!(spinbox.accessible_value_minimum(), Some(10f32));
|
|
assert_eq!(spinbox.accessible_value_step(), Some(0.9));
|
|
|
|
spinbox.invoke_accessible_increment_action();
|
|
assert_eq!(spinbox.accessible_value().unwrap(), "11");
|
|
|
|
spinbox.invoke_accessible_decrement_action();
|
|
assert_eq!(spinbox.accessible_value().unwrap(), "10");
|
|
|
|
|
|
```
|
|
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
|
|
auto label_search = slint::testing::ElementHandle::find_by_element_id(handle, "TestCase::spin-min-pos");
|
|
assert(label_search.size() == 1);
|
|
auto spinbox = label_search[0];
|
|
assert_eq(spinbox.accessible_value_maximum().value(), 100);
|
|
assert_eq(spinbox.accessible_value_minimum().value(), 10);
|
|
assert_eq(spinbox.accessible_value_step().value(), 0.9);
|
|
|
|
spinbox.invoke_accessible_increment_action();
|
|
assert_eq(spinbox.accessible_value().value(), "11");
|
|
|
|
spinbox.invoke_accessible_decrement_action();
|
|
assert_eq(spinbox.accessible_value().value(), "10");
|
|
|
|
```
|
|
|
|
*/
|