Skip to content

Commit 4a4d222

Browse files
committed
CompositionBuilder Test 1 Added
1 parent b5e17a7 commit 4a4d222

4 files changed

Lines changed: 176 additions & 2 deletions

File tree

VideoEditor.xcodeproj/project.pbxproj

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
F20FD5EB2F7D37180007E1F9 /* WaveformImageTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F20FD5E52F7D37180007E1F9 /* WaveformImageTypes.swift */; };
3030
F20FD5ED2F7D37180007E1F9 /* WaveformImageDrawer+iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = F20FD5E42F7D37180007E1F9 /* WaveformImageDrawer+iOS.swift */; };
3131
F20FD5EE2F7D37180007E1F9 /* TempiFFT.swift in Sources */ = {isa = PBXBuildFile; fileRef = F20FD5E12F7D37180007E1F9 /* TempiFFT.swift */; };
32+
F21B09822F91EEC400B83482 /* VideoEditorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21B09802F91EEC400B83482 /* VideoEditorTests.swift */; };
33+
F21B09832F91F2B400B83482 /* img1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F2A12A182F74776900FBF32C /* img1.jpg */; };
34+
F21B09842F91F2B400B83482 /* img2.png in Resources */ = {isa = PBXBuildFile; fileRef = F291A8842F77E7C000F5839A /* img2.png */; };
3235
F22B79AE2F91B46400DB4E8F /* ExportedVideoResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F22B79AD2F91B46400DB4E8F /* ExportedVideoResultViewController.swift */; };
3336
F25D1C192F73F5F900B82DC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F25D1C0E2F73F5F900B82DC2 /* Assets.xcassets */; };
3437
F25D1C1B2F73F5F900B82DC2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F25D1C112F73F5F900B82DC2 /* LaunchScreen.storyboard */; };
@@ -140,6 +143,16 @@
140143
F2TXTCV112FAA400100E04DD1 /* EditorCanvasTextOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2TXTCV122FAA400100E04DD1 /* EditorCanvasTextOverlayView.swift */; };
141144
/* End PBXBuildFile section */
142145

146+
/* Begin PBXContainerItemProxy section */
147+
F21B097B2F91EEB800B83482 /* PBXContainerItemProxy */ = {
148+
isa = PBXContainerItemProxy;
149+
containerPortal = F25D1BCE2F73F57E00B82DC2 /* Project object */;
150+
proxyType = 1;
151+
remoteGlobalIDString = F25D1BD52F73F57E00B82DC2;
152+
remoteInfo = VideoEditor;
153+
};
154+
/* End PBXContainerItemProxy section */
155+
143156
/* Begin PBXFileReference section */
144157
08178BF3D1C1171B215FED1C /* LocalThumbnailService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = LocalThumbnailService.swift; sourceTree = "<group>"; };
145158
56EF222A5456915C4E52BAAA /* RelativeDateFormatter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RelativeDateFormatter.swift; sourceTree = "<group>"; };
@@ -163,6 +176,8 @@
163176
F20FD5E32F7D37180007E1F9 /* WaveformImageDrawer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveformImageDrawer.swift; sourceTree = "<group>"; };
164177
F20FD5E42F7D37180007E1F9 /* WaveformImageDrawer+iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WaveformImageDrawer+iOS.swift"; sourceTree = "<group>"; };
165178
F20FD5E52F7D37180007E1F9 /* WaveformImageTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveformImageTypes.swift; sourceTree = "<group>"; };
179+
F21B09772F91EEB800B83482 /* VideoEditorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VideoEditorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
180+
F21B09802F91EEC400B83482 /* VideoEditorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoEditorTests.swift; sourceTree = "<group>"; };
166181
F22B79AD2F91B46400DB4E8F /* ExportedVideoResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportedVideoResultViewController.swift; sourceTree = "<group>"; };
167182
F25D1BD62F73F57E00B82DC2 /* VideoEditor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VideoEditor.app; sourceTree = BUILT_PRODUCTS_DIR; };
168183
F25D1C0D2F73F5F900B82DC2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -277,6 +292,13 @@
277292
/* End PBXFileReference section */
278293

