mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-03 00:41:56 -06:00
test(ui): cover runtime tooltips and current region shortcut
This commit is contained in:
@@ -44,6 +44,7 @@ const SHORTCUTS: &[(&str, &str, &str, Option<&str>)] = &[
|
||||
("home.alignLeft", "", "⌘L", None),
|
||||
("home.alignCenter", "", "⌘E", None),
|
||||
("selection.row", "", "Shift+Space", Some("Shift+Space")),
|
||||
("selection.currentRegion", "", "Control+Shift+8", Some("Ctrl+Shift+8")),
|
||||
("selection.column", "", "Control+Space", Some("Ctrl+Space")),
|
||||
("view.showObjects", "", "Control+6", Some("Ctrl+6")),
|
||||
("formulas.showFormulas", "Show Formulas", "⌘`", Some("Ctrl+`")),
|
||||
@@ -747,4 +748,23 @@ mod tooltip_shortcut_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ribbon_tip_text_obeys_runtime_os() {
|
||||
use egui::os::OperatingSystem;
|
||||
|
||||
for (os, expected) in [(OperatingSystem::Windows, "Flash Fill (Ctrl+E)"), (OperatingSystem::Mac, "Flash Fill (Control+E)")] {
|
||||
let ctx = egui::Context::default();
|
||||
ctx.set_os(os);
|
||||
|
||||
let mut actual = String::new();
|
||||
|
||||
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
|
||||
actual = super::tip_text(ui, "Flash Fill");
|
||||
});
|
||||
output.textures_delta.clear();
|
||||
|
||||
assert_eq!(actual, expected, "{os:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,3 +229,25 @@ fn command_palette_and_ribbon_tooltips_share_shortcuts() {
|
||||
assert_eq!(command_shortcut("selection.row", false), Some("Shift+Space"));
|
||||
assert_eq!(command_shortcut("unverified.command", false), None);
|
||||
}
|
||||
|
||||
/// Current Region must show the physical Control shortcut on both platforms.
|
||||
#[test]
|
||||
fn command_search_shows_current_region_shortcut() {
|
||||
use egui::os::OperatingSystem;
|
||||
|
||||
for (os, expected) in
|
||||
[(OperatingSystem::Windows, "Select Current Region (Ctrl+Shift+8)"), (OperatingSystem::Mac, "Select Current Region (Control+Shift+8)")]
|
||||
{
|
||||
let mut h = harness();
|
||||
h.ctx.set_os(os);
|
||||
h.run_steps(2);
|
||||
|
||||
h.state_mut().open_dialog("commandSearch", json!({}));
|
||||
h.run_steps(6);
|
||||
|
||||
h.state_mut().dialog.as_mut().unwrap().search = "selection.currentRegion".into();
|
||||
|
||||
h.run_steps(3);
|
||||
h.get_by_label_contains(expected);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user