1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Add container_labelled_by test

This commit is contained in:
lucasmerlin
2026-02-26 09:36:30 +01:00
parent e0bac4e260
commit 1e07512e84
3 changed files with 39 additions and 10 deletions

View File

@@ -2558,11 +2558,12 @@ dependencies = [
[[package]] [[package]]
name = "kurbo" name = "kurbo"
version = "0.11.1" version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89234b2cc610a7dd927ebde6b41dd1a5d4214cffaef4cf1fb2195d592f92518f" checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"euclid",
"smallvec", "smallvec",
] ]
@@ -4327,7 +4328,7 @@ version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc"
dependencies = [ dependencies = [
"kurbo 0.11.1", "kurbo 0.11.3",
"siphasher", "siphasher",
] ]
@@ -4663,9 +4664,9 @@ dependencies = [
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.25.0" version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5902c5d130972a0000f60860bfbf46f7ca3db5391eddfedd1b8728bd9dc96c0e" checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31"
dependencies = [ dependencies = [
"core_maths", "core_maths",
] ]
@@ -4829,7 +4830,7 @@ dependencies = [
"flate2", "flate2",
"fontdb", "fontdb",
"imagesize", "imagesize",
"kurbo 0.11.1", "kurbo 0.11.3",
"log", "log",
"pico-args", "pico-args",
"roxmltree", "roxmltree",

View File

@@ -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. /// 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 /// This method is marked as deprecated to trigger errors in CI (so that it's usages are not
/// committed). /// accidentally committed). It's fine to use it for debugging.
#[deprecated = "Only for debugging, don't commit this."] #[deprecated = "Only for debugging, don't commit this."]
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub fn debug_open_snapshot(&mut self) { pub fn debug_open_snapshot(&mut self) {

View File

@@ -1,6 +1,6 @@
use egui::{Modifiers, ScrollArea, Vec2, include_image}; use egui::{include_image, Modifiers, ScrollArea, Vec2};
use egui_kittest::{Harness, SnapshotResults}; use egui_kittest::{Harness, SnapshotResults};
use kittest::Queryable as _; use kittest::{NodeT, Queryable as _};
#[test] #[test]
fn test_shrink() { fn test_shrink() {
@@ -214,3 +214,31 @@ fn test_remove_cursor() {
"The button appearance should change" "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");
}