mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-12 05:02:51 +00:00
Cover normal Paste followed by Paste As after an internal copy
This commit is contained in:
1 parent
a78b1f1bf8
commit
027b2cdd3c
3 files changed
+25
No files matched your search
@@ -67,6 +67,7 @@ fn assert_size_and_style(s: &Session, id: LayerId, scale: bool) {
|
||||
assert_eq!(stroke.size, if scale { 10.0 } else { 20.0 });
|
||||
}
|
||||
|
||||
/// Recorded true, false and omitted flags retain their meaning through save and playback.
|
||||
#[test]
|
||||
fn imported_style_scaling_survives_saved_bytes_and_playback() {
|
||||
for event in ["ImgS", "imageSize"] {
|
||||
@@ -95,6 +96,7 @@ fn imported_style_scaling_survives_saved_bytes_and_playback() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Saving native calls writes their effective default instead of changing style scaling.
|
||||
#[test]
|
||||
fn native_default_is_written_explicitly_and_keeps_its_behavior() {
|
||||
for option in [None, Some(json!(false)), Some(json!(true)), Some(Value::Null), Some(json!(1)), Some(json!("false"))] {
|
||||
@@ -121,6 +123,7 @@ fn native_default_is_written_explicitly_and_keeps_its_behavior() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Unsupported flags and empty steps remain complete descriptors instead of becoming resizes.
|
||||
#[test]
|
||||
fn malformed_or_empty_steps_are_kept_without_becoming_resizes() {
|
||||
for event in ["ImgS", "imageSize"] {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
use photocraft_engine::Session;
|
||||
use photocraft_ui_egui::{PhotocraftApp, Services};
|
||||
use serde_json::json;
|
||||
|
||||
/// A normal paste must not make an unchanged external SVG replace a newer internal copy.
|
||||
#[test]
|
||||
fn normal_paste_preserves_newer_internal_copy_for_later_paste_as() {
|
||||
const SVG: &[u8] = br##"<svg xmlns="http://www.w3.org/2000/svg" width="2" height="2"><rect width="2" height="2" fill="#ff0000"/></svg>"##;
|
||||
let services =
|
||||
Services { clipboard_get_svg: Some(Box::new(|| Ok(Some(SVG.to_vec())))), clipboard_get_image: Some(Box::new(|| Ok(None))), ..Default::default() };
|
||||
let mut app = PhotocraftApp::new(Session::new(), services);
|
||||
app.run("file.new", json!({"width": 8, "height": 6})).unwrap();
|
||||
app.run("edit.paste", json!({"as": "pixels"})).unwrap();
|
||||
app.session.edit_prefs(|prefs| prefs.general.export_clipboard = false);
|
||||
app.run("file.new", json!({"width": 8, "height": 6})).unwrap();
|
||||
app.run("edit.fill", json!({"color": "#0000ff"})).unwrap();
|
||||
app.run("edit.copy", json!({})).unwrap();
|
||||
app.run("edit.paste", json!({})).unwrap();
|
||||
app.run("edit.paste", json!({"as": "pixels"})).unwrap();
|
||||
assert_eq!(app.run("document.pixel", json!({"x": 4, "y": 3})).unwrap(), json!([0.0, 0.0, 1.0, 1.0]));
|
||||
}
|
||||
@@ -9,6 +9,7 @@ mod camera_raw_scope;
|
||||
mod camera_raw_zoom;
|
||||
mod canvas_16f;
|
||||
mod checker_canvas;
|
||||
mod clipboard_svg;
|
||||
mod color_managed_canvas;
|
||||
mod crop_beyond_canvas;
|
||||
mod crop_default_mode;
|
||||
|
||||
Reference in new issue
Block a user