// 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 Flutter

@testable import camera_avfoundation

/// A mock implementation of `CameraGlobalEventApi` that captures received
/// `deviceOrientationChanged` events and exposes whether they were received to the testing code.
final class MockGlobalEventApi: CameraGlobalEventApiProtocol {
  /// Whether the `deviceOrientationChanged` callback was called.
  var deviceOrientationChangedCalled = false

  /// The last orientation received by the `deviceOrientationChanged` callback.
  var lastOrientation = PlatformDeviceOrientation.portraitUp

  func deviceOrientationChanged(
    orientation orientationArg: PlatformDeviceOrientation,
    completion: @escaping (Result<Void, PigeonError>) -> Void
  ) {
    deviceOrientationChangedCalled = true
    lastOrientation = orientationArg
    completion(.success(()))
  }
}
