forked from OpenTimelineIO/OpenTimelineIO-Swift-Bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestTimeline.swift
More file actions
82 lines (65 loc) · 2.71 KB
/
testTimeline.swift
File metadata and controls
82 lines (65 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// testTimeline.swift
//
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO project
import XCTest
@testable import OpenTimelineIO
import Foundation
final class testTimeline: XCTestCase {
override func setUpWithError() throws {
}
override func tearDownWithError() throws {
}
func testMetadataRead() {
let inputName = "data/timeline.otio"
let knownDictKey = "foo"
let knownKey = "some_key"
let knownValue = "some_value"
guard let timelineInputPath = Bundle.module.path(forResource: inputName, ofType: "") else {
XCTFail("Missing test data `\(inputName)`")
return
}
do {
let otio = try SerializableObject.fromJSON(filename: timelineInputPath)
guard let timeline = otio as? Timeline else {
XCTFail("Could not create Timeline object from \(timelineInputPath)")
return
}
let timelineMetadata = timeline.metadata
if let knownMetadata = timelineMetadata[knownDictKey] as? Metadata.Dictionary {
if let value = knownMetadata[knownKey] as? String {
XCTAssertTrue(value == knownValue)
} else {
XCTFail("Expects (\(knownKey), \(knownValue)), but found none in \(knownMetadata)")
}
} else {
XCTFail("Cannot read timeline metadata \(String(describing: timelineMetadata[knownDictKey])) as `Metadata.Dictionary`")
}
} catch let error {
XCTFail("Cannot read OTIO file `\(timelineInputPath)`: \(error)")
}
}
func testTimelineClipAvailableBounds() {
let inputName = "data/clip_example.otio"
guard let timelineInputPath = Bundle.module.path(forResource: inputName, ofType: "") else {
XCTFail("Missing test data `\(inputName)`")
return
}
do {
let otio = try SerializableObject.fromJSON(filename: timelineInputPath)
guard let timeline = otio as? Timeline else {
XCTFail("Could not create Timeline object from \(timelineInputPath)")
return
}
if let firstClip = timeline.videoTracks.first!.children[1] as? Clip,
let mediaReference = firstClip.mediaReference,
let availableBounds = mediaReference.availableImageBounds
{
XCTAssertEqual(availableBounds, CGRect(origin: .zero, size: CGSize(width: 16, height: 9)))
}
} catch let error {
XCTFail("Cannot read OTIO file `\(timelineInputPath)`: \(error)")
}
}
}