Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Windows: folder-drop tests name folders as the Folders tree does; offline test waits for its worker

Claude5902a07354a7
diff --git a/crates/ui-egui/src/tests_folder_drop.rs b/crates/ui-egui/src/tests_folder_drop.rs
index 9b4cb860a..0bb844d58 100644
--- a/crates/ui-egui/src/tests_folder_drop.rs
+++ b/crates/ui-egui/src/tests_folder_drop.rs
@@ -50,8 +50,13 @@ fn widget(h: &Headless, id: &str) -> Option<Rect> {
h.app.widgets.iter().find(|(w, _)| w == id).map(|(_, r)| *r)
}
+/// A folder as the Folders tree names it: `/`-separated on every platform.
+fn tree_path(dir: &Path) -> String {
+ dir.to_string_lossy().replace('\\', "/")
+}
+
fn folder_row(h: &Headless, dir: &Path) -> Option<Rect> {
- widget(h, &format!("source:libfolder:{}", dir.to_string_lossy()))
+ widget(h, &format!("source:libfolder:{}", tree_path(dir)))
}
fn id_of(h: &Headless, file: &str) -> u64 {
@@ -180,7 +185,7 @@ fn photos_already_in_the_folder_stay_put() {
let (root, trip, home) = folders("here");
let mut h = app(&[(trip.join("beach.png"), false), (home.join("garden.png"), false)]);
// open the folder holding both
- let toggle = widget(&h, &format!("libraryFolderToggle:{}", root.to_string_lossy())).unwrap();
+ let toggle = widget(&h, &format!("libraryFolderToggle:{}", tree_path(&root))).unwrap();
h.app.synthetic.push(egui::Event::PointerMoved(toggle.center()));
h.app.synthetic.push(egui::Event::PointerButton {
pos: toggle.center(),
@@ -284,7 +289,7 @@ fn cancelling_the_question_moves_nothing() {
let target = if folder_row(&h, &home).is_some() {
target
} else {
- click(&mut h, &format!("libraryFolderToggle:{}", root.to_string_lossy()));
+ click(&mut h, &format!("libraryFolderToggle:{}", tree_path(&root)));
folder_row(&h, &home).unwrap()
};
let undo = h.app.session.undo.len();
@@ -302,7 +307,7 @@ fn dont_ask_again_moves_the_next_drop_at_once() {
let (root, trip, home) = folders("dont-ask");
std::fs::copy(trip.join("beach.png"), trip.join("dunes.png")).unwrap();
let mut h = app(&[(trip.join("beach.png"), false), (trip.join("dunes.png"), false), (home.join("garden.png"), false)]);
- click(&mut h, &format!("libraryFolderToggle:{}", root.to_string_lossy()));
+ click(&mut h, &format!("libraryFolderToggle:{}", tree_path(&root)));
let target = folder_row(&h, &home).unwrap();
let beach = id_of(&h, "beach.png");
h.app.session.selection = lightcraft_engine::Selection::single(lightcraft_catalog::PhotoId(beach));
@@ -327,7 +332,7 @@ fn dont_ask_again_moves_the_next_drop_at_once() {
fn a_question_left_open_while_another_library_opens_moves_nothing() {
let (root, trip, home) = folders("other-library");
let mut h = app(&[(trip.join("beach.png"), false), (home.join("garden.png"), false)]);
- click(&mut h, &format!("libraryFolderToggle:{}", root.to_string_lossy()));
+ click(&mut h, &format!("libraryFolderToggle:{}", tree_path(&root)));
let beach = id_of(&h, "beach.png");
let target = folder_row(&h, &home).unwrap();
drop_beach(&mut h, beach, target);
diff --git a/crates/ui-egui/src/tests_offline.rs b/crates/ui-egui/src/tests_offline.rs
index 9e0b85b78..5327412d1 100644
--- a/crates/ui-egui/src/tests_offline.rs
+++ b/crates/ui-egui/src/tests_offline.rs
@@ -155,6 +155,11 @@ fn offline_originals_never_block_a_frame() {
h.app.session.execute("library.source", &json!({"kind": "missing"})).unwrap();
assert_eq!(h.app.session.source, LibrarySource::Missing);
frames_while_asleep(&mut h, &nas, 20, "Missing Photos");
+ // the probe runs on the background worker: give it time to start on a loaded machine
+ let asked = std::time::Instant::now();
+ while calls.n.load(Ordering::SeqCst) == 0 && asked.elapsed() < std::time::Duration::from_secs(5) {
+ std::thread::sleep(std::time::Duration::from_millis(10));
+ }
assert!(calls.n.load(Ordering::SeqCst) > 0, "the probe was asked");
assert_eq!(h.app.session.visible().len(), 0, "unknown files count as there");