mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Canvas menu tests: a switch away closes the menu for good, as main's sync_views does
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
15d6f73331
commit
83dcfd287d
1 file changed
+6
-5
@@ -1,6 +1,6 @@
|
||||
//! #12359: a canvas right-click menu belongs to the document it was opened on. When another
|
||||
//! document becomes active it closes (`close_stale`), `ui.context.choose` refuses its rows with an error
|
||||
//! and closes it, and neither document changes. With the same document active it works as before.
|
||||
//! and closes it, and neither document changes. With its document still active it works as before.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
@@ -67,7 +67,7 @@ fn a_layer_row_chosen_after_a_document_switch_runs_nowhere() {
|
||||
|
||||
#[test]
|
||||
fn the_menu_closes_when_another_document_becomes_active() {
|
||||
let (mut app, ctx) = two_documents(Tool::RectMarquee);
|
||||
let (mut app, _ctx) = two_documents(Tool::RectMarquee);
|
||||
right_click(&mut app, 16.0, 16.0);
|
||||
let menu = app.ui.canvas_tool_menu.clone().unwrap();
|
||||
assert!(menu.doc.is_some(), "the menu records its document");
|
||||
@@ -75,6 +75,8 @@ fn the_menu_closes_when_another_document_becomes_active() {
|
||||
activate(&mut app, 1);
|
||||
assert!(!available(&app, &menu, "layer.new.layerViaCut"), "no row is available on another document");
|
||||
assert!(!entry_enabled(&app, &menu, "layer.new.layerViaCut"), "and none lists as enabled");
|
||||
// Even when the switch reached the menu before `sync_views` did, the next frame closes it.
|
||||
app.ui.canvas_tool_menu = Some(menu);
|
||||
close_stale(&mut app);
|
||||
assert!(app.ui.canvas_tool_menu.is_none(), "the next frame closes it");
|
||||
}
|
||||
@@ -84,9 +86,8 @@ fn the_menu_still_works_on_its_own_document() {
|
||||
let (mut app, ctx) = two_documents(Tool::RectMarquee);
|
||||
right_click(&mut app, 16.0, 16.0);
|
||||
let layers = app.session.active().unwrap().doc.layers.len();
|
||||
// A switch away and back: the menu's document is active again.
|
||||
activate(&mut app, 1);
|
||||
activate(&mut app, 0);
|
||||
// Its document stays active: the recorded document matches, so the row runs. (A switch away
|
||||
// closes the menu for good, `sync_views`, even when the document comes back.)
|
||||
let r = choose(&mut app, &ctx, "layer.new.layerViaCut");
|
||||
assert_eq!(r["ok"], true, "{r}");
|
||||
assert_eq!(app.session.active().unwrap().doc.layers.len(), layers + 1, "Layer Via Cut ran on A");
|
||||
|
||||
Reference in new issue
Block a user