// apple/PhysarumApp/Tests/LivePhotoMetadataTests.swift
import XCTest
import AVFoundation
import Metal
@testable import Physarum
import PhysarumEngine
final class LivePhotoMetadataTests: XCTestCase {
func testLivePhotoMovHasContentIdentifierAndStillImageTimeTrack() async throws {
guard let device = MTLCreateSystemDefaultDevice() else { throw XCTSkip("No Metal device") }
let id = "TEST-\(UUID().uuidString)"
let url = FileManager.default.temporaryDirectory.appendingPathComponent("lp-test.mov")
let rec = VideoClipRecorder(device: device, url: url, width: 128, height: 128, fps: 30, codec: .hevc,
renderInto: { _ in },
livePhoto: VideoClipRecorder.LivePhoto(assetID: id, keyFrameIndex: 5))
_ = try await runClip(frameCount: 12, fps: 30, recorder: rec,
renderFrame: { _ in }, isCancelled: { false }, progress: { _ in })
let asset = AVURLAsset(url: url)
let meta = try await asset.load(.metadata)
let cid = meta.first { $0.key as? String == "com.apple.quicktime.content.identifier" }
XCTAssertNotNil(cid, "content.identifier missing")
let cidValue = try await cid?.load(.stringValue)
XCTAssertEqual(cidValue, id)
let metaTracks = try await asset.loadTracks(withMediaType: .metadata)
XCTAssertFalse(metaTracks.isEmpty, "still-image-time metadata track missing")
XCTAssertNotNil(rec.keyFrameImage, "key frame not captured")
try? FileManager.default.removeItem(at: url)
}
}