mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-26 02:58:32 -06:00
The ui-egui integration tests drive the shell by its English labels, and `i18n::system_lang` returns `Lang::EN` under `cfg!(test)` so they can. That only covers the unit tests: an integration test links the library as it ships, where `cfg!(test)` is off, so `PdfCraftApp::new()` leaves `language` on `auto` and the shell is drawn in the system language. On a Spanish Windows eleven of the test binaries fail; a French, Russian, Chinese, Japanese, Portuguese, Czech or Telugu machine does the same. CI never sees it because its locale is English. `tests/theme.rs` and `tests/create.rs` already pin the option; the other 119 harnesses now do too, and the comment in `system_lang` says why, so a test copied from an existing one keeps the line. Also `i18n::tests::windows_display_language_query_returns_a_locale_tag` treated the return of `windows_ui_language()` as a single tag. It is the preferred-language list, one tag per line, as `first_supported` reads it, so on a Windows with two or more display languages the assertion tripped over the newline. It now checks the shape of every line. Co-authored-by: Fernando Areán <soporte@codebit.es> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
49 lines
1.8 KiB
Rust
49 lines
1.8 KiB
Rust
//! Export a PDF ▸ Image and Text from the real shell (egui_kittest).
|
|
|
|
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
|
|
2 0 obj << /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 /MediaBox [0 0 200 100] >> endobj
|
|
3 0 obj << /Type /Page /Parent 2 0 R >> endobj
|
|
4 0 obj << /Type /Page /Parent 2 0 R >> endobj
|
|
trailer << /Root 1 0 R >>
|
|
%%EOF";
|
|
|
|
#[test]
|
|
fn export_dialogs_write_images_and_text() {
|
|
let dir = std::env::temp_dir().join(format!("pdfcraft-export-ui-{}", std::process::id()));
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let d = dir.clone();
|
|
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| {
|
|
let mut app = PdfCraftApp::new();
|
|
app.set_option("language", "en").unwrap();
|
|
app.open_bytes("doc.pdf", None, FIXTURE.to_vec()).unwrap();
|
|
app.export_dir_override = Some(d.to_string_lossy().into_owned());
|
|
app
|
|
});
|
|
h.run_steps(4);
|
|
assert!(h.state_mut().execute("export.image"));
|
|
h.run_steps(2);
|
|
h.get_by_label("Export to Image");
|
|
h.get_by_label("Export").click();
|
|
h.run_steps(4);
|
|
assert!(dir.join("doc_page_1.png").exists() && dir.join("doc_page_2.png").exists());
|
|
h.get_by_label_contains("Exported 2 images");
|
|
assert!(h.state_mut().execute("export.text"));
|
|
h.run_steps(2);
|
|
h.get_by_label("Export").click();
|
|
h.run_steps(4);
|
|
assert!(dir.join("doc.txt").exists());
|
|
// Export all images: this document has none, and says so.
|
|
assert!(h.state_mut().execute("export.all_images"));
|
|
h.run_steps(2);
|
|
h.get_by_label("Export All Images");
|
|
h.get_by_label("Export").click();
|
|
h.run_steps(4);
|
|
h.get_by_label_contains("Exported 0 images");
|
|
}
|