mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Tests: file dialog and histogram tests pass on Windows again
The file dialog tests rebuilt a Save request's suggested path with Path::join, which puts a backslash between the folder and the name on Windows, while the expected paths use "/". The helper now joins with "/". The histogram throttle test set the last count's time to 0, but each test pass moves the context's clock on by one frame, so a run that took more than 15 frames to settle was already past the 250 ms throttle. The test now sets the time to the context's current time.
This commit is contained in:
1 parent
c337d6e4e8
commit
08dcd6ba90
2 files changed
+10
-8
No files matched your search
@@ -50,11 +50,11 @@ fn chose(path: &str) -> Picked {
|
||||
Picked::Paths(vec![PathBuf::from(path)])
|
||||
}
|
||||
|
||||
/// The file a Save request suggests: its folder and name together.
|
||||
/// The file a Save request suggests: its folder and name together (see [`joined`]).
|
||||
fn suggested(request: &PickRequest) -> String {
|
||||
let name = request.file_name.clone().unwrap_or_default();
|
||||
match &request.directory {
|
||||
Some(dir) => dir.join(name).to_string_lossy().into_owned(),
|
||||
Some(dir) => joined(&dir.to_string_lossy(), &name),
|
||||
None => name,
|
||||
}
|
||||
}
|
||||
@@ -589,10 +589,10 @@ fn save_and_export_dialogs_start_beside_the_document() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The path `pick_save` suggests for `name` in `dir` on this platform: it joins with `Path::join`,
|
||||
/// which uses `\` on Windows, so the expected values must be built the same way (#2745).
|
||||
/// `name` in the folder `dir`, joined with `/` as the tests' paths are written. A Save request
|
||||
/// carries its folder and name apart, and `Path::join` would put `\` between them on Windows.
|
||||
fn joined(dir: &str, name: &str) -> String {
|
||||
Path::new(dir).join(name).to_string_lossy().into_owned()
|
||||
format!("{}/{name}", dir.trim_end_matches('/'))
|
||||
}
|
||||
|
||||
/// #1826: after the user navigates a save or export dialog elsewhere, the document's next dialog
|
||||
@@ -1428,7 +1428,7 @@ fn a_scripted_quality_survives_the_changed_on_disk_prompt() {
|
||||
fn save_a_copy_appends_copy_unless_the_preference_says_not_to() {
|
||||
let ctx = egui::Context::default();
|
||||
for (off, name) in [(false, "My image copy.psd"), (true, "My image.psd")] {
|
||||
let want = Path::new("/pics").join(name).to_string_lossy().into_owned();
|
||||
let want = joined("/pics", name);
|
||||
let (mut app, files, _) = jpeg_app(Some("/pics/My image.JPEG"), false);
|
||||
app.run("prefs.set", json!({"path": "fileHandling.doNotAppendCopy", "value": off})).unwrap();
|
||||
menus::invoke(&mut app, &ctx, "file.saveACopy", json!({})).unwrap();
|
||||
|
||||
@@ -276,8 +276,10 @@ fn cache_levels_one_still_throttles_recounts_and_an_uncached_refresh_does_not()
|
||||
let mut app = app_with(json!({"width": 64, "height": 48}));
|
||||
app.run("prefs.set", json!({"path": "performance.cacheLevels", "value": 1})).unwrap();
|
||||
settle(&mut app);
|
||||
// The count just landed, so the next edit falls inside the throttle.
|
||||
app.doc_hist.as_mut().unwrap().at = 0.0;
|
||||
// The count just landed, so the next edit falls inside the throttle. Each pass without an input
|
||||
// time moves the context's clock on by one frame, so "just now" is the context's time, not 0.
|
||||
let now = app.ctx().input(|i| i.time) * 1000.0;
|
||||
app.doc_hist.as_mut().unwrap().at = now;
|
||||
app.run("edit.fill", json!({"color": "#000000"})).unwrap();
|
||||
frame(&mut app);
|
||||
assert!(app.hist_job.is_none(), "an edit within 250 ms of the last count waits");
|
||||
|
||||
Reference in new issue
Block a user