From 8733f3c65de9777e12ecf3138a6618a28dd01abb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 3 Nov 2026 22:13:33 -0800 Subject: [PATCH] Tests: the Color Picker's R, G and B fields show the working RGB values The new test opens the Color Picker in each working RGB profile and reads the R, G and B fields the dialog draws. It fails when the fields show the display sRGB values instead. --- .../ui-egui/tests/color_working_components.rs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/ui-egui/tests/color_working_components.rs b/crates/ui-egui/tests/color_working_components.rs index 85f392416..83b0e0126 100644 --- a/crates/ui-egui/tests/color_working_components.rs +++ b/crates/ui-egui/tests/color_working_components.rs @@ -110,6 +110,39 @@ fn picker_initialization_preserves_working_values() { } } +/// The picker's R, G and B fields show the stored RGB components in every working profile. +#[test] +fn picker_rgb_fields_show_working_values() { + use egui_kittest::kittest::Queryable; + + for profile in [SRGB, DISPLAY_P3, WIDE_GAMUT_RGB, PROPHOTO_RGB] { + let _space = WorkingSpace::new(profile); + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 100})).unwrap(); + app.run("ui.colorPicker", json!({"color": [0.6, 0.4, 0.2]})).unwrap(); + let mut fonts = false; + let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 900.0)).with_accessibility_check(false).build_ui_state( + move |ui, app: &mut VectorcraftApp| { + if !std::mem::replace(&mut fonts, true) { + vectorcraft_ui_egui::theme::install_fonts(ui.ctx()); + return; + } + vectorcraft_ui_egui::dialogs::show(app, ui.ctx()); + }, + app, + ); + harness.run_steps(3); + // HSB's Brightness field is also labelled B, so the fields labelled B are read together. + for (label, expected) in [("R", "153"), ("G", "102"), ("B", "51")] { + let values: Vec = harness + .query_all_by_role_and_label(egui::accesskit::Role::TextInput, label) + .filter_map(|field| field.value().map(|v| v.to_string())) + .collect(); + assert!(values.iter().any(|v| v == expected), "{profile}: {label} shows {values:?}"); + } + } +} + /// Shared hex and web-safe numeric controls round the native working RGB components. #[test] fn shared_hex_and_websafe_preserve_working_values() {