mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-26 03:06:56 -06:00
Integration: Control bar tests read #255's object Control groups
#112's and #142's Control bar tests found controls by accessibility label (Fill, Columns, Y:). #255 replaces control_object with object_control::show, whose captions are painted and whose last group with nothing text-specific selected is Align. The tests now use #255's group responses (("object_control", id)): #142's second-row test checks the X/Y/W/H group, #112's scroll test uses Align bottom edges as the last control and opens the Fill picker from the appearance group with a frame selected (#255 disables the controls without a selection), and the one-line caption test checks that the text frame's Columns group keeps its full width after scrolling.
This commit is contained in:
@@ -556,8 +556,8 @@ mod tests {
|
||||
|
||||
use crate::test_window::{self, wheel};
|
||||
|
||||
/// The Control panel's last control with nothing selected.
|
||||
const LAST_CONTROL: &str = "Jump to Next Column";
|
||||
/// The Control panel's last control with no text frame selected.
|
||||
const LAST_CONTROL: &str = "Align bottom edges";
|
||||
const FIRST_CONTROL: &str = "Rotate 90° Counterclockwise";
|
||||
|
||||
fn app() -> crate::DesignApp {
|
||||
@@ -566,6 +566,20 @@ mod tests {
|
||||
app
|
||||
}
|
||||
|
||||
/// A document with a rectangle selected, so the object controls are enabled.
|
||||
fn app_with_selection() -> crate::DesignApp {
|
||||
let mut app = app();
|
||||
app.run("file.new", serde_json::json!({})).unwrap();
|
||||
app.run("frame.create", serde_json::json!({"rect": [72, 72, 300, 200]})).unwrap();
|
||||
app.run("edit.selectAll", serde_json::json!({})).unwrap();
|
||||
app
|
||||
}
|
||||
|
||||
/// The rect of an object Control panel group.
|
||||
fn group(h: &egui_kittest::Harness<'static, test_window::Window>, id: &str) -> egui::Rect {
|
||||
h.ctx.read_response(egui::Id::new(("object_control", id))).unwrap().rect
|
||||
}
|
||||
|
||||
fn rect(h: &egui_kittest::Harness<'static, test_window::Window>, label: &str) -> egui::Rect {
|
||||
h.get_by_label(label).rect()
|
||||
}
|
||||
@@ -573,7 +587,7 @@ mod tests {
|
||||
#[test]
|
||||
fn a_narrow_window_scrolls_the_control_bar() {
|
||||
let w = 700.0;
|
||||
let mut h = test_window::open(app(), vec2(w, 600.0));
|
||||
let mut h = test_window::open(app_with_selection(), vec2(w, 600.0));
|
||||
let bar = test_window::panel_rect(&h, "control_bar");
|
||||
assert!(rect(&h, LAST_CONTROL).max.x > w, "the controls are wider than the window");
|
||||
// A plain mouse wheel scrolls the bar sideways.
|
||||
@@ -584,8 +598,9 @@ mod tests {
|
||||
assert!(window.contains_rect(last) && bar.contains_rect(last), "{last:?} outside the bar {bar:?}");
|
||||
assert_eq!(test_window::panel_rect(&h, "control_bar").height(), bar.height(), "the bar keeps its height");
|
||||
// A popup opened from a scrolled control opens at that control.
|
||||
let fill = h.get_by_label("Fill").rect();
|
||||
let chip = pos2(fill.max.x + 15.0, fill.center().y);
|
||||
let appearance = group(&h, "appearance");
|
||||
let fill = egui::Rect::from_min_size(appearance.min, vec2(30.0, crate::widgets::FIELD_H));
|
||||
let chip = pos2(fill.min.x + 9.0, fill.center().y);
|
||||
h.hover_at(chip);
|
||||
h.drag_at(chip);
|
||||
h.drop_at(chip);
|
||||
@@ -626,8 +641,8 @@ mod tests {
|
||||
let mut h = test_window::open(app, vec2(700.0, 600.0));
|
||||
let bar = test_window::panel_rect(&h, "control_bar").center();
|
||||
wheel(&mut h, bar, vec2(0.0, -3000.0));
|
||||
// The text frame's last group: its caption gets only what is left of the row.
|
||||
let columns = h.get_by_label("Columns").rect();
|
||||
assert!(columns.height() < 20.0 && columns.width() > columns.height(), "Columns wraps: {columns:?}");
|
||||
// The text frame's last group keeps its full size, not only what is left of the row.
|
||||
let columns = group(&h, "columns");
|
||||
assert!(columns.width() >= 48.0 && columns.max.x <= 700.0, "Columns group squeezed or off screen: {columns:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1120,7 +1120,6 @@ mod tests {
|
||||
/// row hung below the panel and was cut off.
|
||||
#[test]
|
||||
fn control_bar_shows_its_second_row() {
|
||||
use egui_kittest::kittest::Queryable as _;
|
||||
let mut app = DesignApp::new(designcraft_engine::Session::new(), Services::default());
|
||||
app.run("file.newSample", json!({})).unwrap();
|
||||
app.ui.control_bar = true;
|
||||
@@ -1135,9 +1134,10 @@ mod tests {
|
||||
h.run_steps(4);
|
||||
let bar = egui::containers::panel::PanelState::load(&h.ctx, egui::Id::new("control_bar")).unwrap().outer_rect;
|
||||
assert!(bar.height() > 40.0, "{bar:?}");
|
||||
let rows: Vec<egui::Rect> = h.query_all_by_label("Y:").map(|n| n.rect()).filter(|r| bar.contains(r.left_top())).collect();
|
||||
assert_eq!(rows.len(), 1, "the Y: caption of the Control panel");
|
||||
assert!(rows[0].bottom() <= bar.bottom(), "Y: caption {:?} hangs below the Control panel {bar:?}", rows[0]);
|
||||
// The X/Y/W/H group: its second row holds Y: and H:.
|
||||
let group = h.ctx.read_response(egui::Id::new(("object_control", "dimensions"))).unwrap().rect;
|
||||
assert!(bar.contains(group.left_top()), "the X/Y/W/H group {group:?} is in the Control panel {bar:?}");
|
||||
assert!(group.bottom() <= bar.bottom(), "X/Y/W/H group {group:?} hangs below the Control panel {bar:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user