Preserve passive canvas geometry while contextual help is open
This commit is contained in:
@@ -1383,6 +1383,16 @@ impl App {
|
||||
| Message::SourceSymbolsReady(_)
|
||||
| Message::SourceRenameReady(_)
|
||||
| Message::DiagramUsagesReady(_)
|
||||
| Message::ScenarioCanvas(
|
||||
behavior::scenario::CanvasEvent::Scrolled(..)
|
||||
| behavior::scenario::CanvasEvent::Restored(..)
|
||||
| behavior::scenario::CanvasEvent::Viewport(..)
|
||||
)
|
||||
| Message::TopologyCanvas(
|
||||
behavior::topology::CanvasEvent::Scrolled(..)
|
||||
| behavior::topology::CanvasEvent::Viewport(..)
|
||||
)
|
||||
| Message::StateDiagram(behavior::state_edit::Event::Viewport(..))
|
||||
)
|
||||
{
|
||||
return Task::none();
|
||||
|
||||
@@ -272,3 +272,77 @@ fn context_help_rejects_a_reference_picker_open_queued_from_the_inspector() {
|
||||
before
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn context_help_accepts_live_process_viewport_and_rejects_stale_measurements() {
|
||||
use crate::behavior::topology::CanvasEvent;
|
||||
let mut project = Project::empty();
|
||||
let owner = project
|
||||
.add_element(Kind::Process, Layer::Oa, "Response process", None)
|
||||
.unwrap();
|
||||
let mut app = App::with_project(project);
|
||||
send(&mut app, Message::Select(owner));
|
||||
send(&mut app, Message::Page(Page::Behavior));
|
||||
let context = app.topology_context().unwrap();
|
||||
send(
|
||||
&mut app,
|
||||
Message::TopologyCanvas(CanvasEvent::Viewport(context, iced::Size::new(640., 480.))),
|
||||
);
|
||||
let initial = app.behavior.topology.camera_boundary();
|
||||
let before = app.document.snapshot();
|
||||
send(&mut app, Message::Help);
|
||||
assert!(app.context_help);
|
||||
assert_eq!(app.guide.topic, Topic::Chains);
|
||||
|
||||
let resized = iced::Size::new(420., 330.);
|
||||
let context = app.topology_context().unwrap();
|
||||
send(
|
||||
&mut app,
|
||||
Message::TopologyCanvas(CanvasEvent::Viewport(context, resized)),
|
||||
);
|
||||
let measured = app.behavior.topology.camera_boundary();
|
||||
assert!(
|
||||
measured != initial,
|
||||
"Help must admit passive viewport measurements"
|
||||
);
|
||||
assert!(app.context_help);
|
||||
let epoch = app.canvas_epoch;
|
||||
for field in 0..3 {
|
||||
let mut stale = app.topology_context().unwrap();
|
||||
match field {
|
||||
0 => stale.document = Id::new_v4(),
|
||||
1 => stale.owner = Id::new_v4(),
|
||||
_ => stale.revision += 1,
|
||||
}
|
||||
send(
|
||||
&mut app,
|
||||
Message::TopologyCanvas(CanvasEvent::Viewport(stale, iced::Size::new(999., 777.))),
|
||||
);
|
||||
assert!(app.behavior.topology.camera_boundary() == measured);
|
||||
assert_eq!(app.canvas_epoch, epoch);
|
||||
}
|
||||
|
||||
send(&mut app, Message::CloseContextHelp);
|
||||
assert!(!app.context_help);
|
||||
assert!(app.behavior.topology.camera_boundary() == measured);
|
||||
let context = app.topology_context().unwrap();
|
||||
let epoch = app.canvas_epoch;
|
||||
send(
|
||||
&mut app,
|
||||
Message::TopologyCanvas(CanvasEvent::Viewport(context, resized)),
|
||||
);
|
||||
assert_eq!(
|
||||
app.canvas_epoch, epoch,
|
||||
"The size observed behind Help is already current"
|
||||
);
|
||||
let context = app.topology_context().unwrap();
|
||||
send(
|
||||
&mut app,
|
||||
Message::TopologyCanvas(CanvasEvent::Viewport(context, iced::Size::new(700., 500.))),
|
||||
);
|
||||
assert!(app.behavior.topology.camera_boundary() != measured);
|
||||
assert_eq!(app.page, Page::Behavior);
|
||||
assert_eq!(app.selected, owner);
|
||||
assert!(Arc::ptr_eq(&before, &app.document.snapshot()));
|
||||
assert!(!app.document.can_undo());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user