mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add container_labelled_by test
This commit is contained in:
@@ -695,8 +695,8 @@ impl<State> Harness<'_, State> {
|
||||
|
||||
/// Render a snapshot, save it to a temp file and open it in the default image viewer.
|
||||
///
|
||||
/// This method is marked as deprecated to trigger errors in CI (so that it's not accidentally
|
||||
/// committed).
|
||||
/// This method is marked as deprecated to trigger errors in CI (so that it's usages are not
|
||||
/// accidentally committed). It's fine to use it for debugging.
|
||||
#[deprecated = "Only for debugging, don't commit this."]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn debug_open_snapshot(&mut self) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use egui::{Modifiers, ScrollArea, Vec2, include_image};
|
||||
use egui::{include_image, Modifiers, ScrollArea, Vec2};
|
||||
use egui_kittest::{Harness, SnapshotResults};
|
||||
use kittest::Queryable as _;
|
||||
use kittest::{NodeT, Queryable as _};
|
||||
|
||||
#[test]
|
||||
fn test_shrink() {
|
||||
@@ -214,3 +214,31 @@ fn test_remove_cursor() {
|
||||
"The button appearance should change"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_container_labelled_by() {
|
||||
let mut harness = Harness::new_ui(|ui| {
|
||||
_ = ui.button("Duplicate");
|
||||
|
||||
_ = ui.group(|ui| {
|
||||
let group_label = ui.label("Labelled inside");
|
||||
ui.response().labelled_by(group_label.id);
|
||||
ui.label("Duplicate");
|
||||
});
|
||||
|
||||
let group_label = ui.label("Labelled outside");
|
||||
_ = ui
|
||||
.group(|ui| {
|
||||
ui.label("Duplicate");
|
||||
})
|
||||
.response
|
||||
.labelled_by(group_label.id);
|
||||
});
|
||||
|
||||
let group = harness.get_by_role_and_label(egui::accesskit::Role::GenericContainer, "Labelled inside");
|
||||
group.get_by_label("Duplicate");
|
||||
|
||||
// TODO: This panics, we should make it work somehow
|
||||
let group = harness.get_by_role_and_label(egui::accesskit::Role::GenericContainer, "Labelled outside");
|
||||
group.get_by_label("Duplicate");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user