//! Integration tests against the real extracted Project Sylpheed disc. //! //! These are **skipped** (pass as no-ops) when the extracted disc is not present, //! so the suite still runs on machines/CI without the game. Point at the disc via //! the `SYLPHEED_DISC` env var, or drop it at the default dev path below. use std::path::{Path, PathBuf}; use sylpheed_formats::texture::X360Texture; use sylpheed_formats::{IdxdObject, PakArchive}; /// Locate the extracted disc root, or `None` to skip. fn disc_root() -> Option { if let Ok(p) = std::env::var("SYLPHEED_DISC") { let p = PathBuf::from(p); if p.join("dat").is_dir() { return Some(p); } } let default = Path::new( "/home/fabi/RE - Project Sylpheed/Project Sylpheed - Arc of Deception (USA, Europe) (En,Ja)", ); if default.join("dat").is_dir() { return Some(default.to_path_buf()); } None } macro_rules! skip_without_disc { ($root:ident) => { let Some($root) = disc_root() else { eprintln!("SKIP: extracted disc not found (set SYLPHEED_DISC to enable)"); return; }; }; } #[test] fn deftables_header_and_first_entry() { skip_without_disc!(root); let arc = PakArchive::open(root.join("hidden/DefTables.pak")).unwrap(); assert_eq!(arc.len(), 1465); assert_eq!(arc.block_size, 0x800); assert_eq!(arc.flags, 0x1000_0000); // TOC is sorted ascending by name_hash. assert!(arc .entries() .windows(2) .all(|w| w[0].name_hash < w[1].name_hash)); // First entries decompress to a known inner format (IDXD or XML). let first = &arc.entries()[0]; let payload = arc.read(first).unwrap(); assert!( payload.starts_with(b"IDXD") || payload.starts_with(b" 0); } /// The English movie subtitle track (an `IXUD` entry) decodes to timed cues. #[test] fn eng_movie_subtitle_track() { skip_without_disc!(root); let arc = PakArchive::open(root.join("dat/movie/eng.pak")).unwrap(); // S04A's track — the longest inline English one (starts "Calm down!"). let bytes = arc.read_by_hash(0x73d2_2a3b).expect("entry present").unwrap(); let sub = sylpheed_formats::ixud::parse(&bytes).expect("IXUD parses as subtitle"); assert!(sub.cues.len() > 50, "cues={}", sub.cues.len()); assert!(!sub.is_reference_only()); assert_eq!(sub.cues[0].text, "Calm down!"); assert!((sub.cues[0].start - 9.4).abs() < 0.01); assert_eq!(sub.cues[0].end, Some(11.0)); } /// The subtitle tracks are genuinely localized: the same entry hash differs /// between the English and German packs. #[test] fn subtitles_are_localized() { skip_without_disc!(root); let eng = PakArchive::open(root.join("dat/movie/eng.pak")).unwrap(); let deu = PakArchive::open(root.join("dat/movie/deu.pak")).unwrap(); let e = eng.read_by_hash(0x73d2_2a3b).unwrap().unwrap(); let d = deu.read_by_hash(0x73d2_2a3b).unwrap().unwrap(); assert_ne!(e, d, "eng/deu subtitle payloads should differ"); } /// The English movie pack's embedded subtitle font parses to sane metadata. #[test] fn eng_movie_font_metadata() { skip_without_disc!(root); let arc = PakArchive::open(root.join("dat/movie/eng.pak")).unwrap(); let bytes = arc.read_by_hash(0x5cd0_fca6).expect("entry present").unwrap(); assert!(sylpheed_formats::font::is_font(&bytes)); let info = sylpheed_formats::font::parse_info(&bytes).expect("font parses"); assert!(info.glyphs > 0, "glyphs={}", info.glyphs); assert!(!info.family.is_empty(), "family should be readable"); } /// The Acheron backdrop is a TXCM world cubemap: 6 faces, and the cube path's /// face 0 matches the (validated) 2D `from_xpr2` face-0 decode. #[test] fn acheron_world_cubemap_six_faces() { skip_without_disc!(root); let bytes = std::fs::read(root.join("hidden/resource3d/BG_Acheron.xpr")).unwrap(); let cube = X360Texture::cube_faces_from_xpr2(&bytes) .expect("cube decode ok") .expect("BG_Acheron is a TXCM cubemap"); assert_eq!((cube.width, cube.height), (1024, 1024)); assert_eq!(cube.faces.len(), 6); // A8R8G8B8 → 4 bytes/texel, de-tiled to width×height. for face in &cube.faces { assert_eq!(face.len(), 1024 * 1024 * 4); } // Face 0 must equal what the existing 2D path decodes (the green planet). let face0_2d = X360Texture::from_xpr2(&bytes).unwrap(); assert!(face0_2d.is_cubemap); assert_eq!(cube.faces[0], face0_2d.data); }