Exercise top and bottom toolbar docking at two window widths

(cherry picked from commit 5cc98a8448)
This commit is contained in:
Codex
2026-11-30 18:38:57 +01:00
committed by FredApps
parent c290b47849
commit 9fc46a5cc3
+21
View File
@@ -1576,6 +1576,27 @@ fn dock(h: &mut Harness<'static, PdfCraftApp>, c: &ControlClient) -> Value {
ok(h, c, "ui.panel", json!({"panel": "side"}))["side_panels"].clone()
}
/// Dropping the toolbar on the page's top or bottom edge reserves its controls and grip.
#[test]
fn a_horizontal_toolbar_fits_its_controls_above_or_below_the_page() {
use egui::accesskit::Role;
for edge in ["Top", "Bottom"] {
let (mut h, c) = harness();
ok(&mut h, &c, "ui.set", json!({"key":"mode","value":"edit"}));
ok(&mut h, &c, "ui.dock.apply", json!({"action":{"Move":{"panel":"toolbar","anchor":"document","placement":{"Edge":edge}}}}));
for width in [1400.0, 820.0, 1400.0] {
h.set_size(egui::vec2(width, 900.0));
h.run_steps(6);
let rail = h.get_by_role_and_label(Role::Toolbar, "Toolbar").rect();
let pages = h.get_by_role_and_label(Role::Canvas, "Pages").rect();
let grip = h.get_by_role_and_label(Role::Button, "Toolbar").rect();
let gap = if edge == "Top" { pages.top() - rail.bottom() } else { grip.top() - pages.bottom() };
assert!((-1.0..=12.0).contains(&gap), "{edge}, width {width}: {gap} blank points between the toolbar and the pages");
assert!(rail.contains(h.get_by_role_and_label(Role::Button, "Edit toolbar").rect().center()));
}
}
}
#[test]
fn ui_panel_opens_closes_and_sizes_panes_and_survives_restore() {
let (mut h, c) = harness();