From ead70695c80ba6078604d6ff30388d3e15ff476e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 5 Oct 2026 18:12:42 -0400 Subject: [PATCH] Tests: dropping a PDF on the window, and hovering a comment (two features now shipped) Both features worked but had no test, so parity listed them as partial: - core.drag-drop-open: a file dropped on the window opens in a tab (ui.rs::dropping_a_pdf_on_the_window_opens_it, through egui's DroppedFile). - view.annotation-hover: hovering a comment shows a popup with its author and text (comments.rs::hovering_a_comment_shows_its_author_and_text). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/tests/comments.rs | 25 +++++++++++++++++++++++++ crates/ui-egui/tests/ui.rs | 28 ++++++++++++++++++++++++++++ parity/acrobat-features.toml | 12 ++++++------ 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/tests/comments.rs b/crates/ui-egui/tests/comments.rs index 5ce5520e71..1fafe9a508 100644 --- a/crates/ui-egui/tests/comments.rs +++ b/crates/ui-egui/tests/comments.rs @@ -529,3 +529,28 @@ fn erasing_part_of_a_drawing() { drag_pt(&mut h, (40.0, 60.0), (260.0, 60.0)); assert!(comments(&h).is_empty(), "{:?}", comments(&h)); } + +#[test] +fn hovering_a_comment_shows_its_author_and_text() { + // A square comment by Ada over the first page's text. + let pdf = String::from_utf8_lossy(TEXT_FIXTURE).replace("/Contents 5 0 R /Resources", "/Contents 5 0 R /Annots [8 0 R] /Resources").replace( + "trailer", + "8 0 obj << /Type /Annot /Subtype /Square /Rect [50 50 150 120] /C [1 0 0] /T (Ada) /Contents (Check this figure) >> endobj\ntrailer", + ); + let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| { + let mut app = PrintCraftApp::new(); + app.open_bytes("hover.pdf", None, pdf.into_bytes()).expect("opens"); + app.set_option("left", "closed").unwrap(); + // No Comments panel: the comment's text should only appear in the hover popup. + app.set_option("panel", "none").unwrap(); + app + }); + h.run_steps(4); + settle(&mut h); + assert!(h.query_by_label_contains("Check this figure").is_none(), "no popup before hovering"); + let p = at(&h, 100.0, 85.0); + h.hover_at(p); + h.run_steps(3); + h.get_by_label_contains("Check this figure"); + h.get_by_label_contains("Ada"); +} diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index bab498b81b..7fab48f5cb 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -212,3 +212,31 @@ fn selection_works_in_every_view_rotation() { assert_eq!(h.state().views[0].selected_text().as_deref(), Some("quick brown"), "rotation {deg}"); } } + +/// A file dropped on the window, as the windowing layer hands it over. +#[derive(Debug)] +struct Dropped { + path: std::path::PathBuf, + bytes: Vec, +} + +impl egui::DroppedFile for Dropped { + fn path(&self) -> &std::path::Path { + &self.path + } + fn bytes(&self) -> Result, String> { + Ok(self.bytes.clone()) + } +} + +#[test] +fn dropping_a_pdf_on_the_window_opens_it() { + let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_eframe(|_cc| PrintCraftApp::new()); + h.run_steps(3); + assert!(h.state().views.is_empty()); + let file: egui::DroppedFileHandle = std::sync::Arc::new(Dropped { path: "dropped.pdf".into(), bytes: FIXTURE.to_vec() }); + h.input_mut().dropped_files.push(file); + h.run_steps(3); + assert_eq!(h.state().views.len(), 1, "the dropped PDF opens in a tab"); + h.get_by_label_contains("dropped.pdf"); +} diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml index 8785afc5dc..314e353222 100644 --- a/parity/acrobat-features.toml +++ b/parity/acrobat-features.toml @@ -643,11 +643,11 @@ title = "Open files by drag and drop" area = "A" tier = "P1" milestone = "M3" -status = "partial" +status = "shipped" commands = [] tools = [] -evidence = [] -notes = "desktop drop is handled; no test yet" +evidence = ["crates/ui-egui/tests/ui.rs::dropping_a_pdf_on_the_window_opens_it"] +notes = "desktop: the dropped file opens in a tab (by path, or its bytes); web: read asynchronously" [[feature]] id = "core.recent-files" @@ -1151,11 +1151,11 @@ title = "Show comment text on hover" area = "B" tier = "P1" milestone = "M3" -status = "partial" +status = "shipped" commands = [] tools = [] -evidence = [] -notes = "no test yet" +evidence = ["crates/ui-egui/tests/comments.rs::hovering_a_comment_shows_its_author_and_text"] +notes = "a popup with the author and the comment text, as Acrobat shows" [[feature]] id = "view.document-tabs"