mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 19:14:26 +00:00
FW-276 trials: a context request on a collapsed floating window's band opens its menu, and Close closes the window
This commit is contained in:
@@ -8,7 +8,7 @@ use craft_ui::docking::{DockConfig, DockPanels, GroupDrag, PanelSpec, request_ac
|
||||
use craft_ui::layout_components::Stack;
|
||||
use craft_ui::patterns::dock::DockArea;
|
||||
use craft_ui::runtime::drag::{self, DropMark};
|
||||
use craft_ui::testing::pointer::{moved, press, release};
|
||||
use craft_ui::testing::pointer::{moved, press, release, secondary};
|
||||
use craft_ui::testing::{Fixture, trial};
|
||||
use egui::{Modifiers, Pos2, Rect, Ui, Vec2};
|
||||
use std::cell::{Cell, RefCell};
|
||||
@@ -437,6 +437,28 @@ fn a_double_click_on_a_floating_windows_band_collapses_and_expands_its_column()
|
||||
assert!(!bed.workspace.borrow().layout.floating[0].column.iconic, "a second double click expanded it: {:?}", bed.actions.borrow());
|
||||
}
|
||||
|
||||
/// A collapsed floating window's title row is its column's bar alone: a context request on its band opens the
|
||||
/// window's menu, whose Close entry closes the window.
|
||||
#[trial]
|
||||
fn a_context_request_on_a_collapsed_windows_band_opens_its_menu_and_close_closes_it() {
|
||||
let mut bed = bed(collapsed_at(WINDOW_AT), |_| Permissions::ALL);
|
||||
let icon = button_rect(&bed, &title(WINDOW)).expect("the collapsed window shows its icon");
|
||||
let band = Pos2::new(icon.left() + 4.0, WINDOW_AT.top() + 6.0);
|
||||
bed.fixture.frame(vec![moved(band)]);
|
||||
bed.fixture.frame(vec![secondary(band, true)]);
|
||||
bed.fixture.frame(vec![secondary(band, false)]);
|
||||
bed.fixture.settle();
|
||||
let tree = bed.fixture.tree();
|
||||
let items: Vec<_> =
|
||||
bed.fixture.by_role(Role::MENU_ITEM).into_iter().map(|item| (craft_ui::testing::access::name(tree, item.node), item)).collect();
|
||||
let names: Vec<_> = items.iter().map(|(name, _)| *name).collect();
|
||||
let close = items.iter().find(|(name, _)| name.is_some_and(|name| name.starts_with("Close"))).map(|(_, item)| *item);
|
||||
let close = close.unwrap_or_else(|| panic!("the band's context request opens the window's menu with a Close entry: {names:?}"));
|
||||
bed.fixture.click(&close);
|
||||
bed.fixture.settle();
|
||||
assert!(bed.workspace.borrow().layout.floating.is_empty(), "Close closed the window: {:?}", bed.actions.borrow());
|
||||
}
|
||||
|
||||
/// Nothing goes beside a floating window: a tab dragged over the start side of its group marks the join of the
|
||||
/// group, not a split; and a tab dropped on a collapsed window's icon joins its group, which stays collapsed.
|
||||
#[trial]
|
||||
@@ -484,10 +506,14 @@ fn a_settled_collapsed_window_runs_no_more_passes_than_an_expanded_one() {
|
||||
#[trial]
|
||||
fn diag_window_move() {
|
||||
let mut bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
|
||||
for group in bed.fixture.by_role(Role::GROUP) { eprintln!("DIAG group {:?}", group.rect); }
|
||||
for group in bed.fixture.by_role(Role::GROUP) {
|
||||
eprintln!("DIAG group {:?}", group.rect);
|
||||
}
|
||||
eprintln!("DIAG title_row {} at {:?}", bed.title_row.get(), window_title());
|
||||
let tree = bed.fixture.tree();
|
||||
for b in bed.fixture.by_role(Role::BUTTON) { eprintln!("DIAG button {:?} {:?}", craft_ui::testing::access::name(tree, b.node), b.rect); }
|
||||
for b in bed.fixture.by_role(Role::BUTTON) {
|
||||
eprintln!("DIAG button {:?} {:?}", craft_ui::testing::access::name(tree, b.node), b.rect);
|
||||
}
|
||||
eprintln!("DIAG layers {:?}", craft_ui::testing::snapshot::layer_rects(bed.fixture.ctx()));
|
||||
let from = window_title();
|
||||
bed.fixture.frame(vec![moved(from)]);
|
||||
@@ -495,6 +521,11 @@ fn diag_window_move() {
|
||||
eprintln!("DIAG drag_part {:?} click_part {:?}", bed.fixture.drag_part(), bed.fixture.click_part());
|
||||
for step in 1..=4 {
|
||||
bed.fixture.frame(vec![moved(from + Vec2::new(-40.0, 30.0) * (step as f32 / 4.0))]);
|
||||
eprintln!("DIAG step {step} rect {:?} dragging {} actions {:?}", bed.workspace.borrow().layout.floating[0].rect, dragging(&bed), bed.actions.borrow());
|
||||
eprintln!(
|
||||
"DIAG step {step} rect {:?} dragging {} actions {:?}",
|
||||
bed.workspace.borrow().layout.floating[0].rect,
|
||||
dragging(&bed),
|
||||
bed.actions.borrow()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user