twonly-app-dependencies/camera_avfoundation/darwin/Tests/Mocks/MockAssetWriter.swift
2026-10-07 22:18:23 +02:00

33 lines
885 B
Swift

// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import AVFoundation
@testable import camera_avfoundation
/// Mock implementation of `AssetWriter` protocol which allows injecting a custom
/// implementation.
final class MockAssetWriter: NSObject, AssetWriter {
var statusStub: (() -> AVAssetWriter.Status)?
var startWritingStub: (() -> Bool)?
var finishWritingStub: ((() -> Void) -> Void)?
var status: AVAssetWriter.Status {
return statusStub?() ?? .unknown
}
var error: Error? = nil
func startWriting() -> Bool {
return startWritingStub?() ?? true
}
func finishWriting(completionHandler handler: @escaping () -> Void) {
finishWritingStub?(handler)
}
func startSession(atSourceTime startTime: CMTime) {}
func add(_ input: AVAssetWriterInput) {}
}