diff --git a/apps/pdfcraft/src/windows_manifest.rs b/apps/pdfcraft/src/windows_manifest.rs
index 5d7787d250..8c5c8a7fde 100644
--- a/apps/pdfcraft/src/windows_manifest.rs
+++ b/apps/pdfcraft/src/windows_manifest.rs
@@ -8,3 +8,27 @@ pub(crate) const WINDOWS_MANIFEST: &str = r#"
"#;
+
+#[cfg(test)]
+mod tests {
+ use super::WINDOWS_MANIFEST;
+
+ #[test]
+ fn declares_per_monitor_v2_with_per_monitor_fallback() {
+ assert!(
+ WINDOWS_MANIFEST
+ .contains("PerMonitorV2, PerMonitor")
+ );
+ }
+
+ #[test]
+ fn legacy_declaration_is_per_monitor_aware() {
+ assert!(WINDOWS_MANIFEST.contains("true/pm"));
+ }
+
+ #[test]
+ fn windows_resource_build_script_embeds_this_manifest() {
+ let build_script = include_str!("../build.rs");
+ assert!(build_script.contains("set_manifest(windows_manifest::WINDOWS_MANIFEST)"));
+ }
+}
diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs
index 93def4cf15..553cf1f8b2 100644
--- a/crates/ui-egui/src/app.rs
+++ b/crates/ui-egui/src/app.rs
@@ -183,13 +183,15 @@ impl PdfCraftApp {
/// The app unit tests start from: the default host (threads run its jobs, pickers answer Cancelled), no
/// wake-ups, no autosave folder, the GitHub update source, a fresh intake and an inline watch.
- #[cfg(all(test, not(target_arch = "wasm32")))]
+ #[cfg(test)]
+ #[cfg(not(target_arch = "wasm32"))]
pub(crate) fn for_unit_tests() -> Self {
Self::for_unit_tests_on(Arc::new(Host::builder(APP_INFO).build()))
}
/// [`for_unit_tests`](Self::for_unit_tests) over `host`, for a test whose jobs or files are scripted.
- #[cfg(all(test, not(target_arch = "wasm32")))]
+ #[cfg(test)]
+ #[cfg(not(target_arch = "wasm32"))]
pub(crate) fn for_unit_tests_on(host: Arc) -> Self {
let services = AppServices::new(
Wake::none(),
diff --git a/crates/ui-egui/src/canvas/image_pick.rs b/crates/ui-egui/src/canvas/image_pick.rs
index b6a388e19c..555a116dfb 100644
--- a/crates/ui-egui/src/canvas/image_pick.rs
+++ b/crates/ui-egui/src/canvas/image_pick.rs
@@ -222,8 +222,8 @@ mod picture_tests {
fn click_still_being_looked_into(h: &mut Harness<'static, PdfCraftApp>, at: &impl Fn(f32, f32) -> egui::Pos2) {
click(h, at(100.0, 150.0));
h.run_steps(2);
- let test = std::thread::current().name().and_then(|n| n.rsplit("::").next()).unwrap_or_default().to_owned();
- let s = h.state();
+ let _test = std::thread::current().name().and_then(|n| n.rsplit("::").next()).unwrap_or_default().to_owned();
+ let _s = h.state();
assert!(h.state().views[0].session.pending_pick.is_some(), "the click waits for its page");
}
diff --git a/crates/ui-egui/src/canvas/signature_drag.rs b/crates/ui-egui/src/canvas/signature_drag.rs
index 1ba17ef14b..a9a4aadbb3 100644
--- a/crates/ui-egui/src/canvas/signature_drag.rs
+++ b/crates/ui-egui/src/canvas/signature_drag.rs
@@ -565,7 +565,6 @@ fn stamp_tile(p: &PageInfo, rect: [f32; 4], scale: f32) -> Option<(f32, Tile)> {
#[cfg(test)]
mod tests {
- use std::sync::Arc;
use egui::Pos2;
diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs
index 8544e34638..cb27267cf8 100644
--- a/crates/ui-egui/src/canvas/tests.rs
+++ b/crates/ui-egui/src/canvas/tests.rs
@@ -1,7 +1,7 @@
use super::area::{MARK_SIDE_SHARE, mark_anchor, verdict_mark_rect};
use super::cache::grayscale;
use super::*;
-use craft::pages::ui::{PageBody, PlacedPage};
+use craft::pages::ui::PlacedPage;
use craft::ui::primitives::textures::{LoadFailure, Revision, TextureState, TextureStore, TextureStoreOptions};
#[test]
diff --git a/crates/ui-egui/src/dialogs/convert_colours_ui.rs b/crates/ui-egui/src/dialogs/convert_colours_ui.rs
index e7f66ad07f..a3710456be 100644
--- a/crates/ui-egui/src/dialogs/convert_colours_ui.rs
+++ b/crates/ui-egui/src/dialogs/convert_colours_ui.rs
@@ -144,11 +144,8 @@ mod tests {
let (a, b) = (DocId(1), DocId(2));
let mut d = ConvertColoursDraft::default();
d.for_document(a);
- let mut chosen = PageRange::default();
- chosen.scope = PageScope::Range;
- chosen.from = 4;
- chosen.to = Some(5);
- d.range = chosen.clone();
+ let chosen = PageRange { scope: PageScope::Range, from: 4, to: Some(5), ..PageRange::default() };
+ d.range = chosen;
d.for_document(a);
assert_eq!(d.range, chosen, "same document keeps its range");
d.for_document(b);
diff --git a/crates/ui-egui/src/dialogs/rename_ui.rs b/crates/ui-egui/src/dialogs/rename_ui.rs
index 2d6ba0728e..7ac224f03a 100644
--- a/crates/ui-egui/src/dialogs/rename_ui.rs
+++ b/crates/ui-egui/src/dialogs/rename_ui.rs
@@ -201,7 +201,8 @@ impl PdfCraftApp {
}
}
-#[cfg(all(test, not(target_arch = "wasm32")))]
+#[cfg(test)]
+#[cfg(not(target_arch = "wasm32"))]
#[allow(clippy::unwrap_used, clippy::expect_used)]
mod tests {
use super::KEY;
diff --git a/crates/ui-egui/src/dialogs/word_count_ui.rs b/crates/ui-egui/src/dialogs/word_count_ui.rs
index 4fc9ab8285..e9b66edaa5 100644
--- a/crates/ui-egui/src/dialogs/word_count_ui.rs
+++ b/crates/ui-egui/src/dialogs/word_count_ui.rs
@@ -209,10 +209,7 @@ impl PdfCraftApp {
mod tests {
use super::*;
use craft::host::ManualJobs;
- use egui_kittest::{
- Harness,
- kittest::{NodeT as _, Queryable},
- };
+ use egui_kittest::{Harness, kittest::Queryable};
/// An app whose background jobs wait on `jobs` until the test runs them.
fn app_on(jobs: Arc) -> PdfCraftApp {
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 5958f7d67b..8bf58242d0 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -137,8 +137,6 @@ use platform::macos_association;
#[cfg(not(target_arch = "wasm32"))]
use platform::open_worker;
pub use platform::ui_scale;
-#[cfg(test)]
-use state::CopyPage;
#[cfg(not(target_arch = "wasm32"))]
use state::OpenRequest;
pub use state::{
diff --git a/crates/ui-egui/src/menus/tab_context.rs b/crates/ui-egui/src/menus/tab_context.rs
index 071c705404..e7f08868e6 100644
--- a/crates/ui-egui/src/menus/tab_context.rs
+++ b/crates/ui-egui/src/menus/tab_context.rs
@@ -90,7 +90,8 @@ impl crate::PdfCraftApp {
}
}
-#[cfg(all(test, not(target_arch = "wasm32")))]
+#[cfg(test)]
+#[cfg(not(target_arch = "wasm32"))]
mod tests {
use super::*;
use crate::PdfCraftApp;
diff --git a/crates/ui-egui/src/notices.rs b/crates/ui-egui/src/notices.rs
index 3d58934db5..46646bbf07 100644
--- a/crates/ui-egui/src/notices.rs
+++ b/crates/ui-egui/src/notices.rs
@@ -97,7 +97,6 @@ fn apply(app: &mut PdfCraftApp, ctx: &egui::Context, request: ProgressRequest) {
}
}
-/// How far the job of `key` has got, from its card; `None` when it has no card shown.
// PLAN: L-206 names this `Notices::progress(&self, key: &str)`; the app has no `Notices` type, so it is a function
// over the app's card map.
diff --git a/crates/ui-egui/src/persist/recent_check.rs b/crates/ui-egui/src/persist/recent_check.rs
index cc54887bc2..45b928893b 100644
--- a/crates/ui-egui/src/persist/recent_check.rs
+++ b/crates/ui-egui/src/persist/recent_check.rs
@@ -93,8 +93,7 @@ mod tests {
// No lanes: a job runs only when the test runs it.
let queue = JobQueue::new(Arc::new(ManualJobs::new()), Wake::none(), QueueOptions { lanes: 0, ..QueueOptions::default() });
app.recent_check = RecentCheck::new(queue);
- let listed = || vec![crate::state::RecentFile { name: "a.pdf".into(), path: "/gone/a.pdf".into(), pages: 1, size: 0 }];
- app.recent = listed();
+ app.recent = vec![crate::state::RecentFile { name: "a.pdf".into(), path: "/gone/a.pdf".into(), pages: 1, size: 0 }];
app.recent_check.restored(vec!["/gone/a.pdf".into()]);
app.check_restored_recent();
app.recent_check.opened("/gone/a.pdf");
diff --git a/crates/ui-egui/src/persist/recovery.rs b/crates/ui-egui/src/persist/recovery.rs
index f06a4837e9..3ee856c3ed 100644
--- a/crates/ui-egui/src/persist/recovery.rs
+++ b/crates/ui-egui/src/persist/recovery.rs
@@ -440,7 +440,7 @@ mod idle_tests {
frame(&mut app, &ctx, base + Duration::from_secs(119));
assert_eq!(std::fs::read(©).unwrap(), first);
frame(&mut app, &ctx, base + Duration::from_secs(120));
- assert_eq!(copies(&folder), [copy.clone()], "the same document replaces its existing snapshot");
+ assert_eq!(copies(&folder), std::slice::from_ref(©), "the same document replaces its existing snapshot");
let second = std::fs::read(©).unwrap();
assert_ne!(second, first);
let mut recovered = pdfcraft_engine::Session::new();
@@ -480,7 +480,7 @@ mod idle_tests {
#[cfg(test)]
mod sidecar_tests {
use super::idle_tests::{TestDir, app_in};
- use super::*;
+
use crate::SaveTarget;
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
@@ -491,7 +491,7 @@ mod sidecar_tests {
/// the document's file from then on.
#[test]
fn the_first_save_after_recovering_asks_instead_of_writing_the_sidecars_path() {
- let ctx = &egui::Context::default();
+ let _ctx = &egui::Context::default();
let ctx = &egui::Context::default();
let dir = TestDir::new();
let folder = dir.path().join("recovery");
diff --git a/crates/ui-egui/src/platform/open_worker.rs b/crates/ui-egui/src/platform/open_worker.rs
index c7b162fe3f..1cd2f6238e 100644
--- a/crates/ui-egui/src/platform/open_worker.rs
+++ b/crates/ui-egui/src/platform/open_worker.rs
@@ -100,5 +100,6 @@ fn prepare(job: Job, cancel: &Cancel) -> ResultKind {
ResultKind::Prepared { bytes, result: Box::new(result), named }
}
-#[cfg(all(test, not(target_arch = "wasm32")))]
+#[cfg(test)]
+#[cfg(not(target_arch = "wasm32"))]
mod tests;
diff --git a/crates/ui-egui/src/script_dialog.rs b/crates/ui-egui/src/script_dialog.rs
index 4ca9524cec..c209e97a22 100644
--- a/crates/ui-egui/src/script_dialog.rs
+++ b/crates/ui-egui/src/script_dialog.rs
@@ -605,7 +605,7 @@ mod review13_ui_tests {
/// Script focus reveals the requested field page before opening its editor.
#[test]
fn script_focus_reveals_an_offscreen_widget() {
- let ctx = &egui::Context::default();
+ let _ctx = &egui::Context::default();
let ctx = &egui::Context::default();
let (mut app, id) = app(ctx);
app.session
@@ -659,7 +659,7 @@ mod link_script_tests {
/// window's prompt, the answer resumes it, and its field change and openDoc consent apply.
#[test]
fn a_javascript_link_asks_its_menu_and_applies_its_result() {
- let ctx = &egui::Context::default();
+ let _ctx = &egui::Context::default();
let ctx = &egui::Context::default();
// An absolute path on this system (the document has no folder): on Windows, Acrobat's
// `/C/…` form, which reads as `C:/…`.
diff --git a/crates/ui-egui/src/tools/comments.rs b/crates/ui-egui/src/tools/comments.rs
index 7cbeb5e515..3cd0e9bfd0 100644
--- a/crates/ui-egui/src/tools/comments.rs
+++ b/crates/ui-egui/src/tools/comments.rs
@@ -25,7 +25,7 @@ use crate::icons;
#[cfg(test)]
use craft::review::ui::annotate::{AnnotateCommand, AnnotateIcons};
#[cfg(test)]
-use egui::{CornerRadius, Sense, Stroke, pos2, vec2};
+use egui::{pos2, vec2};
mod bridge;
pub(crate) mod colours;
@@ -42,12 +42,8 @@ use bridge::hover_tip;
/// The comment thread of the annotation at `(page, index)`: the key the Comments panel files it under.
pub use bridge::thread_id;
pub(crate) use bridge::{PageMap, delete_selected, id_of, key_of, kind_of, parts, pdf_date_seconds, rgb8};
-#[cfg(test)]
-pub(crate) use bridge::{annotations, edit, edit_anchor, markers, screen_to_user_rect, thread_key, tips};
pub(crate) use colours::{RecentColours, border_choice, fill_choice, palette, to_rgb};
pub(crate) use composer::composer;
-#[cfg(test)]
-use composer::edited_in_view;
pub(crate) use geometry::caret_snap;
pub(crate) use geometry::page_rotation;
#[cfg(test)]
@@ -55,8 +51,6 @@ pub(crate) use geometry::snapped_caret;
pub use geometry::{drawn_text_box_rect, snug_text_box_rect, text_box_rect};
pub use menu::CanvasAction;
pub(crate) use menu::{CommentMenuCx, MenuRights, context_rows, popover_from, quick_bar_controls};
-#[cfg(test)]
-pub(crate) use menu::{QuickBarPick, attachment_items};
pub(crate) use overlay::{Hover, show};
pub(crate) use popups::note_popups;
pub(crate) use state::PageCx;
diff --git a/crates/ui-egui/src/tools/comments/tests.rs b/crates/ui-egui/src/tools/comments/tests.rs
index 5e09858c5b..02f68b2609 100644
--- a/crates/ui-egui/src/tools/comments/tests.rs
+++ b/crates/ui-egui/src/tools/comments/tests.rs
@@ -395,7 +395,7 @@ fn markup_comment_markers_stay_inside_turned_and_zoomed_pages() {
..Default::default()
};
let placed = [placed_page(&xf, f64::from(zoom))];
- let map = page_map(&placed, &info, rotation as u16);
+ let map = page_map(&placed, &info, rotation);
let side = icon_side(&map);
let with = |annotations: Vec| DocInfo { annotations, ..info.clone() };
for rect in [[0.0, 180.0, 30.0, 200.0], [270.0, 180.0, 300.0, 200.0], [270.0, 0.0, 300.0, 20.0], [0.0, 0.0, 30.0, 20.0]] {
@@ -592,7 +592,7 @@ fn an_annotation_round_trips_through_the_page_map_on_turned_and_zoomed_pages() {
..Default::default()
};
let placed = [placed_page(&xf, f64::from(zoom))];
- let map = page_map(&placed, &info, rotation as u16);
+ let map = page_map(&placed, &info, rotation);
let case = format!("page/view rotation {page_rotation}/{rotation}, zoom {zoom}");
for user in [[10.0, 20.0], [250.0, 150.0]] {
let back = map.to_user(0, map.to_doc(0, user));
diff --git a/crates/ui-egui/src/tools/object_ui.rs b/crates/ui-egui/src/tools/object_ui.rs
index 12e6519b88..0f6478c99d 100644
--- a/crates/ui-egui/src/tools/object_ui.rs
+++ b/crates/ui-egui/src/tools/object_ui.rs
@@ -570,6 +570,13 @@ pub(crate) fn move_error(error: &pdfcraft_engine::EditError) -> String {
}
}
+/// The accent as outline ink: production outlines the selection and the editable paragraphs in blue, not in
+/// the overlay grey the outline component defaults to.
+pub(crate) fn accent_ink(ui: &egui::Ui, share: f32) -> craft::ui::style::DataColor {
+ let [r, g, b, a] = craft::ui::runtime::env::Env::of(ui).tokens.color.accent.solid.0;
+ craft::ui::style::DataColor::new(egui::Color32::from_rgba_unmultiplied(r, g, b, a).gamma_multiply(share))
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -594,10 +601,3 @@ mod tests {
assert!(Edit::delete_objects(0, Vec::new()).is_none());
}
}
-
-/// The accent as outline ink: production outlines the selection and the editable paragraphs in blue, not in
-/// the overlay grey the outline component defaults to.
-pub(crate) fn accent_ink(ui: &egui::Ui, share: f32) -> craft::ui::style::DataColor {
- let [r, g, b, a] = craft::ui::runtime::env::Env::of(ui).tokens.color.accent.solid.0;
- craft::ui::style::DataColor::new(egui::Color32::from_rgba_unmultiplied(r, g, b, a).gamma_multiply(share))
-}
diff --git a/crates/ui-egui/src/workflows/print_ui/dialog.rs b/crates/ui-egui/src/workflows/print_ui/dialog.rs
index d06e5ab1e5..7a279d5732 100644
--- a/crates/ui-egui/src/workflows/print_ui/dialog.rs
+++ b/crates/ui-egui/src/workflows/print_ui/dialog.rs
@@ -379,9 +379,9 @@ impl PdfCraftApp {
/// Page Setup…: the driver's paper and orientation dialog, owned by the main window.
fn page_setup(&mut self) {
- // PLAN: assumed `main_window_handle(&self) -> Option`, the window service's accessor for the main window.
+ // The print dialog is the active window, so the driver's dialog stays in front of it.
#[cfg(windows)]
- let parent = self.main_window_handle();
+ let parent = winsafe::HWND::GetActiveWindow().map(|h| h.ptr() as isize);
#[cfg(not(windows))]
let parent = None;
let d = &mut self.print_draft;
diff --git a/crates/ui-egui/tests/it/accessibility.rs b/crates/ui-egui/tests/it/accessibility.rs
index 767affe7ea..e29e332fe9 100644
--- a/crates/ui-egui/tests/it/accessibility.rs
+++ b/crates/ui-egui/tests/it/accessibility.rs
@@ -128,7 +128,7 @@ fn checking_fixing_skipping_and_reporting() {
assert_eq!(requests.len(), 1, "the report asks where to be saved once");
assert_eq!(requests[0].kind, PickKind::Folder, "the report uses the export folder picker");
let saved = std::path::Path::new("/reports/notes Accessibility Report.html");
- let html = String::from_utf8(files.file(&saved).expect("the report was written")).unwrap();
+ let html = String::from_utf8(files.file(saved).expect("the report was written")).unwrap();
assert!(html.contains("Accessibility Report") && html.contains("Skipped"));
}
diff --git a/crates/ui-egui/tests/it/attach_picker_target.rs b/crates/ui-egui/tests/it/attach_picker_target.rs
index 47d442d3f8..2a15645e5e 100644
--- a/crates/ui-egui/tests/it/attach_picker_target.rs
+++ b/crates/ui-egui/tests/it/attach_picker_target.rs
@@ -90,6 +90,6 @@ fn an_attachment_pick_is_dropped_when_the_user_switches_tabs() {
h.run_steps(2);
assert!(!dirty(h.state(), 0), "the document the pick was for is unchanged");
assert!(!dirty(h.state(), 1), "the newly active document did not get the attachment");
- assert!(support::shown_notice(&mut h).is_some(), "the user is told why nothing happened");
+ assert!(support::shown_notice(&h).is_some(), "the user is told why nothing happened");
let _ = std::fs::remove_dir_all(&dir);
}
diff --git a/crates/ui-egui/tests/it/column_select.rs b/crates/ui-egui/tests/it/column_select.rs
index 5086eb3007..3895ccc2e7 100644
--- a/crates/ui-egui/tests/it/column_select.rs
+++ b/crates/ui-egui/tests/it/column_select.rs
@@ -167,7 +167,7 @@ fn a_column_selection_copies_plain_text_only() {
drag(&mut h, from, to, Modifiers::ALT);
assert!(h.execute("edit.copy"));
h.step();
- let html = clipboard.writes().iter().flatten().any(|flavor| flavor.mime.to_string() == "text/html");
+ let html = clipboard.writes().iter().flatten().any(|flavor| flavor.mime == "text/html");
assert!(!html, "no HTML for a column selection");
assert_eq!(clipboard.copied().as_deref(), Some("Name\tQty\nApple\t12"), "the plain text goes out the usual way");
}
diff --git a/crates/ui-egui/tests/it/comments.rs b/crates/ui-egui/tests/it/comments.rs
index f1b41ed838..2022b086b4 100644
--- a/crates/ui-egui/tests/it/comments.rs
+++ b/crates/ui-egui/tests/it/comments.rs
@@ -339,7 +339,7 @@ trailer << /Root 1 0 R >>
h.get_by_label("Blue").click();
h.run_steps(3);
- let notice = support::shown_notice(&mut h);
+ let notice = support::shown_notice(&h);
let state = h.state();
let doc = state.session.get(id).expect("document");
assert_eq!(doc.comment_props(0, 0).and_then(|props| props.color), Some([1.0, 0.94, 0.0]), "the comment keeps its colour");
@@ -1283,7 +1283,6 @@ fn panel_posts_comment_and_reply_row() {
// `PdfCraftApp::dialogs.get_mut_by_id::(id)` for the hosted Comment Properties
// dialog (pdf-comments-w11); the row keys are the dialog's own (`comment.props.colour`, ...).
const PROP_COLOUR: &str = "comment.props.colour";
-const PROP_BORDER: &str = "comment.props.border";
const PROP_FILL: &str = "comment.props.fill";
/// Write the row `key` of the open Comment Properties dialog; the dialog shows it in its next pass.
@@ -1827,7 +1826,7 @@ fn delete_one_reply_row() {
h.event(egui::Event::Text("Right reply, reworded".into()));
h.run_steps(2);
// The document's own Save sits earlier in the tree than the editor's.
- h.query_all_by_label("Save").filter(|n| !n.accesskit_node().is_disabled()).last().expect("the editor's Save").click();
+ h.query_all_by_label("Save").rfind(|n| !n.accesskit_node().is_disabled()).expect("the editor's Save").click();
h.run_steps(3);
assert_eq!(texts(&h), ["The comment", "Right reply, reworded", "Accepted set by Ben"]);
diff --git a/crates/ui-egui/tests/it/document_links.rs b/crates/ui-egui/tests/it/document_links.rs
index 875c825074..e6cd0c54e2 100644
--- a/crates/ui-egui/tests/it/document_links.rs
+++ b/crates/ui-egui/tests/it/document_links.rs
@@ -305,7 +305,7 @@ fn bookmarks_go_through_the_link_policy() {
// A fresh app per row: each row's notice is its own.
let mut h = bookmark_harness_with(None, pdf.clone());
click_bookmark(&mut h, title);
- assert_eq!(support::shown_notice(&mut h).as_deref(), notice, "{title}");
+ assert_eq!(support::shown_notice(&h).as_deref(), notice, "{title}");
let opened = support::step_collecting_urls(&mut h, 2);
let s = h.state();
assert_eq!((&s.pending_link, s.views.len(), s.views[0].current()), (&None, 1, 0), "{title}: nothing opened");
@@ -315,7 +315,7 @@ fn bookmarks_go_through_the_link_policy() {
click_bookmark(&mut h, "Absolute");
assert_eq!(h.state().pending_remote_link.as_ref().map(|p| p.path.clone()), Some(target));
assert_eq!(h.state().views.len(), 1);
- assert!(support::shown_notice(&mut h).is_none(), "the file is not touched before consent");
+ assert!(support::shown_notice(&h).is_none(), "the file is not touched before consent");
}
#[test]
@@ -383,14 +383,14 @@ fn a_gotor_link_to_a_named_destination_opens_at_its_page() {
click_remote_link(&mut h);
// The name is looked up off the UI thread, so the tab may open before it moves there.
support::wait_until(&mut h, "remote document at its destination", |app| app.views.len() == 2 && app.views[1].current() == page);
- assert!(support::shown_notice(&mut h).is_none(), "{destination}: applied, so nothing to warn about");
+ assert!(support::shown_notice(&h).is_none(), "{destination}: applied, so nothing to warn about");
}
// A name the target doesn't define opens it at its first page, with the warning.
let mut h = remote_harness(Some(dir.join("source.pdf").to_string_lossy().into_owned()), "target.pdf", "/elsewhere");
click_remote_link(&mut h);
assert!(support::step_until(&mut h, |h| h.state().views.len() == 2 && support::shown_notice(h).is_some()), "remote document and the warning");
assert_eq!(h.state().views[1].current(), 0);
- let notice = support::shown_notice(&mut h);
+ let notice = support::shown_notice(&h);
assert!(notice.as_deref().is_some_and(|text| text.contains("named destination was not applied")), "{notice:?}");
}
@@ -447,7 +447,7 @@ fn a_gotor_link_to_a_directory_or_device_is_refused_without_reading_it() {
click_remote_link(&mut h);
assert!(support::step_until(&mut h, |h| support::shown_notice(h).is_some()), "relative invalid target refusal");
assert_eq!(h.state().views.len(), 1, "{target} opens no tab");
- let toast = support::shown_notice(&mut h).unwrap().to_string();
+ let toast = support::shown_notice(&h).unwrap().to_string();
assert!(toast.contains("not a regular file"), "{target}: {toast}");
}
let _ = std::fs::remove_dir_all(&dir);
@@ -460,7 +460,7 @@ fn an_in_memory_source_does_not_resolve_a_relative_gotor_against_cwd() {
let mut h = remote_harness(None, "target.pdf", "[0 /Fit]");
click_remote_link(&mut h);
assert_eq!(h.state().views.len(), 1);
- let toast = support::shown_notice(&mut h).unwrap().to_string();
+ let toast = support::shown_notice(&h).unwrap().to_string();
assert!(toast.contains("relative link needs a source document path"), "{toast}");
}
@@ -473,7 +473,7 @@ fn unsupported_launch_action_is_reported_without_claiming_javascript() {
assert!(support::step_collecting_urls(&mut h, 1).is_empty());
assert_eq!(h.state().views.len(), 1);
assert_eq!(h.state().views[0].current(), 0);
- let toast = support::shown_notice(&mut h).expect("the unsupported action is reported").to_string();
+ let toast = support::shown_notice(&h).expect("the unsupported action is reported").to_string();
assert_eq!(toast, "This PDF uses the unsupported Launch action.");
}
@@ -516,7 +516,7 @@ fn a_button_script_cannot_open_a_local_program() {
assert!(support::step_until(&mut h, |h| h.state().pending_link.is_some() || support::shown_notice(h).is_some()), "script link refusal");
assert_eq!(h.state().pending_link, None, "a file: address is never offered");
assert!(support::step_collecting_urls(&mut h, 1).is_empty());
- let toast = support::shown_notice(&mut h).expect("the user is told").to_string();
+ let toast = support::shown_notice(&h).expect("the user is told").to_string();
assert!(toast.contains("“file:” address"), "{toast}");
}
@@ -553,7 +553,7 @@ fn a_script_cannot_open_other_kinds_of_address() {
assert!(support::step_until(&mut h, |h| h.state().pending_link.is_some() || support::shown_notice(h).is_some()), "script link decision");
assert_eq!(h.state().pending_link, None, "{url}");
assert!(support::step_collecting_urls(&mut h, 1).is_empty(), "{url}");
- let notice = support::shown_notice(&mut h);
+ let notice = support::shown_notice(&h);
assert!(notice.as_deref().is_some_and(|t| t.contains("won't open")), "{url}: {notice:?}");
}
}
@@ -569,7 +569,7 @@ fn an_email_link_cannot_attach_a_local_file() {
assert!(support::step_until(&mut h, |h| h.state().pending_link.is_some() || support::shown_notice(h).is_some()), "script link decision");
assert_eq!(h.state().pending_link, None, "{url}");
assert!(support::step_collecting_urls(&mut h, 1).is_empty(), "{url}");
- let toast = support::shown_notice(&mut h).expect("the user is told").to_string();
+ let toast = support::shown_notice(&h).expect("the user is told").to_string();
assert!(toast.contains("attach or insert a file"), "{url}: {toast}");
}
}
@@ -633,7 +633,7 @@ fn an_absolute_gotor_waits_for_consent_and_keeps_its_destination_across_tabs() {
h.get_by_label("Allow");
assert_eq!(h.state().views.len(), 1);
assert_eq!(h.state().session.docs().len(), 1);
- assert!(support::shown_notice(&mut h).is_none(), "the nonexistent target is not accessed before consent");
+ assert!(support::shown_notice(&h).is_none(), "the nonexistent target is not accessed before consent");
assert!(h.state().password_prompt.is_none());
// The target only appears AFTER the confirmation is displayed.
let target_bytes = linked_pages(2, None);
@@ -682,7 +682,7 @@ fn cancelling_an_absolute_gotor_by_button_or_escape_changes_nothing() {
assert_eq!(doc.bytes, before);
assert!(!doc.dirty);
assert!(doc.can_undo().is_none());
- assert!(support::shown_notice(&mut h).is_none());
+ assert!(support::shown_notice(&h).is_none());
assert!(h.state().password_prompt.is_none());
}
}
@@ -717,7 +717,7 @@ fn consenting_to_absolute_gotor_still_validates_the_target() {
let before = h.state().session.get(source).unwrap().bytes.clone();
click_remote_link(&mut h);
assert!(h.state().pending_remote_link.is_some());
- assert!(support::shown_notice(&mut h).is_none(), "{name} isn't checked before consent");
+ assert!(support::shown_notice(&h).is_none(), "{name} isn't checked before consent");
h.get_by_label("Allow").click();
assert!(
support::step_until(&mut h, |h| support::shown_notice(h).is_some_and(|message| message.starts_with(expected_error))),
@@ -725,7 +725,7 @@ fn consenting_to_absolute_gotor_still_validates_the_target() {
);
assert!(h.state().pending_remote_link.is_none());
assert_eq!(h.state().views.len(), 1, "{name}");
- assert!(support::shown_notice(&mut h).is_some(), "{name} is refused after consent");
+ assert!(support::shown_notice(&h).is_some(), "{name} is refused after consent");
assert_eq!(h.state().session.docs().len(), 1);
assert_eq!(h.state().active_ids().map(|(_, id)| id), Some(source));
assert_eq!(h.state().views[0].current(), 0);
@@ -789,7 +789,7 @@ fn closing_the_source_invalidates_pending_absolute_gotor_consent() {
assert!(h.state().views.is_empty());
assert!(h.state().session.docs().is_empty());
assert!(h.state().pending_remote_link.is_none());
- assert!(support::shown_notice(&mut h).is_none());
+ assert!(support::shown_notice(&h).is_none());
}
fn overlapping_annotation_fixture(subtype: &str, internal: bool) -> Vec {
diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs
index c04b85c546..90a5bf7a45 100644
--- a/crates/ui-egui/tests/it/editing.rs
+++ b/crates/ui-egui/tests/it/editing.rs
@@ -432,7 +432,7 @@ fn shift_click_selects_a_range_and_moves_it() {
h.run_steps(3);
assert_eq!(page_texts(h.state()), ["Page 3", "Page 1", "Page 2", "Page 4"]);
// The moved pages stay selected at their new position, so repeated clicks keep moving them.
- assert_eq!(h.state().views[0].selected.items.iter().copied().collect::>(), [1, 2]);
+ assert_eq!(h.state().views[0].selected.items.to_vec(), [1, 2]);
// The pointer still rests on the button, whose tooltip carries its name too.
h.get_by_role_and_label(Role::Button, "Move later").click();
h.run_steps(3);
@@ -914,7 +914,7 @@ fn opening_a_missing_file_fails_and_tells_the_user() {
assert_eq!(h.state_mut().open_path(&missing.to_string_lossy()), OpenOutcome::Pending);
h.run_steps(4);
assert!(h.state().views.is_empty());
- assert!(support::shown_notice(&mut h).is_some(), "the failure is still reported to the user");
+ assert!(support::shown_notice(&h).is_some(), "the failure is still reported to the user");
}
#[test]
@@ -944,7 +944,7 @@ fn opening_a_file_whose_copy_vanished_from_disk_focuses_its_tab() {
h.run_steps(2);
assert_eq!(h.state().views.len(), 1, "no second tab");
assert_eq!(h.state().active, Some(0), "the open tab is focused");
- assert!(support::shown_notice(&mut h).is_none(), "no read error: the file is never read again");
+ assert!(support::shown_notice(&h).is_none(), "no read error: the file is never read again");
}
#[test]
@@ -3063,20 +3063,20 @@ fn copying_out_of_a_document_honours_its_security() {
let (mut h, copies) = open("pw");
assert!(!copy(&mut h, &copies), "⌘C copies nothing");
- assert_eq!(support::shown_notice(&mut h).as_deref(), refused);
+ assert_eq!(support::shown_notice(&h).as_deref(), refused);
for command in ["edit.snapshot", "export.image", "export.text", "export.docx", "export.pptx", "export.html", "export.rtf", "export.all_images"] {
// A fresh window per command: the notice of the one before would still be showing.
let (mut h, _) = open("pw");
assert!(!h.execute(command), "{command} is refused");
h.run_steps(2);
- assert_eq!(support::shown_notice(&mut h).as_deref(), refused, "{command} says why");
+ assert_eq!(support::shown_notice(&h).as_deref(), refused, "{command} says why");
assert!(h.state().dialogs.is_empty(), "no export dialog");
}
// The snapshot tool, chosen on another tab, takes nothing here either.
h.set_option("quick", "snapshot").unwrap();
snapshot(&mut h);
assert!(h.state().last_snapshot.is_none());
- assert_eq!(support::shown_notice(&mut h).as_deref(), refused);
+ assert_eq!(support::shown_notice(&h).as_deref(), refused);
let (mut h, copies) = open("owner");
assert!(copy(&mut h, &copies), "the owner may copy");
@@ -3279,7 +3279,7 @@ fn dragging_thumbnails_reorders_pages() {
let after = page_texts(h.state());
assert_eq!(after, vec![before[1].clone(), before[2].clone(), before[0].clone(), before[3].clone()], "{after:?}");
assert_eq!(h.state().session.get(h.state().views[0].id).unwrap().can_undo(), Some("Move page"));
- let sel: Vec = h.state().views[0].selected.items.iter().copied().collect();
+ let sel: Vec = h.state().views[0].selected.items.to_vec();
assert_eq!(sel, vec![2], "the moved page stays selected");
}
@@ -3325,7 +3325,7 @@ fn dragging_with_the_copy_modifier_copies_the_pages_into_the_gap() {
let after = page_texts(h.state());
assert_eq!(after, vec![before[0].clone(), before[1].clone(), before[2].clone(), before[0].clone()], "{after:?}");
assert_eq!(h.state().session.get(h.state().views[0].id).unwrap().can_undo(), Some("Duplicate page"));
- let sel: Vec = h.state().views[0].selected.items.iter().copied().collect();
+ let sel: Vec = h.state().views[0].selected.items.to_vec();
assert_eq!(sel, vec![3], "the copy is selected");
}
@@ -3355,7 +3355,7 @@ fn option_copies_and_ctrl_moves_when_the_context_reports_macos() {
page_drag(&mut h, from, to, Modifiers::ALT);
assert_eq!(page_texts(h.state()), vec![before[0].clone(), before[1].clone(), before[2].clone(), before[0].clone()], "Option copies on macOS");
assert_eq!(h.state().session.get(h.state().views[0].id).unwrap().can_undo(), Some("Duplicate page"));
- let sel: Vec = h.state().views[0].selected.items.iter().copied().collect();
+ let sel: Vec = h.state().views[0].selected.items.to_vec();
assert_eq!(sel, vec![3], "the copy is selected");
}
@@ -3370,7 +3370,7 @@ fn copying_cutting_and_pasting_pages() {
h.run_steps(2);
let after = page_texts(h.state());
assert_eq!(after, vec![before[0].clone(), before[1].clone(), before[2].clone(), before[0].clone(), before[3].clone()], "pasted after page 3");
- let sel: Vec = h.state().views[0].selected.items.iter().copied().collect();
+ let sel: Vec = h.state().views[0].selected.items.to_vec();
assert_eq!(sel, vec![3], "the pasted page is selected");
// Cut page 2 and paste it at the end.
h.state_mut().views[0].select_pages(&[1]);
@@ -3895,7 +3895,7 @@ fn a_paragraph_whose_edit_fails_stays_open_with_its_typing() {
h.run_steps(1);
h.key_press_modifiers(Modifiers::COMMAND, Key::Enter);
h.run_steps(3);
- let notice = support::shown_notice(&mut h);
+ let notice = support::shown_notice(&h);
let s = h.state();
assert!(notice.as_ref().is_some_and(|m| m.starts_with("Edit text failed")), "the failure is said: {notice:?}");
assert_eq!(s.session.get(s.views[0].id).unwrap().can_undo(), None, "nothing was applied");
@@ -6022,7 +6022,7 @@ fn an_ordinary_paragraph_drag_refusal_never_rewrites_the_text() {
assert!(doc.can_undo().is_none());
assert!(!doc.dirty);
assert_dragged_paragraphs(&dragged_paragraphs(&h), &before);
- assert!(support::shown_notice(&mut h).unwrap().contains("Text used as a clipping path cannot be moved with this selection."));
+ assert!(support::shown_notice(&h).unwrap().contains("Text used as a clipping path cannot be moved with this selection."));
}
/// A delete the engine refuses (text used as a clipping path) leaves the document as it was and
@@ -6045,7 +6045,7 @@ fn a_refused_delete_keeps_the_object_selection() {
let doc = h.state().session.get(id).unwrap();
assert_eq!((doc.edit_generation(), &doc.bytes), (generation, &bytes), "the refused delete changed nothing");
assert!(doc.can_undo().is_none());
- assert!(support::shown_notice(&mut h).is_some(), "the refusal is reported");
+ assert!(support::shown_notice(&h).is_some(), "the refusal is reported");
h.get_by_label("1 object selected");
}
@@ -6310,7 +6310,7 @@ fn dragging_pages_panel_thumbnails_reorders_pages() {
assert_eq!(after, vec![before[2].clone(), before[0].clone(), before[1].clone(), before[3].clone()], "{after:?}");
assert_eq!(h.state().session.get(h.state().views[0].id).unwrap().can_undo(), Some("Move page"));
let view = &h.state().views[0];
- assert_eq!(view.selected.items.iter().copied().collect::>(), vec![0], "the moved page stays selected");
+ assert_eq!(view.selected.items.to_vec(), vec![0], "the moved page stays selected");
}
#[test]
@@ -6416,7 +6416,7 @@ fn the_delete_key_deletes_pages_picked_in_the_pages_panel_but_never_every_page()
let (p1, p3) = (panel_thumb(&h, "Page 1"), panel_thumb(&h, "Page 3"));
h.hover_at(p3);
h.run_steps(1);
- assert_eq!(h.state().views[0].selected.items.iter().copied().collect::>(), vec![0, 1, 2]);
+ assert_eq!(h.state().views[0].selected.items.to_vec(), vec![0, 1, 2]);
// Every page picked: Delete does nothing, and the menu item is off.
h.key_press(Key::Delete);
h.run_steps(3);
@@ -8644,7 +8644,7 @@ fn page_properties_does_not_apply_after_the_document_changes() {
h.run_steps(3);
assert!(h.state().dialogs.is_empty());
assert_eq!(
- support::shown_notice(&mut h).as_deref(),
+ support::shown_notice(&h).as_deref(),
Some("The document changed while the dialog was open, so nothing was changed. Open Page properties again to set the tab order.")
);
let doc = h.state().session.get(id).unwrap();
@@ -9620,7 +9620,7 @@ fn printer_marks_are_added_from_the_dialog_and_removed() {
assert!(doc.marks().contains(&pdfcraft_engine::MarkKind::PrinterMarks));
// No trim box: the whole page is the trim box, so the page grew 36 pt a side for the marks.
assert!((doc.info.pages[0].width - (before + 72.0)).abs() < 0.5, "{} → {}", before, doc.info.pages[0].width);
- assert_eq!(support::shown_notice(&mut h).unwrap(), "Printer marks added");
+ assert_eq!(support::shown_notice(&h).unwrap(), "Printer marks added");
assert!(h.execute("prepress.marks.remove"));
h.run_steps(3);
let doc = h.state().session.get(id).unwrap();
@@ -9658,13 +9658,13 @@ fn convert_colours_from_the_dialog() {
// The mode bar has a "Convert" too: the dialog's button is the last one.
h.query_all_by_label("Convert").last().unwrap().click();
h.run_steps(3);
- assert_eq!(support::shown_notice(&mut h).unwrap(), "Converted 2 colours and 0 pictures on 1 pages");
+ assert_eq!(support::shown_notice(&h).unwrap(), "Converted 2 colours and 0 pictures on 1 pages");
assert_eq!(h.state().session.get(id).unwrap().can_undo(), Some("Convert colours"));
assert!(h.execute("prepress.convert_colors"));
h.run_steps(2);
h.query_all_by_label("Convert").last().unwrap().click();
h.run_steps(3);
- assert_eq!(support::shown_notice(&mut h).unwrap(), "Nothing on those pages needed converting");
+ assert_eq!(support::shown_notice(&h).unwrap(), "Nothing on those pages needed converting");
}
/// Print production ▸ Fix hairlines: the dialog widens zero-width and too-thin
@@ -9695,14 +9695,14 @@ fn fix_hairlines_from_the_dialog() {
h.get_by_label("Type 3 font glyphs");
h.get_by_label("Fix").click();
h.run_steps(3);
- assert_eq!(support::shown_notice(&mut h).unwrap(), "Fixed 1 hairline on 1 page");
+ assert_eq!(support::shown_notice(&h).unwrap(), "Fixed 1 hairline on 1 page");
assert_eq!(h.state().session.get(id).unwrap().can_undo(), Some("Fix hairlines"));
// Nothing left: told, and no new undo step.
assert!(h.execute("prepress.hairlines"));
h.run_steps(2);
h.get_by_label("Fix").click();
h.run_steps(3);
- assert_eq!(support::shown_notice(&mut h).unwrap(), "No hairlines found on those pages");
+ assert_eq!(support::shown_notice(&h).unwrap(), "No hairlines found on those pages");
assert_eq!(h.state().session.get(id).unwrap().can_undo(), Some("Fix hairlines"));
}
@@ -9731,7 +9731,7 @@ fn fix_hairlines_notice_uses_singular_and_plural() {
h.run_steps(2);
h.get_by_label("Fix").click();
h.run_steps(3);
- assert_eq!(support::shown_notice(&mut h).unwrap(), "Fixed 2 hairlines on 1 page");
+ assert_eq!(support::shown_notice(&h).unwrap(), "Fixed 2 hairlines on 1 page");
}
/// The Read mode command (not the mode bar) applies a paragraph still open in the editor, as
diff --git a/crates/ui-egui/tests/it/export.rs b/crates/ui-egui/tests/it/export.rs
index 76b72e347a..965f5ba5e2 100644
--- a/crates/ui-egui/tests/it/export.rs
+++ b/crates/ui-egui/tests/it/export.rs
@@ -7,7 +7,6 @@ use crate::support::AppHarness as _;
use craft::host::{ManualJobs, Picked, ScriptedFiles};
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
-use pdfcraft_ui_egui::PdfCraftApp;
const FIXTURE: &[u8] = b"%PDF-1.7
1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj
diff --git a/crates/ui-egui/tests/it/find_replace.rs b/crates/ui-egui/tests/it/find_replace.rs
index e0d664d425..51516b386c 100644
--- a/crates/ui-egui/tests/it/find_replace.rs
+++ b/crates/ui-egui/tests/it/find_replace.rs
@@ -104,7 +104,7 @@ fn replace_all_from_the_find_bar_is_one_undo_step() {
h.get_by_label(&replace_all()).click();
h.run_steps(4);
assert_eq!(texts(&h), ["dog and dog", "a dog"]);
- assert!(support::shown_notice(&mut h).is_some(), "Replace all says what it did");
+ assert!(support::shown_notice(&h).is_some(), "Replace all says what it did");
let s = h.state();
assert_eq!(s.session.get(s.views[0].id).unwrap().can_undo(), Some("Replace all"));
// One Undo puts every page back.
diff --git a/crates/ui-egui/tests/it/layer_actions.rs b/crates/ui-egui/tests/it/layer_actions.rs
index f6f9622139..acefbdc7e7 100644
--- a/crates/ui-egui/tests/it/layer_actions.rs
+++ b/crates/ui-egui/tests/it/layer_actions.rs
@@ -1,8 +1,6 @@
//! Set-layer-visibility actions (`SetOCGState`) on links and push buttons show and hide layers,
//! as the Layers panel does.
-use std::sync::Arc;
-
use egui::Pos2;
use egui::accesskit::Role;
use egui_kittest::Harness;
diff --git a/crates/ui-egui/tests/it/marks.rs b/crates/ui-egui/tests/it/marks.rs
index 4feba772e3..f62fa94d6e 100644
--- a/crates/ui-egui/tests/it/marks.rs
+++ b/crates/ui-egui/tests/it/marks.rs
@@ -375,7 +375,7 @@ fn remove_background_says_which_pages_keep_their_own_backdrop_off() {
h.steps(2);
assert!(marks(&h).is_empty());
assert_eq!(
- support::shown_notice(&mut h.h).as_deref(),
+ support::shown_notice(&h.h).as_deref(),
Some("Page 1 changed after the background was added, so its own white backdrop stays off. It looks the same on white paper.")
);
}
diff --git a/crates/ui-egui/tests/it/page_view.rs b/crates/ui-egui/tests/it/page_view.rs
index af1564814e..da568ae1ea 100644
--- a/crates/ui-egui/tests/it/page_view.rs
+++ b/crates/ui-egui/tests/it/page_view.rs
@@ -2,7 +2,6 @@
//! frame is invisible to a component trial, so the whole app runs here.
use egui_kittest::Harness;
-use pdfcraft_ui_egui::PdfCraftApp;
#[test]
fn a_document_tab_shows_its_pages_for_a_few_frames() {
diff --git a/crates/ui-egui/tests/it/pickers.rs b/crates/ui-egui/tests/it/pickers.rs
index 954194e5c5..8c3b6bfcf8 100644
--- a/crates/ui-egui/tests/it/pickers.rs
+++ b/crates/ui-egui/tests/it/pickers.rs
@@ -211,7 +211,7 @@ fn a_pick_for_a_document_that_is_no_longer_active_is_dropped() {
h.answer(Picked::Paths(vec![file]));
assert_eq!(pages(h.state(), 0), 3, "the document the pick was for is unchanged");
assert_eq!(pages(h.state(), 1), 4, "the newly active document is unchanged");
- assert!(support::shown_notice(&mut h).is_some(), "the user is told why nothing happened");
+ assert!(support::shown_notice(&h).is_some(), "the user is told why nothing happened");
let _ = std::fs::remove_dir_all(&dir);
}
@@ -330,6 +330,7 @@ fn type_into(r: &mut Rig, label: &str, text: &str) {
}
/// What the Extract dialog is filled with; `None` leaves a field as the dialog opened it.
+#[derive(Default)]
struct Extract<'a> {
name: Option<&'a str>,
pages: Option<&'a str>,
@@ -337,12 +338,6 @@ struct Extract<'a> {
delete: bool,
}
-impl Default for Extract<'_> {
- fn default() -> Self {
- Self { name: None, pages: None, separate: false, delete: false }
- }
-}
-
/// Opens Extract pages through its command and fills it in; leaves the dialog open.
fn open_extract(r: &mut Rig, e: Extract) {
assert!(r.execute("page.extract"));
@@ -532,7 +527,7 @@ fn extracted_pages_are_not_deleted_if_the_document_was_edited_while_choosing_the
h.answer(Picked::Paths(vec![dir.clone()]));
assert!(h.files.file(&dir.join("doc0 (page 1).pdf")).is_some(), "the extracted file is still written");
assert_eq!(pages(h.state(), 0), 2, "nothing more is deleted");
- assert!(support::shown_notice(&mut h).is_some(), "the user is told");
+ assert!(support::shown_notice(&h).is_some(), "the user is told");
let _ = std::fs::remove_dir_all(&dir);
}
@@ -609,7 +604,7 @@ fn a_browser_insert_that_arrives_after_switching_documents_changes_neither() {
h.answer(Picked::Contents(vec![("b.pdf".into(), fixture(1))]));
assert_eq!(pages(h.state(), 0), 3, "A is unchanged");
assert_eq!(pages(h.state(), 1), 1, "C is unchanged");
- assert!(support::shown_notice(&mut h).is_some(), "the user is told why nothing happened");
+ assert!(support::shown_notice(&h).is_some(), "the user is told why nothing happened");
}
#[test]
@@ -632,7 +627,7 @@ fn replace_pages_applies_only_to_the_document_its_dialog_was_opened_on() {
press(&mut h, "OK");
if switch {
assert!(!dirty(h.state(), 0) && !dirty(h.state(), 1), "neither document is changed");
- assert!(support::shown_notice(&mut h).is_some(), "the user is told why");
+ assert!(support::shown_notice(&h).is_some(), "the user is told why");
} else {
assert!(dirty(h.state(), 0) && !dirty(h.state(), 1), "the first document's page is replaced");
}
@@ -647,7 +642,7 @@ fn a_failed_startup_url_is_reported_in_the_app() {
let mut h = harness(&[]);
h.deliver("missing.pdf", b"HTTP 404".to_vec());
h.steps(2);
- assert!(support::shown_notice(&mut h).is_some(), "the failure is reported");
+ assert!(support::shown_notice(&h).is_some(), "the failure is reported");
assert!(h.state().views.is_empty(), "no document was opened");
}
@@ -769,7 +764,7 @@ fn a_broken_late_startup_file_reports_its_error_without_changing_the_active_docu
h.steps(2);
assert_eq!(h.state().active, Some(0));
assert_eq!(h.state().views.len(), 1);
- let notice = support::shown_notice(&mut h).expect("the failure is reported");
+ let notice = support::shown_notice(&h).expect("the failure is reported");
assert!(notice.contains("broken.pdf"), "{notice}");
}
@@ -895,10 +890,10 @@ fn a_background_startup_forms_script_notice_waits_until_its_tab_is_selected() {
h.deliver("late-form.pdf", pdfcraft_xfa::fixtures::shell(&template));
h.steps(2);
assert_eq!(h.state().active, Some(0));
- assert!(support::shown_notice(&mut h).is_none(), "the background form must not interrupt the current document");
+ assert!(support::shown_notice(&h).is_none(), "the background form must not interrupt the current document");
h.get_by_label("late-form.pdf").click();
h.steps(2);
- let notice = support::shown_notice(&mut h).expect("the form's message shows once its tab is selected");
+ let notice = support::shown_notice(&h).expect("the form's message shows once its tab is selected");
assert!(notice.contains("Late form opened"), "{notice}");
}
@@ -1070,7 +1065,7 @@ fn files_written_from_an_attachment_tab_stay_inside_the_chosen_folder() {
open_extract(&mut h, Extract { separate: true, ..Default::default() });
confirm_extract(&mut h);
h.answer(Picked::Paths(vec![out.clone()]));
- assert!(support::shown_notice(&mut h).is_some(), "{name}: Extract reports what it wrote");
+ assert!(support::shown_notice(&h).is_some(), "{name}: Extract reports what it wrote");
assert_eq!(files_written(&h), written, "{name}");
std::fs::remove_dir_all(dir.0.join("a")).unwrap();
}
diff --git a/crates/ui-egui/tests/it/preferences.rs b/crates/ui-egui/tests/it/preferences.rs
index ef3f597c22..56fe27deb8 100644
--- a/crates/ui-egui/tests/it/preferences.rs
+++ b/crates/ui-egui/tests/it/preferences.rs
@@ -101,7 +101,7 @@ fn cases() -> Vec {
},
applied: |a| {
let v = &a.views[0].view;
- v.display == craft::pages::PageDisplay::TwoUp && v.continuous != crate::control::new_app().views.first().map_or(true, |_| true)
+ v.display == craft::pages::PageDisplay::TwoUp && v.continuous != crate::control::new_app().views.first().is_none_or(|_| true)
},
},
Case {
@@ -167,7 +167,7 @@ fn edited(case: &Case) -> H {
fn preference_rows_apply_live_and_survive_closing() {
for case in cases() {
let mut h = edited(&case);
- assert!((case.applied)(h.state()), "{}: a row applies immediately", case.name);
+ assert!((case.applied)(h.state()), "{} ({}): a row applies immediately", case.name, case.page);
click(&mut h, "OK");
h.run_steps(3);
assert!(!preferences_shown(&h), "{}: OK closes the window", case.name);
diff --git a/crates/ui-egui/tests/it/prepare.rs b/crates/ui-egui/tests/it/prepare.rs
index b0deecf74a..b8cf14885f 100644
--- a/crates/ui-egui/tests/it/prepare.rs
+++ b/crates/ui-egui/tests/it/prepare.rs
@@ -8,7 +8,7 @@ use craft::ui::runtime::toast;
use egui::Pos2;
use egui::accesskit::Role;
use egui_kittest::Harness;
-use egui_kittest::kittest::{NodeT as _, Queryable, by};
+use egui_kittest::kittest::{NodeT as _, Queryable};
use pdfcraft_ui_egui::field_table_ui::FieldTableDialog;
use pdfcraft_ui_egui::prepare::FieldPropsDialog;
use pdfcraft_ui_egui::{PdfCraftApp, QuickTool};
diff --git a/crates/ui-egui/tests/it/print.rs b/crates/ui-egui/tests/it/print.rs
index f3cc6c058c..865e252635 100644
--- a/crates/ui-egui/tests/it/print.rs
+++ b/crates/ui-egui/tests/it/print.rs
@@ -246,7 +246,7 @@ impl Rig {
/// Whether the preview shows why the draft can't print a document of `pages` pages, as the draft gives the reason.
fn preview_says_why(&self, pages: usize) -> bool {
- let why = self.state().print_draft.settings(pages, &[]).err().expect("the draft can't print");
+ let why = self.state().print_draft.settings(pages, &[]).expect_err("the draft can't print");
self.query_by_label_contains(&why).is_some()
}
diff --git a/crates/ui-egui/tests/it/print_custom_paper_names.rs b/crates/ui-egui/tests/it/print_custom_paper_names.rs
index e6d3c7e35a..9134f50c1a 100644
--- a/crates/ui-egui/tests/it/print_custom_paper_names.rs
+++ b/crates/ui-egui/tests/it/print_custom_paper_names.rs
@@ -2,7 +2,6 @@
//! standard size would be found first and a printer's custom paper (#2001) would come back as it.
use crate::print::{harness, restore};
-use pdfcraft_ui_egui::PdfCraftApp;
use std::sync::Arc;
#[test]
diff --git a/crates/ui-egui/tests/it/reading_colors.rs b/crates/ui-egui/tests/it/reading_colors.rs
index f17efe4615..c48b0722e3 100644
--- a/crates/ui-egui/tests/it/reading_colors.rs
+++ b/crates/ui-egui/tests/it/reading_colors.rs
@@ -3,7 +3,7 @@
use crate::support::AppHarness as _;
use egui_kittest::Harness;
-use egui_kittest::kittest::{NodeT as _, Queryable};
+use egui_kittest::kittest::Queryable;
use pdfcraft_render::ReadingColors;
use pdfcraft_ui_egui::PdfCraftApp;
diff --git a/crates/ui-egui/tests/it/script_noop.rs b/crates/ui-egui/tests/it/script_noop.rs
index d34aef8475..abc894c7cc 100644
--- a/crates/ui-egui/tests/it/script_noop.rs
+++ b/crates/ui-egui/tests/it/script_noop.rs
@@ -2,7 +2,6 @@
use crate::support::AppHarness as _;
use egui_kittest::{Harness, kittest::Queryable};
use pdfcraft_render::{PageRenderer, RenderRequest};
-use pdfcraft_ui_egui::PdfCraftApp;
use std::sync::Arc;
fn hidden_text() -> Vec {
diff --git a/crates/ui-egui/tests/it/signing.rs b/crates/ui-egui/tests/it/signing.rs
index ad2bfa15d6..606c823c02 100644
--- a/crates/ui-egui/tests/it/signing.rs
+++ b/crates/ui-egui/tests/it/signing.rs
@@ -191,7 +191,7 @@ fn trust_signer_and_inspect_certificate(h: &mut Harness<'static, PdfCraftApp>) {
// Seed a find so the trust path proves it invalidates the view: trust rebuilds
// the display copy, and the next frame must draw from it without any zoom change.
let mut find = pdfcraft_ui_egui::canvas::Find::default();
- find.matches.set_page(0, vec![0..5]);
+ find.matches.set_page(0, std::iter::once(0..5).collect::>());
h.state_mut().views[0].find = Some(find);
h.get_by_label("Add to trusted certificates").click();
h.run_steps(3);
diff --git a/crates/ui-egui/tests/it/stamps.rs b/crates/ui-egui/tests/it/stamps.rs
index 59b293203b..91f57d33b8 100644
--- a/crates/ui-egui/tests/it/stamps.rs
+++ b/crates/ui-egui/tests/it/stamps.rs
@@ -3,7 +3,7 @@
use crate::support::AppHarness as _;
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
-use pdfcraft_ui_egui::{PdfCraftApp, QuickTool};
+use pdfcraft_ui_egui::QuickTool;
#[test]
fn choosing_and_placing_stamps() {
diff --git a/crates/ui-egui/tests/it/support/input.rs b/crates/ui-egui/tests/it/support/input.rs
index 9dd503781a..0e8f63b03f 100644
--- a/crates/ui-egui/tests/it/support/input.rs
+++ b/crates/ui-egui/tests/it/support/input.rs
@@ -33,26 +33,6 @@ pub fn touch_tap(h: &mut Harness<'_, S>, p: Pos2) {
h.run_steps(4);
}
-/// A finger drag from `a` to `b` in six moves, one frame each, ending as a touch does: release
-/// and `PointerGone` in one frame.
-pub fn touch_drag(h: &mut Harness<'_, S>, a: Pos2, b: Pos2) {
- one_frame(h, [touch(TouchPhase::Start, a), Event::PointerMoved(a), button(a, true)]);
- for i in 1..=6 {
- let p = a + (b - a) * (i as f32 / 6.0);
- one_frame(h, [touch(TouchPhase::Move, p), Event::PointerMoved(p)]);
- }
- one_frame(h, [touch(TouchPhase::End, b), button(b, false), Event::PointerGone]);
- h.run_steps(4);
-}
-
-/// A mouse click at `p` whose press and release land in one slow frame (#2100).
-pub fn coalesced_click(h: &mut Harness<'_, S>, p: Pos2) {
- h.hover_at(p);
- h.run_steps(2);
- one_frame(h, [button(p, true), button(p, false)]);
- h.run_steps(4);
-}
-
/// A double-click at `p`: two clicks, each a press and release in one frame, in consecutive
/// frames (0.25 s apart, within egui's 0.3 s double-click delay).
pub fn double_click(h: &mut Harness<'_, S>, p: Pos2) {
diff --git a/crates/ui-egui/tests/it/support/mod.rs b/crates/ui-egui/tests/it/support/mod.rs
index eb496a8d54..dbb9ad0a32 100644
--- a/crates/ui-egui/tests/it/support/mod.rs
+++ b/crates/ui-egui/tests/it/support/mod.rs
@@ -149,14 +149,6 @@ pub fn install_runtime(ctx: &egui::Context) {
embed::install(ctx, spec, &pdfcraft_ui_egui::fonts::ui_fonts(i18n::Lang::EN)).expect("the runtime installs on a fresh context");
}
-pub fn host_harness(host: Arc, clipboard: RecordingClipboard) -> Harness<'static, PdfCraftApp> {
- let app = PdfCraftApp::with_host(host, services(clipboard));
- Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |cc| {
- crate::support::install_runtime(&cc.egui_ctx);
- app
- })
-}
-
/// A clipboard backend the tests share: what the app writes is read back through the clone the test keeps.
#[derive(Clone, Default)]
pub struct RecordingClipboard {
@@ -341,7 +333,6 @@ pub trait AppHarness {
fn set_option(&mut self, key: &str, value: &str) -> Result<(), String>;
fn undo(&mut self);
fn redo(&mut self);
- fn run_command(&mut self, id: &str);
fn submit_password(&mut self, password: Option);
fn run_button_script(&mut self, id: pdfcraft_engine::DocId, field: &str, script: &str);
fn snapshot(&mut self, index: usize, page: usize, view_rect: [f32; 4]) -> Result<(u32, u32), String>;
@@ -369,11 +360,6 @@ impl AppHarness for Harness<'_, PdfCraftApp> {
self.state_mut().redo(&ctx);
}
- fn run_command(&mut self, id: &str) {
- let ctx = self.ctx.clone();
- self.state_mut().run_command(&ctx, id);
- }
-
fn submit_password(&mut self, password: Option) {
let ctx = self.ctx.clone();
self.state_mut().submit_password(&ctx, password);
diff --git a/crates/ui-egui/tests/it/text_select.rs b/crates/ui-egui/tests/it/text_select.rs
index c5b820386c..06ed1769f1 100644
--- a/crates/ui-egui/tests/it/text_select.rs
+++ b/crates/ui-egui/tests/it/text_select.rs
@@ -85,7 +85,7 @@ fn html_sets(clipboard: &RecordingClipboard) -> Vec<(String, String)> {
.writes()
.iter()
.filter_map(|flavors| {
- let part = |mime: &str| flavors.iter().find(|f| f.mime.to_string() == mime).map(|f| String::from_utf8_lossy(&f.data).into_owned());
+ let part = |mime: &str| flavors.iter().find(|f| f.mime == mime).map(|f| String::from_utf8_lossy(&f.data).into_owned());
Some((part("text/html")?, part("text/plain").unwrap_or_default()))
})
.collect()
diff --git a/crates/ui-egui/tests/it/trust_signer.rs b/crates/ui-egui/tests/it/trust_signer.rs
index fa4a20ab85..c0c3b45c8f 100644
--- a/crates/ui-egui/tests/it/trust_signer.rs
+++ b/crates/ui-egui/tests/it/trust_signer.rs
@@ -6,7 +6,7 @@
use crate::support;
use crate::support::AppHarness as _;
use egui_kittest::Harness;
-use egui_kittest::kittest::{NodeT, Queryable};
+use egui_kittest::kittest::Queryable;
use pdfcraft_engine::SignatureStatus;
use pdfcraft_ui_egui::{PdfCraftApp, SignStep};
diff --git a/crates/ui-egui/tests/it/view.rs b/crates/ui-egui/tests/it/view.rs
index 3ea3f19b37..963ba2d5a2 100644
--- a/crates/ui-egui/tests/it/view.rs
+++ b/crates/ui-egui/tests/it/view.rs
@@ -660,7 +660,6 @@ fn always_use_my_default_zoom_and_page_layout_survives_a_restart() {
#[test]
fn preferences_turn_on_always_use_my_default_zoom_and_page_layout() {
- use egui_kittest::kittest::Queryable;
let mut h = harness(&[]);
assert!(h.execute("app.preferences"));
h.run_steps(3);
@@ -670,7 +669,6 @@ fn preferences_turn_on_always_use_my_default_zoom_and_page_layout() {
#[test]
fn preferences_turn_on_always_use_my_default_zoom_and_page_layout_updates_open_documents() {
- use egui_kittest::kittest::Queryable;
let mut h = harness(&[("continuous", "off"), ("zoom", "50")]);
let ctx_h = h.ctx.clone();
h.state_mut().open_bytes(&ctx_h, "second.pdf", None, PAGES.to_vec()).expect("opens");
@@ -695,7 +693,6 @@ fn preferences_turn_on_always_use_my_default_zoom_and_page_layout_updates_open_d
#[test]
fn preferences_toggle_continuous_scrolling_updates_active_document() {
- use egui_kittest::kittest::Queryable;
let mut h = harness(&[("default-continuous", "off"), ("continuous", "off")]);
assert!(!h.state().view_defaults.continuous);
assert!(!h.state().views[0].continuous());
@@ -708,7 +705,6 @@ fn preferences_toggle_continuous_scrolling_updates_active_document() {
#[test]
fn preferences_during_full_screen_updates_saved_normal_display_and_restores_on_exit() {
- use egui_kittest::kittest::Queryable;
use pdfcraft_ui_egui::canvas::Fit;
let mut h = harness(&[("continuous", "off"), ("zoom", "50")]);
@@ -750,7 +746,6 @@ fn preferences_during_full_screen_updates_saved_normal_display_and_restores_on_e
#[test]
fn preferences_toggle_continuous_during_full_screen_updates_saved_normal_display() {
- use egui_kittest::kittest::Queryable;
use pdfcraft_ui_egui::canvas::Fit;
let mut h = harness(&[("default-continuous", "off"), ("continuous", "off")]);
@@ -787,8 +782,6 @@ fn preferences_toggle_continuous_during_full_screen_updates_saved_normal_display
#[test]
fn preferences_with_always_default_view_on_toggling_continuous_preserves_custom_zoom() {
- use egui_kittest::kittest::Queryable;
-
let mut h = harness(&[("always-default-view", "on"), ("default-continuous", "off"), ("continuous", "off"), ("zoom", "200")]);
assert!(h.state().always_default_view);
assert!(!h.state().view_defaults.continuous);
@@ -807,7 +800,6 @@ fn preferences_with_always_default_view_on_toggling_continuous_preserves_custom_
#[test]
fn preferences_set_the_default_zoom() {
- use egui_kittest::kittest::Queryable;
let mut h = harness(&[]);
assert!(h.execute("app.preferences"));
h.run_steps(3);
@@ -1866,56 +1858,6 @@ fn compare_page_with_raster(h: &mut Harness<'static, PdfCraftApp>, pdf: &[u8], z
(sum as f64 / n as f64, worst)
}
-/// A 1200 pt square page of fine lines (0.5 pt every 1.7 pt): tiled at 300 %, whole-page at 150 %.
-fn fine_grid_pdf() -> Vec {
- let mut content = String::from("0 g\n");
- for i in 0..670 {
- let v = 30.0 + 1.7 * i as f32;
- content.push_str(&format!("{v} 30 0.5 1140 re 30 {v} 1140 0.5 re\n"));
- }
- content.push_str("f\n");
- format!(
- "%PDF-1.7
-1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj
-2 0 obj << /Type /Pages /Kids [3 0 R] /Count 1 >> endobj
-3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 1200 1200] /Contents 4 0 R >> endobj
-4 0 obj << /Length {} >> stream
-{content}
-endstream endobj
-trailer << /Root 1 0 R >>
-%%EOF",
- content.len()
- )
- .into_bytes()
-}
-
-fn grid_harness(pdf: Vec, zoom: &str) -> Harness<'static, PdfCraftApp> {
- Harness::builder().with_size(egui::vec2(1000.0, 800.0)).build_eframe(move |cc| {
- crate::support::install_runtime(&cc.egui_ctx);
- {
- let mut app = crate::control::new_app();
- app.open_bytes(&egui::Context::default(), "grid.pdf", None, pdf.clone()).expect("opens");
- app.set_option(&egui::Context::default(), "left", "closed").unwrap();
- app.set_option(&egui::Context::default(), "panel", "none").unwrap();
- app.set_option(&egui::Context::default(), "zoom", zoom).unwrap();
- app
- }
- })
-}
-
-/// Detail in the middle of the window: the summed difference between neighbouring pixels.
-fn centre_detail(h: &mut Harness<'static, PdfCraftApp>) -> u64 {
- let img = h.render().expect("renders");
- let (cx, cy) = (img.width() / 2, img.height() / 2);
- let mut sum = 0u64;
- for y in cy - 100..cy + 100 {
- for x in cx - 150..cx + 150 {
- sum += u64::from(img.get_pixel(x, y)[0].abs_diff(img.get_pixel(x + 1, y)[0]));
- }
- }
- sum
-}
-
#[test]
fn sidebar_collapse_and_resize_preserves_scroll_position() {
use pdfcraft_ui_egui::canvas::Fit;
@@ -2610,7 +2552,7 @@ fn delete_with_a_menu_open_and_escape_closing_a_thumbnail_menu_leave_the_pages_p
let page_2 = h.get_by_label("Page 2").rect().center();
click_with(&mut h, page_2, Modifiers::COMMAND);
let selected = h.state().views[0].selected.clone();
- assert_eq!(selected.items.iter().copied().collect::>(), [0, 1], "⌘-click picked pages 1 and 2");
+ assert_eq!(selected.items.to_vec(), [0, 1], "⌘-click picked pages 1 and 2");
let thumb = h.get_by_label("Page 2").rect().center();
crate::support::open_menu(&mut h, "View");
h.hover_at(thumb);
diff --git a/crates/ui-egui/tests/it/viewer.rs b/crates/ui-egui/tests/it/viewer.rs
index 5d83fd262a..25ed23320f 100644
--- a/crates/ui-egui/tests/it/viewer.rs
+++ b/crates/ui-egui/tests/it/viewer.rs
@@ -70,18 +70,10 @@ fn fixture(n: usize) -> Vec {
/// What the app wrote to its clipboard: the `(mime, data)` flavours of each write.
#[derive(Clone, Default)]
-struct Written(Arc)>>>>);
+struct Written(Arc>);
-impl Written {
- fn writes(&self) -> Vec)>> {
- self.0.lock().unwrap().clone()
- }
-
- /// Whether a write held a flavour of `mime`.
- fn has(&self, mime: &str) -> bool {
- self.writes().iter().flatten().any(|(m, _)| m == mime)
- }
-}
+/// Each clipboard write, as its `(mime, data)` flavours.
+type Writes = Vec)>>;
/// An app whose pickers answer from `files` and whose clipboard writes land in `written`.
fn app_on(files: Arc, written: &Written) -> PdfCraftApp {
@@ -1068,7 +1060,7 @@ trailer << /Root 1 0 R >>
#[test]
fn initial_view_is_edited_and_honoured_on_open() {
- use pdfcraft_engine::{InitialLayout, Magnification, Navigation};
+ use pdfcraft_engine::{InitialLayout, Navigation};
let mut h = harness();
open_properties(&mut h, PropsTab::InitialView);
// The form row names its field group; the field inside carries the same name.
@@ -1519,10 +1511,7 @@ fn an_earlier_revision_opens_from_document_properties() {
h.state_mut().open_revision(99);
h.run_steps(1);
assert_eq!(h.state().views.len(), views);
- assert!(
- crate::support::shown_notice(&mut h).is_some_and(|notice| notice.contains("revision 99")),
- "unknown revisions error without opening a tab"
- );
+ assert!(crate::support::shown_notice(&h).is_some_and(|notice| notice.contains("revision 99")), "unknown revisions error without opening a tab");
// Another tab over the same original shares the snapshot: b.pdf's first revision is
// byte-identical to updated.pdf's (incremental saves append), so it reuses the tab.
let ids: Vec<_> = h.state().views.iter().map(|v| v.id).collect();
diff --git a/crates/ui-egui/tests/page_shadows.rs b/crates/ui-egui/tests/page_shadows.rs
index abe390b247..b80b84ad56 100644
--- a/crates/ui-egui/tests/page_shadows.rs
+++ b/crates/ui-egui/tests/page_shadows.rs
@@ -239,16 +239,10 @@ fn new_app() -> pdfcraft_ui_egui::PdfCraftApp {
/// The app's command and option entry points with the harness's own context (L-208).
trait AppHarness {
- fn execute(&mut self, id: &str) -> bool;
fn set_option(&mut self, key: &str, value: &str) -> Result<(), String>;
}
impl AppHarness for egui_kittest::Harness<'_, pdfcraft_ui_egui::PdfCraftApp> {
- fn execute(&mut self, id: &str) -> bool {
- let ctx = self.ctx.clone();
- self.state_mut().execute(&ctx, id)
- }
-
fn set_option(&mut self, key: &str, value: &str) -> Result<(), String> {
let ctx = self.ctx.clone();
self.state_mut().set_option(&ctx, key, value)
diff --git a/crates/ui-egui/tests/play.rs b/crates/ui-egui/tests/play.rs
index 33322369c7..3fcc00284a 100644
--- a/crates/ui-egui/tests/play.rs
+++ b/crates/ui-egui/tests/play.rs
@@ -22,7 +22,7 @@ use std::path::{Path, PathBuf};
use egui::accesskit::Role;
use egui::{Key, Modifiers};
use egui_kittest::Harness;
-use egui_kittest::kittest::{NodeT, Queryable};
+use egui_kittest::kittest::Queryable;
use pdfcraft_ui_egui::PdfCraftApp;
use serde::Deserialize;