Draw the in-window View menu in the regression harness

This commit is contained in:
Dan committed 2026-11-29 14:48:05 +00:00
1 parent ca2ccf4f3f
commit 883ffd5d29
1 file changed
+9 -2
@@ -1,3 +1,4 @@
use craft::window::policy::{CaptionFamily, Captions, Decision, Desktop, DesktopKind, Frame};
use egui::accesskit::Role;
use egui::{Event, Key, Modifiers, PointerButton};
use egui_kittest::Harness;
@@ -22,7 +23,12 @@ fn control(h: &mut AppHarness, method: &str, params: Value) -> Result<Value, Str
fn at_minimum(width: u32, height: u32, zoom: f32) -> Result<AppHarness, String> {
let mut session = photocraft_engine::Session::new();
session.execute("file.new", json!({"width": width, "height": height, "background": "transparent"})).map_err(|error| error.to_string())?;
let mut h = app_harness(PhotocraftApp::new(session, crate::Services::default()));
// Use the drawn title bar on every host so the View menu appears in the harness's tree.
let ctx = egui::Context::default();
let frame = Frame::Integrated(Captions { family: CaptionFamily::Windows, layout: craft::window::Layout::default() });
let desktop = Desktop { kind: DesktopKind::Other, ssd: None, gtk_theme: None, icon_theme: None };
PhotocraftApp::setup_window(&ctx, Default::default(), Decision { frame, overridden: None, desktop }, None);
let mut h = app_harness(PhotocraftApp::with_context(ctx, session, crate::Services::default()));
assert_eq!(control(&mut h, "ui.set", json!({"zoom": zoom}))?["ok"], true);
h.run_steps(4);
assert_eq!(h.state().current_zoom(), zoom);
@@ -47,13 +53,14 @@ fn zoom_out_is_disabled_at_the_document_minimum_and_reenabled_after_zoom_in() ->
assert!(!zoom_out_menu_enabled(&mut h)?);
assert_eq!(control(&mut h, "ui.menu.invoke", json!({"id": "view.zoomOut"}))?["ok"], false);
let at = h.get_by_role_and_label(Role::MenuItem, "View").rect().center();
let at = h.get_by_label("View").rect().center();
h.event(Event::PointerMoved(at));
h.step();
for pressed in [true, false] {
h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE });
h.step();
}
h.run_steps(6);
assert!(h.get_by_role_and_label(Role::MenuItem, "Zoom Out").accesskit_node().is_disabled());
h.key_press(Key::Escape);