279294
/* Begin PBXFrameworksBuildPhase section */
295+
F21B09742F91EEB800B83482 /* Frameworks */ = {
296+
isa = PBXFrameworksBuildPhase;
297+
buildActionMask = 2147483647;
298+
files = (
299+
);
300+
runOnlyForDeploymentPostprocessing = 0;
301+
};
280302
F25D1BD32F73F57E00B82DC2 /* Frameworks */ = {
281303
isa = PBXFrameworksBuildPhase;
282304
buildActionMask = 2147483647;
@@ -349,10 +371,19 @@
349371
path = EditorViewController;
350372
sourceTree = "<group>";
351373
};
374+
F21B09812F91EEC400B83482 /* VideoEditorTests */ = {
375+
isa = PBXGroup;
376+
children = (
377+
F21B09802F91EEC400B83482 /* VideoEditorTests.swift */,
378+
);
379+
path = VideoEditorTests;
380+
sourceTree = "<group>";
381+
};
352382
F25D1BCD2F73F57E00B82DC2 = {
353383
isa = PBXGroup;
354384
children = (
355385
F25D1C172F73F5F900B82DC2 /* VideoEditor */,
386+
F21B09812F91EEC400B83482 /* VideoEditorTests */,
356387
F25D1BD72F73F57E00B82DC2 /* Products */,
357388
);
358389
sourceTree = "<group>";
@@ -361,6 +392,7 @@
361392
isa = PBXGroup;
362393
children = (
363394
F25D1BD62F73F57E00B82DC2 /* VideoEditor.app */,
395+
F21B09772F91EEB800B83482 /* VideoEditorTests.xctest */,
364396
);
365397
name = Products;
366398
sourceTree = "<group>";
@@ -725,6 +757,26 @@
725757
/* End PBXGroup section */
726758

727759
/* Begin PBXNativeTarget section */
760+
F21B09762F91EEB800B83482 /* VideoEditorTests */ = {
761+
isa = PBXNativeTarget;
762+
buildConfigurationList = F21B097F2F91EEB800B83482 /* Build configuration list for PBXNativeTarget "VideoEditorTests" */;
763+
buildPhases = (
764+
F21B09732F91EEB800B83482 /* Sources */,
765+
F21B09742F91EEB800B83482 /* Frameworks */,
766+
F21B09752F91EEB800B83482 /* Resources */,
767+
);
768+
buildRules = (
769+
);
770+
dependencies = (
771+
F21B097C2F91EEB800B83482 /* PBXTargetDependency */,
772+
);
773+
name = VideoEditorTests;
774+
packageProductDependencies = (
775+
);
776+
productName = VideoEditorTests;
777+
productReference = F21B09772F91EEB800B83482 /* VideoEditorTests.xctest */;
778+
productType = "com.apple.product-type.bundle.unit-test";
779+
};
728780
F25D1BD52F73F57E00B82DC2 /* VideoEditor */ = {
729781
isa = PBXNativeTarget;
730782
buildConfigurationList = F25D1C022F73F58000B82DC2 /* Build configuration list for PBXNativeTarget "VideoEditor" */;
@@ -753,6 +805,10 @@
753805
LastUpgradeCheck = 2630;
754806
ORGANIZATIONNAME = "Coder ACJHP";
755807
TargetAttributes = {
808+
F21B09762F91EEB800B83482 = {
809+
CreatedOnToolsVersion = 26.3;
810+
TestTargetID = F25D1BD52F73F57E00B82DC2;
811+
};
756812
F25D1BD52F73F57E00B82DC2 = {
757813
CreatedOnToolsVersion = 26.3;
758814
};
@@ -773,11 +829,21 @@
773829
projectRoot = "";
774830
targets = (
775831
F25D1BD52F73F57E00B82DC2 /* VideoEditor */,
832+
F21B09762F91EEB800B83482 /* VideoEditorTests */,
776833
);
777834
};
778835
/* End PBXProject section */
779836

780837
/* Begin PBXResourcesBuildPhase section */
838+
F21B09752F91EEB800B83482 /* Resources */ = {
839+
isa = PBXResourcesBuildPhase;
840+
buildActionMask = 2147483647;
841+
files = (
842+
F21B09832F91F2B400B83482 /* img1.jpg in Resources */,
843+
F21B09842F91F2B400B83482 /* img2.png in Resources */,
844+
);
845+
runOnlyForDeploymentPostprocessing = 0;
846+
};
781847
F25D1BD42F73F57E00B82DC2 /* Resources */ = {
782848
isa = PBXResourcesBuildPhase;
783849
buildActionMask = 2147483647;
@@ -802,6 +868,14 @@
802868
/* End PBXResourcesBuildPhase section */
803869

804870
/* Begin PBXSourcesBuildPhase section */
871+
F21B09732F91EEB800B83482 /* Sources */ = {
872+
isa = PBXSourcesBuildPhase;
873+
buildActionMask = 2147483647;
874+
files = (
875+
F21B09822F91EEC400B83482 /* VideoEditorTests.swift in Sources */,
876+
);
877+
runOnlyForDeploymentPostprocessing = 0;
878+
};
805879
F25D1BD22F73F57E00B82DC2 /* Sources */ = {
806880
isa = PBXSourcesBuildPhase;
807881
buildActionMask = 2147483647;
@@ -928,6 +1002,14 @@
9281002
};
9291003
/* End PBXSourcesBuildPhase section */
9301004

1005+
/* Begin PBXTargetDependency section */
1006+
F21B097C2F91EEB800B83482 /* PBXTargetDependency */ = {
1007+
isa = PBXTargetDependency;
1008+
target = F25D1BD52F73F57E00B82DC2 /* VideoEditor */;
1009+
targetProxy = F21B097B2F91EEB800B83482 /* PBXContainerItemProxy */;
1010+
};
1011+
/* End PBXTargetDependency section */
1012+
9311013
/* Begin PBXVariantGroup section */
9321014
F25D1C112F73F5F900B82DC2 /* LaunchScreen.storyboard */ = {
9331015
isa = PBXVariantGroup;
@@ -940,6 +1022,48 @@
9401022
/* End PBXVariantGroup section */
9411023

9421024
/* Begin XCBuildConfiguration section */
1025+
F21B097D2F91EEB800B83482 /* Debug */ = {
1026+
isa = XCBuildConfiguration;
1027+
buildSettings = {
1028+
BUNDLE_LOADER = "$(TEST_HOST)";
1029+
CODE_SIGN_STYLE = Automatic;
1030+
CURRENT_PROJECT_VERSION = 1;
1031+
DEVELOPMENT_TEAM = N26XM7U465;
1032+
GENERATE_INFOPLIST_FILE = YES;
1033+
MARKETING_VERSION = 1.0;
1034+
PRODUCT_BUNDLE_IDENTIFIER = com.coder.test.VideoEditorTests;
1035+
PRODUCT_NAME = "$(TARGET_NAME)";
1036+
STRING_CATALOG_GENERATE_SYMBOLS = NO;
1037+
SWIFT_APPROACHABLE_CONCURRENCY = YES;
1038+
SWIFT_EMIT_LOC_STRINGS = NO;
1039+
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
1040+
SWIFT_VERSION = 5.0;
1041+
TARGETED_DEVICE_FAMILY = "1,2";
1042+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/VideoEditor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/VideoEditor";
1043+
};
1044+
name = Debug;
1045+
};
1046+
F21B097E2F91EEB800B83482 /* Release */ = {
1047+
isa = XCBuildConfiguration;
1048+
buildSettings = {
1049+
BUNDLE_LOADER = "$(TEST_HOST)";
1050+
CODE_SIGN_STYLE = Automatic;
1051+
CURRENT_PROJECT_VERSION = 1;
1052+
DEVELOPMENT_TEAM = N26XM7U465;
1053+
GENERATE_INFOPLIST_FILE = YES;
1054+
MARKETING_VERSION = 1.0;
1055+
PRODUCT_BUNDLE_IDENTIFIER = com.coder.test.VideoEditorTests;
1056+
PRODUCT_NAME = "$(TARGET_NAME)";
1057+
STRING_CATALOG_GENERATE_SYMBOLS = NO;
1058+
SWIFT_APPROACHABLE_CONCURRENCY = YES;
1059+
SWIFT_EMIT_LOC_STRINGS = NO;
1060+
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
1061+
SWIFT_VERSION = 5.0;
1062+
TARGETED_DEVICE_FAMILY = "1,2";
1063+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/VideoEditor.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/VideoEditor";
1064+
};
1065+
name = Release;
1066+
};
9431067
F25D1C032F73F58000B82DC2 /* Debug */ = {
9441068
isa = XCBuildConfiguration;
9451069
buildSettings = {
@@ -1134,6 +1258,15 @@
11341258
/* End XCBuildConfiguration section */
11351259

11361260
/* Begin XCConfigurationList section */
1261+
F21B097F2F91EEB800B83482 /* Build configuration list for PBXNativeTarget "VideoEditorTests" */ = {
1262+
isa = XCConfigurationList;
1263+
buildConfigurations = (
1264+
F21B097D2F91EEB800B83482 /* Debug */,
1265+
F21B097E2F91EEB800B83482 /* Release */,
1266+
);
1267+
defaultConfigurationIsVisible = 0;
1268+
defaultConfigurationName = Release;
1269+
};
11371270
F25D1BD12F73F57E00B82DC2 /* Build configuration list for PBXProject "VideoEditor" */ = {
11381271
isa = XCConfigurationList;
11391272
buildConfigurations = (

VideoEditor/Engine/PreviewVideoCompositionCore.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ final class PreviewCoreImageVideoCompositor: NSObject, AVVideoCompositing {
213213
request.finishCancelledRequest()
214214
return
215215
}
216+
216217
autoreleasepool {
217-
if let pb = self.newRenderedPixelBuffer(for: request) {
218-
request.finish(withComposedVideoFrame: pb)
218+
if let pixelBuffer = self.newRenderedPixelBuffer(for: request) {
219+
request.finish(withComposedVideoFrame: pixelBuffer)
219220
} else {
220221
request.finish(with: NSError(domain: "PreviewVideoCompositor", code: -1))
221222
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// VideoEditorTests.swift
3+
// VideoEditorTests
4+
//
5+
// Created by Coder ACJHP on 17.04.2026.
6+
// Copyright © 2026 Coder ACJHP. All rights reserved.
7+
//
8+
9+
import AVFoundation
10+
import XCTest
11+
@testable import VideoEditor
12+
13+
final class VideoEditorTests: XCTestCase {
14+
15+
private func bundledSampleImageURL() throws -> URL {
16+
let bundles = [Bundle(for: CompositionBuilder.self), Bundle.main]
17+
let url = bundles.lazy.compactMap { bundle in
18+
bundle.url(forResource: "img2", withExtension: "png")
19+
?? bundle.url(forResource: "img1", withExtension: "jpg")
20+
}.first
21+
return try XCTUnwrap(
22+
url,
23+
"Add img2.png or img1.jpg to the VideoEditor target’s Copy Bundle Resources."
24+
)
25+
}
26+
27+
@MainActor
28+
func testCompositionBuilderBuildsEmptyProject() async throws {
29+
let sut = CompositionBuilder()
30+
let project = EditingProject(name: "Test Empty")
31+
let result = try await sut.build(from: project, options: .previewDefault)
32+
33+
XCTAssertIdentical(result.playerItem.asset as AnyObject?, result.composition as AnyObject?)
34+
XCTAssertTrue(result.composition.tracks(withMediaType: .video).isEmpty)
35+
XCTAssertNil(result.playerItem.videoComposition)
36+
XCTAssertNil(result.audioMix)
37+
XCTAssertTrue(result.overlayLayers.isEmpty)
38+
XCTAssertEqual(result.composition.duration.seconds, 0, accuracy: 1e-6)
39+
}
40+
}

0 commit comments

Comments
 (0)