mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-27 19:48:14 -06:00
* Build each crate's integration tests as one binary Every tests/*.rs file is its own executable that links the whole crate graph. Move each crate's test files into tests/it/ as modules of one tests/it/main.rs, for apps/pdfcraft, apps/pdfcraft-cli, automation, cos, crypt, engine, render, sign and ui-egui. ui-egui's ui_group binary and the support modules move into tests/it/ too. Crates with a single test file keep it. The test executables go from 150 to 52, and every crate runs the same number of tests as before. ui-egui perf keeps its own binary (own process): its frame-time budgets would charge each measurement for the other tests running beside it. What the move needs: - include_str!/include_bytes! and #[path] paths gain one "../". - ui-egui: one GPU lock in tests/it/main.rs replaces the five per-file ones (content, document_links, editing, fill_sign, view), so one process creates one wgpu device at a time. The drop-line test in ui.rs and the screenshot blocks behind PDFCRAFT_*_SHOT(S) and CRAFT_UI_DOCKING_DIR, which render without holding it, take it too. - pdfcraft winit_wayland_scroll: the vendored winit source it compiles names crate::event, so that shim lives in main.rs. - parity evidence names the new paths. * Name the one-binary test paths in docs and comments - READMEs, docs, ATTRIBUTION and source comments name tests/it/<file>.rs. - The oracle README's example filters with --test it encryption::qpdf_agrees. - pdfcraft's GPU lock comment points at the UI tests' shared lock in crates/ui-egui/tests/it/main.rs.
42 lines
1.4 KiB
Rust
42 lines
1.4 KiB
Rust
//! The title bar's theme button: a click cycles System, Light and Dark; a right-click opens the
|
|
//! menu with the appearance settings.
|
|
|
|
use egui_kittest::Harness;
|
|
use egui_kittest::kittest::Queryable;
|
|
use pdfcraft_ui_egui::PdfCraftApp;
|
|
|
|
fn harness() -> Harness<'static, PdfCraftApp> {
|
|
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| {
|
|
let mut app = PdfCraftApp::new();
|
|
app.set_option("language", "en").unwrap();
|
|
app
|
|
});
|
|
h.run_steps(6);
|
|
h
|
|
}
|
|
|
|
fn preference(h: &Harness<'static, PdfCraftApp>) -> String {
|
|
format!("{:?}", h.state().theme_preference)
|
|
}
|
|
|
|
#[test]
|
|
fn a_click_cycles_the_theme_and_a_right_click_opens_the_menu() {
|
|
let mut h = harness();
|
|
assert_eq!(preference(&h), "Light", "new installs start Light");
|
|
for (label, next) in
|
|
[("Display theme: Light gray", "Dark"), ("Display theme: Dark gray", "System"), ("Display theme: Use system setting", "Light")]
|
|
{
|
|
h.get_by_label(label).click();
|
|
h.run_steps(4);
|
|
assert_eq!(preference(&h), next);
|
|
}
|
|
assert!(h.query_by_label("Appearance settings…").is_none(), "a plain click opens no menu");
|
|
|
|
h.get_by_label("Display theme: Light gray").click_secondary();
|
|
h.run_steps(4);
|
|
h.get_by_label("Appearance settings…").click();
|
|
h.run_steps(4);
|
|
h.run_steps(10);
|
|
assert!(h.query_by_label("Light theme").is_some(), "Preferences opens on Appearance");
|
|
}
|