Testing: Add minimum/maximum support (#5192)

This commit is contained in:
Montel Laurent 2024-05-10 16:18:02 +02:00 committed by GitHub
parent 25ef8f8711
commit c37c9d4f26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 108 additions and 2 deletions

View file

@ -88,6 +88,57 @@ public:
return std::nullopt;
}
/// Returns the accessible-value-maximum of that element, if any.
std::optional<float> accessible_value_maximum() const
{
if (auto item = private_api::upgrade_item_weak(inner)) {
SharedString result;
if (item->item_tree.vtable()->accessible_string_property(
item->item_tree.borrow(), item->index,
cbindgen_private::AccessibleStringProperty::ValueMaximum, &result)) {
float value = 0.0;
if (cbindgen_private::slint_string_to_float(&result, &value)) {
return value;
}
}
}
return std::nullopt;
}
/// Returns the accessible-value-minimum of that element, if any.
std::optional<float> accessible_value_minimum() const
{
if (auto item = private_api::upgrade_item_weak(inner)) {
SharedString result;
if (item->item_tree.vtable()->accessible_string_property(
item->item_tree.borrow(), item->index,
cbindgen_private::AccessibleStringProperty::ValueMinimum, &result)) {
float value = 0.0;
if (cbindgen_private::slint_string_to_float(&result, &value)) {
return value;
}
}
}
return std::nullopt;
}
/// Returns the accessible-value-step of that element, if any.
std::optional<float> accessible_value_step() const
{
if (auto item = private_api::upgrade_item_weak(inner)) {
SharedString result;
if (item->item_tree.vtable()->accessible_string_property(
item->item_tree.borrow(), item->index,
cbindgen_private::AccessibleStringProperty::ValueStep, &result)) {
float value = 0.0;
if (cbindgen_private::slint_string_to_float(&result, &value)) {
return value;
}
}
}
return std::nullopt;
}
/// Returns the accessible-checked of that element, if any.
std::optional<bool> accessible_checked() const
{