From 7e5b60317400413d5e3a80b3309f720057cd5830 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 22 Nov 2026 23:56:36 +0700 Subject: [PATCH] ui-contract: trial that files hovering in the pass right after a drop drag and drop on their own --- crates/ui-contract/tests/it/drag/mod.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/ui-contract/tests/it/drag/mod.rs b/crates/ui-contract/tests/it/drag/mod.rs index 5c6d379c8..7b4f8c7c3 100644 --- a/crates/ui-contract/tests/it/drag/mod.rs +++ b/crates/ui-contract/tests/it/drag/mod.rs @@ -308,6 +308,31 @@ fn files_that_leave_the_window_end_the_drag_without_a_drop() { assert!(landed.borrow().rows.is_empty() && landed.borrow().window.is_empty(), "nothing landed"); } +/// Files that hover in the pass right after a drop start a drag of their own, which their drop ends on the target under +/// the pointer, with or without the pointer moving. +#[trial] +fn files_hovering_right_after_a_drop_drag_and_drop_on_their_own() { + let landed = RefCell::new(Landed::default()); + let mut frames = Frames::new(); + let mut show = |ui: &mut Ui| { + FileList { common: Common::new(), landed: &landed }.id_salt("files").show_at(ui, LIST); + }; + let row = |n: usize| LIST.min + Vec2::new(LIST.width() / 2.0, (n as f32 + 0.5) * ROW); + frames.idle(2, &mut show); + for (file, events) in [("a.png", vec![moved(row(0))]), ("b.png", vec![moved(row(1))]), ("c.png", vec![])] { + frames.hover_files(&[file]); + frames.frame(events, &mut show); + let held = drag::active::(&frames.ctx).map(|files| names(&files)); + assert_eq!(held, Some(vec![file.to_owned()]), "the hovering files are the payload, not the last drop's"); + frames.drop_files(&[file]); + frames.frame(vec![], &mut show); + } + frames.frame(vec![], &mut show); + let on = |n: usize, file: &str| (n, vec![file.to_owned()]); + assert_eq!(landed.borrow().rows, vec![on(0, "a.png"), on(1, "b.png"), on(1, "c.png")], "each drop lands on its row"); + assert!(drag::active::(&frames.ctx).is_none(), "the last drop ends the drag"); +} + /// Where the window's inner rect sits on the desktop in the desktop-pointer trial. const WINDOW_AT: Pos2 = Pos2::new(100.0, 50.0);