diff --git a/crates/print/src/tests/windows_native.rs b/crates/print/src/tests/windows_native.rs index 04dcff75..db8b5c02 100644 --- a/crates/print/src/tests/windows_native.rs +++ b/crates/print/src/tests/windows_native.rs @@ -409,9 +409,15 @@ fn windows_jobs_reach_the_spooler() { eprintln!("skipping the real print: the test printer could not be prepared: {why}"); return; } + let queries = || crate::windows::CAPABILITY_QUERIES.with(std::cell::Cell::get); + let start = queries(); let listed = spool::printers().into_iter().find(|p| p.name == name); - // The list a Print dialog shows first: the same queue, named without asking its driver. + let probed = queries().saturating_sub(start); + // The list a Print dialog shows first: the same queue, named without asking its driver (a + // networked printer in power save can hold that query, storytold/wordcraft#5710). + let start = queries(); let queue = spool::printer_queues().into_iter().find(|p| p.name == name); + let unprobed = queries().saturating_sub(start); let mixed = test_pdf(&[LETTER, LETTER_LANDSCAPE, LETTER], true); let job = Job { printer: Some(name.into()), title: "mixed.pdf".into(), ..Job::default() }; let caller = std::thread::current().id(); @@ -452,7 +458,9 @@ fn windows_jobs_reach_the_spooler() { name, ); assert!(listed.as_ref().is_some_and(|p| p.two_sided.is_some()), "the new printer is listed, its duplex support known: {listed:?}"); - assert!(queue.as_ref().is_some_and(|p| p.two_sided.is_none()), "the new printer is listed with no driver query: {queue:?}"); + assert!(queue.as_ref().is_some_and(|p| p.two_sided.is_none()), "the new printer is listed, its duplex support unknown: {queue:?}"); + assert!(probed > 0, "printers() asks each driver, so the count sees driver queries: {probed}"); + assert_eq!(unprobed, 0, "printer_queues() asks no driver"); assert_eq!(sent.as_deref(), Ok("spooled 3 sheet(s)"), "{sent:?}"); if let Some(refused) = duplex_refused { assert!(matches!(refused, Err(Error::Spool(ref m)) if m.contains("simplex/duplex") && m.contains("nothing was sent")), "{refused:?}"); diff --git a/crates/print/src/windows.rs b/crates/print/src/windows.rs index 20fb7176..cf598d75 100644 --- a/crates/print/src/windows.rs +++ b/crates/print/src/windows.rs @@ -60,10 +60,19 @@ fn spooler_list(two_sided: impl Fn(&PrinterDevice) -> Option) -> Vec = const { std::cell::Cell::new(0) }; +} + /// Whether the printer's driver takes two-sided settings: its PrintCapabilities offer a two-sided /// option for the feature the job's ticket sets. `None` when the capabilities can't be read. A /// driver without one cannot confirm an explicit two-sided request, which is refused before submission. fn two_sided(device: &PrinterDevice) -> Option { + #[cfg(test)] + CAPABILITY_QUERIES.with(|n| n.set(n.get().saturating_add(1))); let capabilities = { let _provider = print_ticket_provider(); PrintCapabilities::fetch(device)