M3.7: proof setup looks profiles up through the alias table; alias tests read the legacy name from it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5d9b97c3bd
commit
7b410ecf2c
|
|
@ -40,7 +40,7 @@ const BUILTIN_CMYK: [&str; 2] = [GENERIC_CMYK, DEVICE_CMYK];
|
|||
|
||||
/// Names earlier versions gave built-in profiles: (old name, current name). Settings, documents
|
||||
/// and commands that still use an old name get the current profile.
|
||||
const LEGACY_NAMES: &[(&str, &str)] = &[("Adobe RGB (1998) compatible", WIDE_GAMUT_RGB)]; // brand-ok: legacy alias
|
||||
pub const LEGACY_NAMES: &[(&str, &str)] = &[("Adobe RGB (1998) compatible", WIDE_GAMUT_RGB)]; // brand-ok: legacy alias
|
||||
|
||||
/// ΔE2000 above which a colour counts as out of the CMYK gamut (the gamut warning).
|
||||
pub const GAMUT_THRESHOLD: f32 = 2.0;
|
||||
|
|
|
|||
|
|
@ -152,14 +152,14 @@ fn wide_gamut_working_space() {
|
|||
|
||||
#[test]
|
||||
fn legacy_profile_name_resolves() {
|
||||
const OLD: &str = "Adobe RGB (1998) compatible"; // brand-ok: legacy alias under test
|
||||
assert_eq!(canonical_name(OLD), WIDE_GAMUT_RGB);
|
||||
let (old, _) = LEGACY_NAMES[0];
|
||||
assert_eq!(canonical_name(old), WIDE_GAMUT_RGB);
|
||||
assert_eq!(canonical_name(SRGB), SRGB);
|
||||
assert_eq!(profile(OLD).map(|p| (p.name, p.kind, p.builtin)), Some((WIDE_GAMUT_RGB.to_string(), ProfileKind::Rgb, true)));
|
||||
assert_eq!(profile(old).map(|p| (p.name, p.kind, p.builtin)), Some((WIDE_GAMUT_RGB.to_string(), ProfileKind::Rgb, true)));
|
||||
assert!(profile("Nope").is_none());
|
||||
assert!(profiles().iter().all(|p| p.name != OLD), "only the current name is listed");
|
||||
assert!(profiles().iter().all(|p| p.name != old), "only the current name is listed");
|
||||
// Settings saved with the old name load as the current profile, under its current name.
|
||||
let c = Cms::new(&ColorSettings { rgb: OLD.into(), ..Default::default() }).unwrap();
|
||||
let c = Cms::new(&ColorSettings { rgb: old.into(), ..Default::default() }).unwrap();
|
||||
assert_eq!(c.settings().rgb, WIDE_GAMUT_RGB);
|
||||
let same = Cms::new(&ColorSettings { rgb: WIDE_GAMUT_RGB.into(), ..Default::default() }).unwrap();
|
||||
assert_eq!(c.rgb_to_srgb([0.0, 1.0, 0.0]), same.rgb_to_srgb([0.0, 1.0, 0.0]));
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ fn proof_setup(s: &mut Session, p: &Value) -> Result<Value> {
|
|||
if let Some(t) = str_param(p, "target") {
|
||||
let t = ProofTarget::parse(t).ok_or_else(|| bad(C, format!("unknown proof target `{t}`")))?;
|
||||
if let ProofTarget::Cmyk(name) = &t
|
||||
&& !cms::profiles().iter().any(|k| &k.name == name && k.kind == cms::ProfileKind::Cmyk)
|
||||
&& !cms::profile(name).is_some_and(|k| k.kind == cms::ProfileKind::Cmyk)
|
||||
{
|
||||
return Err(bad(C, format!("unknown CMYK profile `{name}`")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,6 +314,8 @@ fn view_toggles_redraw_without_dirtying() {
|
|||
assert_eq!(r["target"], "deuteranopia");
|
||||
assert_eq!(vectorcraft_render::proof::active_proof().unwrap().target, ProofTarget::Deuteranopia);
|
||||
assert!(s.execute("view.proofSetup", &json!({"target": "cmyk:Nope"})).is_err());
|
||||
assert!(s.execute("view.proofSetup", &json!({"target": format!("cmyk:{}", cms::WIDE_GAMUT_RGB)})).is_err(), "an RGB profile");
|
||||
s.execute("view.proofSetup", &json!({"target": format!("cmyk:{}", cms::DEVICE_CMYK)})).unwrap();
|
||||
s.execute("view.proofSetup", &json!({"target": "workingCmyk", "intent": "relative"})).unwrap();
|
||||
let r = s.execute("view.proofColors", &json!({"on": false})).unwrap();
|
||||
assert_eq!(r["proofColors"], false);
|
||||
|
|
@ -393,19 +395,19 @@ fn intents_reach_the_document_conversion() {
|
|||
#[test]
|
||||
fn legacy_profile_name_resolves_in_commands_and_files() {
|
||||
let _g = GLOBAL.lock().unwrap_or_else(|e| e.into_inner());
|
||||
const OLD: &str = "Adobe RGB (1998) compatible"; // brand-ok: legacy alias under test
|
||||
let (old, _) = cms::LEGACY_NAMES[0];
|
||||
let mut s = session();
|
||||
let before = cms::active_settings();
|
||||
let r = s.execute("edit.colorSettings", &json!({"rgb": OLD})).unwrap();
|
||||
let r = s.execute("edit.colorSettings", &json!({"rgb": old})).unwrap();
|
||||
assert_eq!(r["rgb"], cms::WIDE_GAMUT_RGB);
|
||||
assert_eq!(cms::active_settings().rgb, cms::WIDE_GAMUT_RGB);
|
||||
let names: Vec<&str> = r["profiles"].as_array().unwrap().iter().map(|p| p["name"].as_str().unwrap()).collect();
|
||||
assert!(names.contains(&cms::WIDE_GAMUT_RGB) && !names.contains(&OLD));
|
||||
let r = s.execute("edit.assignProfile", &json!({"rgb": OLD})).unwrap();
|
||||
assert!(names.contains(&cms::WIDE_GAMUT_RGB) && !names.contains(&old));
|
||||
let r = s.execute("edit.assignProfile", &json!({"rgb": old})).unwrap();
|
||||
assert_eq!(r["rgb"], cms::WIDE_GAMUT_RGB, "stored under the current name");
|
||||
// A document saved by an older version names the profile the old way.
|
||||
let mut d = (*s.doc().unwrap().doc).clone();
|
||||
d.unknown.insert(cmd::colormgmt::PROFILES_KEY.into(), json!({"rgb": OLD, "cmyk": null}));
|
||||
d.unknown.insert(cmd::colormgmt::PROFILES_KEY.into(), json!({"rgb": old, "cmyk": null}));
|
||||
let back = vectorcraft_format::load(&vectorcraft_format::save(&d, false)).unwrap();
|
||||
assert_eq!(cmd::colormgmt::doc_profiles(&back), (Some(cms::WIDE_GAMUT_RGB.to_string()), None));
|
||||
cms::set_active(&before).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue