Skip to content

[camera_avfoundation] Implementation swift migration #8988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/camera/camera_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.18+14

* Creates Swift Package Manager target for Swift implementation.

## 0.9.18+13

* Migrates test utils and mocks to Swift.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class AvailableCamerasTest: XCTestCase {
private func createCameraPlugin(with deviceDiscoverer: MockCameraDeviceDiscoverer) -> CameraPlugin
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class CameraCaptureSessionQueueRaceConditionTests: XCTestCase {
private func createCameraPlugin() -> CameraPlugin {
return CameraPlugin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class CameraMethodChannelTests: XCTestCase {
private func createCameraPlugin(with session: MockCaptureSession) -> CameraPlugin {
return CameraPlugin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

private final class MockUIDevice: UIDevice {
var mockOrientation: UIDeviceOrientation = .unknown

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

private final class MockPermissionService: NSObject, FLTPermissionServicing {
var authorizationStatusStub: ((AVMediaType) -> AVAuthorizationStatus)?
var requestAccessStub: ((AVMediaType, @escaping (Bool) -> Void) -> Void)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class CameraPluginCreateCameraTests: XCTestCase {
private func createCameraPlugin() -> (
CameraPlugin, MockFLTCameraPermissionManager, MockCaptureSession
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

/// Tests of `CameraPlugin` methods delegating to `FLTCam` instance
final class CameraPluginDelegatingMethodTests: XCTestCase {
private func createCameraPlugin() -> (CameraPlugin, MockFLTCam) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class CameraPluginInitializeCameraTests: XCTestCase {
private func createCameraPlugin() -> (
CameraPlugin, MockFLTCam, MockGlobalEventApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class CameraPreviewPauseTests: XCTestCase {
func testPausePreviewWithResult_shouldPausePreview() {
let camera = FLTCam()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class CameraPropertiesTests: XCTestCase {
// MARK: - Flash Mode Tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

/// Includes test cases related to resolution presets setting operations for FLTCam class.
final class CameraSessionPresetsTests: XCTestCase {
func testResolutionPresetWithBestFormat_mustUpdateCaptureSessionPreset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

private let testResolutionPreset = FCPPlatformResolutionPreset.medium
private let testFramesPerSecond = 15
private let testVideoBitrate = 200000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

import Foundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#else
import camera_avfoundation
#endif

/// Utils for creating default class instances used in tests
enum CameraTestUtils {
/// This method provides a convenient way to create media settings with minimal configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class FLTCamExposureTests: XCTestCase {
private func createCamera() -> (FLTCam, MockCaptureDevice, MockDeviceOrientationProvider) {
let mockDevice = MockCaptureDevice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class FLTCamSetFocusModeTests: XCTestCase {
private func createCamera() -> (FLTCam, MockCaptureDevice, MockDeviceOrientationProvider) {
let mockDevice = MockCaptureDevice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class FLTCamSetDeviceOrientationTests: XCTestCase {
private func createCamera() -> (FLTCam, MockCaptureConnection, MockCaptureConnection) {
let configuration = CameraTestUtils.createTestCameraConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class FLTCamSetFlashModeTests: XCTestCase {
private func createCamera() -> (FLTCam, MockCaptureDevice, MockCapturePhotoOutput) {
let mockDevice = MockCaptureDevice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import XCTest

@testable import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
@testable import camera_avfoundation_objc
#endif

final class FLTCamZoomTests: XCTestCase {
private func createCamera() -> (FLTCam, MockCaptureDevice) {
let mockDevice = MockCaptureDevice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTAssetWriter` protocol which allows injecting a custom
/// implementation.
final class MockAssetWriter: NSObject, FLTAssetWriter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTAssetWriterInput` protocol which allows injecting a custom
/// implementation.
final class MockAssetWriterInput: NSObject, FLTAssetWriterInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTAssetWriterInputPixelBufferAdaptor` protocol which allows injecting a custom
/// implementation.
final class MockAssetWriterInputPixelBufferAdaptor: NSObject, FLTAssetWriterInputPixelBufferAdaptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTCameraDeviceDiscovering` protocol which allows injecting a custom
/// implementation for session discovery.
final class MockCameraDeviceDiscoverer: NSObject, FLTCameraDeviceDiscovering {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// A mock implementation of `FLTCaptureConnection` that allows injecting a custom implementation.
final class MockCaptureConnection: NSObject, FLTCaptureConnection {
var setVideoOrientationStub: ((AVCaptureVideoOrientation) -> Void)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// A mock implementation of `FLTCaptureDevice` that allows mocking the class
/// properties.
class MockCaptureDevice: NSObject, FLTCaptureDevice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// A mock implementation of `FLTCaptureDeviceFormat` that allows mocking the class
/// properties.
final class MockCaptureDeviceFormat: NSObject, FLTCaptureDeviceFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

///// A mocked implementation of FLTCaptureDeviceInputFactory which allows injecting a custom
///// implementation.
final class MockCaptureDeviceInputFactory: NSObject, FLTCaptureDeviceInputFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// A mocked implementation of FLTCaptureInput which allows injecting a custom
/// implementation.
final class MockCaptureInput: NSObject, FLTCaptureInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import AVFoundation
import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTCapturePhotoOutput` protocol which allows injecting a custom
/// implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTCaptureSession` protocol which allows injecting a custom
/// implementation.
final class MockCaptureSession: NSObject, FLTCaptureSession {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import camera_avfoundation

// Import Objectice-C part of the implementation when SwiftPM is used.
#if canImport(camera_avfoundation_objc)
import camera_avfoundation_objc
#endif

/// Mock implementation of `FLTCaptureVideoDataOutput` protocol which allows injecting a custom
/// implementation.
class MockCaptureVideoDataOutput: NSObject, FLTCaptureVideoDataOutput {
Expand Down
Loading