From 1e07512e84ed39003c54b7f7f48c2e10f40a9720 Mon Sep 17 00:00:00 2001 From: lucasmerlin Date: Thu, 26 Feb 2026 09:36:30 +0100 Subject: [PATCH] Add container_labelled_by test --- Cargo.lock | 13 ++++++------ crates/egui_kittest/src/snapshot.rs | 4 ++-- crates/egui_kittest/tests/tests.rs | 32 +++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9173deaff..0cd01625e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2558,11 +2558,12 @@ dependencies = [ [[package]] name = "kurbo" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89234b2cc610a7dd927ebde6b41dd1a5d4214cffaef4cf1fb2195d592f92518f" +checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62" dependencies = [ "arrayvec", + "euclid", "smallvec", ] @@ -4327,7 +4328,7 @@ version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" dependencies = [ - "kurbo 0.11.1", + "kurbo 0.11.3", "siphasher", ] @@ -4663,9 +4664,9 @@ dependencies = [ [[package]] name = "ttf-parser" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5902c5d130972a0000f60860bfbf46f7ca3db5391eddfedd1b8728bd9dc96c0e" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" dependencies = [ "core_maths", ] @@ -4829,7 +4830,7 @@ dependencies = [ "flate2", "fontdb", "imagesize", - "kurbo 0.11.1", + "kurbo 0.11.3", "log", "pico-args", "roxmltree", diff --git a/crates/egui_kittest/src/snapshot.rs b/crates/egui_kittest/src/snapshot.rs index 28b5ac986..388262f8f 100644 --- a/crates/egui_kittest/src/snapshot.rs +++ b/crates/egui_kittest/src/snapshot.rs @@ -695,8 +695,8 @@ impl 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) { diff --git a/crates/egui_kittest/tests/tests.rs b/crates/egui_kittest/tests/tests.rs index 81f861451..8887a8f43 100644 --- a/crates/egui_kittest/tests/tests.rs +++ b/crates/egui_kittest/tests/tests.rs @@ -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"); +}