mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-03 17:24:42 +00:00
Drop: dropping an already-open document focuses its tab (#1620)
Co-authored-by: GLM <noreply@z.ai>
This commit is contained in:
1 parent
a5e16bf556
commit
a7160cf45c
1 file changed
+23
@@ -616,6 +616,29 @@ fn dropping_a_pdf_on_the_window_opens_it() {
|
||||
h.get_by_label_contains("dropped.pdf");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dropping_an_open_pdf_again_focuses_its_tab() {
|
||||
let dir = std::env::temp_dir().join(format!("pdfcraft-drop-dedup-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("dropped.pdf");
|
||||
std::fs::write(&path, FIXTURE).unwrap();
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_eframe(|_cc| {
|
||||
let mut app = PdfCraftApp::new();
|
||||
app.set_option("language", "en").unwrap();
|
||||
app
|
||||
});
|
||||
h.run_steps(3);
|
||||
let file: egui::DroppedFileHandle = std::sync::Arc::new(Dropped { path: path.clone(), bytes: FIXTURE.to_vec() });
|
||||
h.input_mut().dropped_files.push(file.clone());
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().views.len(), 1, "the dropped PDF opens in a tab");
|
||||
h.input_mut().dropped_files.push(file);
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().views.len(), 1, "dropping it again adds no tab");
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_file_dropped_on_the_page_grid_is_read_from_disk_and_inserted() {
|
||||
// The grid's drop reads a file from its path when its turn to be inserted comes, and inserts it
|
||||
|
||||
Reference in new issue
Block a user