Style: format CAF action adapter and regressions

This commit is contained in:
yoriswind committed 2026-11-02 20:13:09 -08:00
1 parent 7e53861e62
commit a6ac7fee15
2 files changed
+25 -27

No files matched your search

@@ -12,15 +12,7 @@ const COLOR: &[(&str, &str)] = &[("cafColorAdaptationDefault", "default")];
const ROTATION: &[(&str, &str)] = &[("cafRotationAmountNone", "none")];
// Current Layer is also explicit in the primary Action Manager example cited in docs/atn.md.
const OUTPUT: &[(&str, &str)] = &[("cafOutputToNewLayer", "new"), ("cafOutputToCurrentLayer", "current")];
const KEYS: &[&str] = &[
"cafSamplingRegion",
"cafSampleAllLayers",
"cafColorAdaptationLevel",
"cafRotationAmount",
"cafScale",
"cafMirror",
"cafOutput",
];
const KEYS: &[&str] = &["cafSamplingRegion", "cafSampleAllLayers", "cafColorAdaptationLevel", "cafRotationAmount", "cafScale", "cafMirror", "cafOutput"];
const PARAMS: &[&str] = &["sampling", "sampleAllLayers", "colorAdaptation", "rotationAdaptation", "scale", "mirror", "output"];
/// All seven settings are recorded. Missing keys have no measured Photoshop default here.
@@ -29,12 +21,7 @@ fn recorded(d: &Descriptor) -> Option<Value> {
return None;
}
let mut p = Map::new();
for (key, param, table) in [
(KEYS[0], PARAMS[0], SAMPLING),
(KEYS[2], PARAMS[2], COLOR),
(KEYS[3], PARAMS[3], ROTATION),
(KEYS[6], PARAMS[6], OUTPUT),
] {
for (key, param, table) in [(KEYS[0], PARAMS[0], SAMPLING), (KEYS[2], PARAMS[2], COLOR), (KEYS[3], PARAMS[3], ROTATION), (KEYS[6], PARAMS[6], OUTPUT)] {
let D::Enumerated { type_id, value } = d.get(key)? else { return None };
if !type_id.is(key) {
return None;
@@ -166,11 +166,7 @@ fn caf_unrepresented_descriptors_are_kept_and_never_partially_play() {
/// Known native defaults become explicit values; unsupported defaults/options cannot disappear.
#[test]
fn caf_native_exports_preserve_effective_defaults_and_refuse_unrepresented_options() {
for p in [
json!({"sampling":"rectangular","output":"new"}),
json!({"sampling":"rectangular","output":"new","seed":1,"target":"pixels"}),
params(),
] {
for p in [json!({"sampling":"rectangular","output":"new"}), json!({"sampling":"rectangular","output":"new","seed":1,"target":"pixels"}), params()] {
let a = load(exported(p).unwrap().descriptor.unwrap());
assert_eq!(a.steps, vec![(CMD.into(), params())]);
}
@@ -181,14 +177,29 @@ fn caf_native_exports_preserve_effective_defaults_and_refuse_unrepresented_optio
assert_eq!(a.steps, vec![(CMD.into(), current.clone())]);
}
for (key, value) in [
("sampling", json!("auto")), ("sampling", json!("custom")), ("sampling", json!("unknown")),
("sampling", json!("auto")),
("sampling", json!("custom")),
("sampling", json!("unknown")),
("output", json!("duplicate")),
("colorAdaptation", json!("none")), ("colorAdaptation", json!("high")), ("colorAdaptation", json!("veryHigh")),
("rotationAdaptation", json!("low")), ("rotationAdaptation", json!("medium")),
("rotationAdaptation", json!("high")), ("rotationAdaptation", json!("full")),
("sampleAllLayers", json!(0)), ("scale", Value::Null), ("mirror", json!("true")), ("seed", json!(2)),
("layer", json!(1)), ("margin", json!(10)), ("area", json!([0,0,4,4])), ("channel", json!(0)),
("samplingStrokes", json!([])), ("fillEdits", json!([])), ("target", json!("mask")), ("_atnCafDescriptor", Value::Null),
("colorAdaptation", json!("none")),
("colorAdaptation", json!("high")),
("colorAdaptation", json!("veryHigh")),
("rotationAdaptation", json!("low")),
("rotationAdaptation", json!("medium")),
("rotationAdaptation", json!("high")),
("rotationAdaptation", json!("full")),
("sampleAllLayers", json!(0)),
("scale", Value::Null),
("mirror", json!("true")),
("seed", json!(2)),
("layer", json!(1)),
("margin", json!(10)),
("area", json!([0, 0, 4, 4])),
("channel", json!(0)),
("samplingStrokes", json!([])),
("fillEdits", json!([])),
("target", json!("mask")),
("_atnCafDescriptor", Value::Null),
] {
let mut p = params();
p[key] = value;