Skip to content

Commit

Permalink
updated for v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
reuelk committed Mar 14, 2017
1 parent 2f355a2 commit a077858
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
build/
4 changes: 0 additions & 4 deletions Pipeline.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
05AF39671E1A3B9500319908 /* PCBang_FromGrace_20160202.fcpxml in Resources */ = {isa = PBXBuildFile; fileRef = 05AF39561E1A3A4800319908 /* PCBang_FromGrace_20160202.fcpxml */; };
05EF6D791E2E157B00EADB23 /* JFK_Moon_Demo_START.fcpxml in Resources */ = {isa = PBXBuildFile; fileRef = 05EF6D781E2E157B00EADB23 /* JFK_Moon_Demo_START.fcpxml */; };
7676560F1E36BADA0003D9E7 /* DTDs in Resources */ = {isa = PBXBuildFile; fileRef = 7676560E1E36BADA0003D9E7 /* DTDs */; };
76B365041E4C0D140091FB77 /* FCPXMLElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76B365031E4C0D140091FB77 /* FCPXMLElement.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -54,7 +53,6 @@
05C3D79A1CF272B800DEE915 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
05EF6D781E2E157B00EADB23 /* JFK_Moon_Demo_START.fcpxml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = JFK_Moon_Demo_START.fcpxml; sourceTree = "<group>"; };
7676560E1E36BADA0003D9E7 /* DTDs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = DTDs; sourceTree = "<group>"; };
76B365031E4C0D140091FB77 /* FCPXMLElement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FCPXMLElement.swift; path = Pipeline/Classes/FCPXMLElement.swift; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -82,7 +80,6 @@
isa = PBXGroup;
children = (
0515A0FC1E2AF84F00E7DEA9 /* AttributeParser.swift */,
76B365031E4C0D140091FB77 /* FCPXMLElement.swift */,
0515A0FF1E2AF84F00E7DEA9 /* FCPXMLElementType.swift */,
0515A1031E2AF84F00E7DEA9 /* FCPXMLUtility.swift */,
);
Expand Down Expand Up @@ -266,7 +263,6 @@
0515A1091E2AF84F00E7DEA9 /* CMTimeExtension.swift in Sources */,
0515A10F1E2AF84F00E7DEA9 /* FCPXMLUtility.swift in Sources */,
0515A1081E2AF84F00E7DEA9 /* AttributeParser.swift in Sources */,
76B365041E4C0D140091FB77 /* FCPXMLElement.swift in Sources */,
0531AB6B1E2B6BD8006F191F /* XMLDocumentExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
2 changes: 1 addition & 1 deletion Pipeline/Other/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.5</string>
<string>0.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
123 changes: 92 additions & 31 deletions PipelineTests/PipelineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import XCTest
import CoreMedia
@testable import Pipeline

class PipelineTests: XCTestCase {
Expand All @@ -18,7 +19,7 @@ class PipelineTests: XCTestCase {
// Put setup code here. This method is called before the invocation of each test method in the class.

let testBundle = Bundle(for: type(of: self))
guard let resourceURL = testBundle.url(forResource: "JFK_Moon_Demo_START", withExtension: "fcpxml") else {
guard let resourceURL = testBundle.url(forResource: "PCBang_FromGrace_20160202", withExtension: "fcpxml") else {
// file does not exist
print("file doesn't exist")
return
Expand All @@ -33,7 +34,7 @@ class PipelineTests: XCTestCase {
}

do {
try xmlDoc = XMLDocument(contentsOfFCPXML: resourceURL)
xmlDoc = try XMLDocument(contentsOfFCPXML: resourceURL)
print("File loaded.")
} catch {
print("Error loading XML data.")
Expand All @@ -48,6 +49,19 @@ class PipelineTests: XCTestCase {
super.tearDown()
}

func testNewDoc() {
let zero = CMTime(value: 0, timescale: 2400)
let compound = XMLElement().fcpxCompoundClip(name: "compound", ref: "r1", offset: zero, duration: CMTime(value: 60, timescale: 2400) , start: zero, useAudioSubroles: false)
let project = XMLElement().fcpxProject(name: "new project", formatRef: "r2", duration: zero, tcStart: zero, tcFormat: .nonDropFrame, audioLayout: .stereo, audioRate: .rate48kHz, renderColorSpace: .rec709, clips: [compound])
let event = XMLElement().fcpxEvent(name: "My event", items: [project])



let doc = XMLDocument(resources: [compound], events: [event], fcpxmlVersion: 1.6)

print(doc.fcpxmlString)
}

func testEventItemsForAsset() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
Expand All @@ -72,20 +86,22 @@ class PipelineTests: XCTestCase {
print("Roles: \(testDoc.fcpxRoles.count)")

print("Searching for resource: \(testDoc.fcpxResources[4])")
let matchingEventClips = testDoc.fcpxEvents[0].eventClips(containingAsset: testDoc.fcpxResources[2])

guard let matchingClips = matchingEventClips else {
let matchingEventClips: [XMLElement]
do {
matchingEventClips = try testDoc.fcpxEvents[0].eventClips(containingResource: testDoc.fcpxResources[2])
} catch {
print("Element is not an event.")
XCTFail()
XCTAssert(false)
return
}

print("matchingEventClips: \(matchingEventClips)")

print("matchingClips: \(matchingClips)")

if matchingClips.count > 0 {
for clip in matchingClips {
print("MATCHING CLIP: \(clip.element.fcpxName!)")
print(clip.element)
if matchingEventClips.count > 0 {
for clip in matchingEventClips {
print("MATCHING CLIP: \(clip.fcpxName!)")
print(clip)
}
}

Expand All @@ -99,7 +115,52 @@ class PipelineTests: XCTestCase {

print("--- End Results ---")

XCTAssert(matchingClips.count > 0)
XCTAssert(matchingEventClips.count > 0)

}

func testTimeValues() {
guard let testDoc = xmlDoc else {
XCTFail()
return
}

let eventItem = testDoc.fcpxEvents[0].eventItems![0]
print(eventItem.fcpxDuration)

print(eventItem.fcpxDuration!.timeAsCounter())

dump(testDoc.fcpxEventNames)

let newEvent = XMLElement().fcpxEvent(name: "My New Event")
testDoc.add(event: newEvent)

dump(testDoc.fcpxEventNames)

let firstEvent = testDoc.fcpxEvents[0]

guard let eventClips = firstEvent.eventClips else {
return
}

if eventClips.count > 0 {
let firstClip = eventClips[0]
let duration = firstClip.fcpxDuration
let timeDisplay = duration?.timeAsCounter().counterString
print(timeDisplay)
}

let matchingClips = try! firstEvent.eventClips(forResourceID: "r1")

try! firstEvent.removeFromEvent(items: matchingClips)

guard let resource = testDoc.resource(matchingID: "r1") else {
return
}
testDoc.remove(resourceAtIndex: resource.index)

dump(firstEvent.eventClips)
dump(testDoc.fcpxResources)

}

Expand All @@ -122,7 +183,7 @@ class PipelineTests: XCTestCase {


}

func testLastResourceIDs() {

guard let testDoc = xmlDoc else {
Expand All @@ -135,24 +196,24 @@ class PipelineTests: XCTestCase {

XCTAssert(testDoc.fcpxLastTextStyleID != 0)
}
func testMatchingClips() {

guard let testDoc = xmlDoc else {
XCTFail()
return
}

let clipResource = testDoc.fcpxResources[4]
print(clipResource.fcpxName!)

let matchingClips = testDoc.fcpxEvents[0].eventClips(containingAsset: clipResource)

print(matchingClips?.count)

XCTAssert((matchingClips?.count)! > 1)

}
//
// func testMatchingClips() {
//
// guard let testDoc = xmlDoc else {
// XCTFail()
// return
// }
//
// let clipResource = testDoc.fcpxResources[4]
// print(clipResource.fcpxName!)
//
// let matchingClips = testDoc.fcpxEvents[0].eventClips(containingAsset: clipResource)
//
// print(matchingClips?.count)
//
// XCTAssert((matchingClips?.count)! > 1)
//
// }

func testPerformanceExample() {
// This is an example of a performance test case.
Expand Down

0 comments on commit a077858

Please sign in to comment.