Regler, Schalter und Tempo-Display melden Namen und Wert (#1070) #11
@ -1,7 +1,9 @@
|
||||
//! Bedienelemente im Stil von Musikgeräten: Frontplatte mit Schrauben, Drehregler, Kippschalter mit LED,
|
||||
//! LED-Pegelkette. Die Mathematik (Winkel, Ziehen, LED-Anzahl) ist rein und getestet.
|
||||
|
||||
use eframe::egui::{self, Align2, Color32, FontId, Rect, Response, Sense, Stroke, Ui, pos2, vec2};
|
||||
use eframe::egui::{
|
||||
self, Align2, Color32, FontId, Rect, Response, Role, Sense, Stroke, Ui, WidgetInfo, pos2, vec2,
|
||||
};
|
||||
|
||||
/// Warmes Bernstein als Akzent (Beleuchtung, aktive Elemente).
|
||||
pub const AMBER: Color32 = Color32::from_rgb(255, 176, 48);
|
||||
@ -305,6 +307,8 @@ pub fn knob_sized(
|
||||
FontId::monospace(12.0),
|
||||
AMBER,
|
||||
);
|
||||
// Name und Wert für Barrierefreiheit und automatische Tests (die Beschriftung ist nur gemalt).
|
||||
resp.widget_info(|| WidgetInfo::slider(enabled, f64::from(*value), label));
|
||||
resp.on_hover_text(format!(
|
||||
"{label}: ziehen oder Mausrad (Umschalt = fein), Doppelklick = zurücksetzen"
|
||||
))
|
||||
@ -381,6 +385,7 @@ pub fn toggle(ui: &mut Ui, on: &mut bool, label: &str, enabled: bool) -> Respons
|
||||
FontId::proportional(14.0),
|
||||
dim(Color32::from_gray(225), alpha),
|
||||
);
|
||||
resp.widget_info(|| WidgetInfo::selected(Role::CheckBox, enabled, *on, label));
|
||||
resp
|
||||
}
|
||||
|
||||
@ -417,6 +422,7 @@ pub fn lcd(ui: &mut Ui, text: &str, caption: &str, color: Color32, width: f32) -
|
||||
FontId::monospace(30.0),
|
||||
color,
|
||||
);
|
||||
resp.widget_info(|| WidgetInfo::labeled(Role::Label, true, format!("{caption}: {text}")));
|
||||
resp
|
||||
}
|
||||
|
||||
|
||||
@ -77,3 +77,65 @@ fn roadmap_tab_opens_and_switches_to_the_klicktests_view() {
|
||||
"Zählzeile der Klicktests fehlt"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mixer_knobs_and_toggles_are_found_by_their_names() {
|
||||
let h = harness();
|
||||
assert!(h.state().mode == Mode::Chart);
|
||||
for name in ["Musik", "Sänger", "Zieltöne", "Stimme"] {
|
||||
assert!(
|
||||
h.query_by_label(name).is_some(),
|
||||
"Regler „{name}“ hat keinen Namen"
|
||||
);
|
||||
}
|
||||
for name in [
|
||||
"Original-Sänger",
|
||||
"Original-Kurve",
|
||||
"Taktstriche",
|
||||
"Akkorde",
|
||||
"Gitarrengriffe",
|
||||
] {
|
||||
assert!(
|
||||
h.query_by_label(name).is_some(),
|
||||
"Schalter „{name}“ hat keinen Namen"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clicking_a_custom_toggle_flips_its_setting() {
|
||||
let mut h = harness();
|
||||
// „Original-Kurve“ ist immer aktiv; „Akkorde“ und „Taktstriche“ sind es nur bei Charts mit Akkorden bzw. Raster.
|
||||
let before = h.state().show_original;
|
||||
h.get_by_label("Original-Kurve").click();
|
||||
h.run_steps(3);
|
||||
assert_ne!(
|
||||
h.state().show_original,
|
||||
before,
|
||||
"Klick auf „Original-Kurve“ schaltet nichts um"
|
||||
);
|
||||
h.get_by_label("Original-Kurve").click();
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().show_original, before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_disabled_toggle_does_not_switch() {
|
||||
let mut h = harness();
|
||||
// Das Testchart hat keine Akkorde: der Schalter ist gesperrt.
|
||||
let before = h.state().show_chords;
|
||||
h.get_by_label("Akkorde").click();
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().show_chords, before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_metronome_tempo_display_reports_caption_and_value() {
|
||||
let mut h = harness();
|
||||
h.get_by_label("Stimmanzeige").click();
|
||||
h.run_steps(3);
|
||||
assert!(
|
||||
h.query_by_label_contains("Tempo (Schläge/min): ").is_some(),
|
||||
"Tempo-Anzeige ohne Namen"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user