Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
clean-up
  • Loading branch information
andrewjl-mux committed Sep 12, 2024
1 parent 24d4b76 commit b1f1693
Show file tree
Hide file tree
Showing 3 changed files with 307 additions and 226 deletions.
49 changes: 49 additions & 0 deletions Tests/MuxPlayerSwift/Helpers/TestMonitor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// TestMonitor.swift
//

import AVKit
import Foundation
import XCTest

@testable import MuxPlayerSwift

class TestMonitor: Monitor {
var monitoringRegistrations: [(MonitoringOptions, Bool)] = []

override func setupMonitoring(
playerViewController: AVPlayerViewController,
playbackID: String,
options: MonitoringOptions,
usingDRM: Bool = false
) {
super.setupMonitoring(
playerViewController: playerViewController,
playbackID: playbackID,
options: options,
usingDRM: usingDRM
)

monitoringRegistrations.append(
(options, usingDRM)
)
}

override func setupMonitoring(
playerLayer: AVPlayerLayer,
playbackID: String,
options: MonitoringOptions,
usingDRM: Bool = false
) {
super.setupMonitoring(
playerLayer: playerLayer,
playbackID: playbackID,
options: options,
usingDRM: usingDRM
)

monitoringRegistrations.append(
(options, usingDRM)
)
}
}
78 changes: 78 additions & 0 deletions Tests/MuxPlayerSwift/Helpers/TestPlayerObservationContext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// TestPlayerObservationContext.swift
//

import Foundation

import MUXSDKStats

@testable import MuxPlayerSwift

class TestPlayerObservationContext: PlayerObservationContext {

struct MonitorCall {
// AVPlayerViewController or AVPlayerLayer or AVPlayer
// Only included to validate pointer equality, for
// which NSObject suffices
let player: NSObject
let playerName: String
let customerData: MUXSDKCustomerData
let automaticErrorTracking: Bool
}

var monitorCalls: [MonitorCall] = []

override func monitorAVPlayerViewController(
_ player: AVPlayerViewController,
withPlayerName name: String,
customerData: MUXSDKCustomerData,
automaticErrorTracking: Bool
) -> MUXSDKPlayerBinding? {

monitorCalls.append(
MonitorCall(
player: player,
playerName: name,
customerData: customerData,
automaticErrorTracking: automaticErrorTracking
)
)

// In its current state this test class is only
// useful for validating Mux Data inputs.
//
// This needs to return a non-nil value in order to
// validate side effects in this SDK.
return nil
}

override func monitorAVPlayerLayer(
_ player: AVPlayerLayer,
withPlayerName name: String,
customerData: MUXSDKCustomerData,
automaticErrorTracking: Bool
) -> MUXSDKPlayerBinding? {

monitorCalls.append(
MonitorCall(
player: player,
playerName: name,
customerData: customerData,
automaticErrorTracking: automaticErrorTracking
)
)

// In its current state this test class is only
// useful for validating Mux Data inputs.
//
// This needs to return a non-nil value in order to
// validate side effects in this SDK.
return nil
}

override func destroyPlayer(
_ name: String
) {

}
}
Loading

0 comments on commit b1f1693

Please sign in to comment.