mirror of
https://github.com/samsonjs/SJSAssetExportSession.git
synced 2026-04-27 14:57:46 +00:00
Stop relying on a specific delay in cancellation test
This commit is contained in:
parent
10c717ab99
commit
2f1b859a03
1 changed files with 5 additions and 3 deletions
|
|
@ -296,11 +296,11 @@ final class ExportSessionTests: BaseTests {
|
||||||
@Test func test_export_cancellation() async throws {
|
@Test func test_export_cancellation() async throws {
|
||||||
let sourceURL = resourceURL(named: "test-720p-h264-24fps.mov")
|
let sourceURL = resourceURL(named: "test-720p-h264-24fps.mov")
|
||||||
let destinationURL💥 = makeTemporaryURL()
|
let destinationURL💥 = makeTemporaryURL()
|
||||||
|
let subject = ExportSession()
|
||||||
let task = Task {
|
let task = Task {
|
||||||
let sourceAsset = AVURLAsset(url: sourceURL, options: [
|
let sourceAsset = AVURLAsset(url: sourceURL, options: [
|
||||||
AVURLAssetPreferPreciseDurationAndTimingKey: true,
|
AVURLAssetPreferPreciseDurationAndTimingKey: true,
|
||||||
])
|
])
|
||||||
let subject = ExportSession()
|
|
||||||
try await subject.export(
|
try await subject.export(
|
||||||
asset: sourceAsset,
|
asset: sourceAsset,
|
||||||
video: .codec(.h264, width: 1280, height: 720),
|
video: .codec(.h264, width: 1280, height: 720),
|
||||||
|
|
@ -309,8 +309,10 @@ final class ExportSessionTests: BaseTests {
|
||||||
)
|
)
|
||||||
Issue.record("Task should be cancelled long before we get here")
|
Issue.record("Task should be cancelled long before we get here")
|
||||||
}
|
}
|
||||||
NSLog("Sleeping for 0.3s")
|
NSLog("Waiting for encoding to begin...")
|
||||||
try await Task.sleep(for: .milliseconds(300))
|
for await progress in subject.progressStream where progress > 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
NSLog("Cancelling task")
|
NSLog("Cancelling task")
|
||||||
task.cancel()
|
task.cancel()
|
||||||
try? await task.value // Wait for task to complete
|
try? await task.value // Wait for task to complete
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue