From cc2f6971b599e8d2d7042414282a2b0fbdfe52bb Mon Sep 17 00:00:00 2001 From: Steffan Andrews Date: Wed, 22 Nov 2023 14:11:25 -0800 Subject: [PATCH] Added compound clips unit test (#7) --- .../CompoundClipTests.swift | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 Tests/MarkersExtractorTests/CompoundClipTests.swift diff --git a/Tests/MarkersExtractorTests/CompoundClipTests.swift b/Tests/MarkersExtractorTests/CompoundClipTests.swift new file mode 100644 index 0000000..40f439a --- /dev/null +++ b/Tests/MarkersExtractorTests/CompoundClipTests.swift @@ -0,0 +1,108 @@ +// +// CompoundClipTests.swift +// MarkersExtractor • https://github.com/TheAcharya/MarkersExtractor +// Licensed under MIT License +// + +import XCTest +@testable import MarkersExtractor +import TimecodeKit +import OTCore + +final class CompoundClipTests: XCTestCase { + /// Ensure that markers directly attached to compound clips (`ref-clip`s) on the main timeline + /// are preserved, while all markers within compound clips are discarded. + func testCompoundClips() throws { + var settings = try MarkersExtractor.Settings( + fcpxml: FCPXMLFile(fileContents: fcpxmlTestData), + outputDir: FileManager.default.temporaryDirectory + ) + settings.idNamingMode = .projectTimecode + + let extractor = MarkersExtractor(settings) + + // verify marker contents + + let markers = try extractor.extractMarkers() + + XCTAssertEqual(markers.count, 1) + + let fr: TimecodeFrameRate = .fps25 + + // just test basic marker info to identify the marker + let marker0 = try XCTUnwrap(markers[safe: 0]) + XCTAssertEqual(marker0.name, "Marker On Compound Clip in Main Timeline") + XCTAssertEqual(marker0.position, tc("01:00:04:00", at: fr)) + } +} + +private let fcpxmlTestData = fcpxmlTestString.data(using: .utf8)! +private let fcpxmlTestString = """ + + + + + + + + + + + <text> + <text-style ref="ts1">Title</text-style> + </text> + <text-style-def id="ts1"> + <text-style font="Helvetica" fontSize="63" fontFace="Regular" fontColor="1 1 1 1" alignment="center"/> + </text-style-def> + <marker start="3606s" duration="100/2500s" value="Marker On Title Clip Within Title Compound Clip"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"""