Skip to content

Commit

Permalink
even more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Sep 11, 2024
1 parent b9c68da commit dca39c8
Showing 1 changed file with 197 additions and 2 deletions.
199 changes: 197 additions & 2 deletions Tests/MuxPlayerSwift/MonitorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ class MonitorTests: XCTestCase {
)
}

func testPlayerMonitoringInputsPlayerViewControllerDRM() throws {
func testPlayerMonitoringInputs_PlayerViewController_DRM() throws {
let testPlayerObservationContext = TestPlayerObservationContext()
let testMonitor = Monitor(
playerObservationContext: testPlayerObservationContext
Expand All @@ -1070,13 +1070,159 @@ class MonitorTests: XCTestCase {
testPlayerObservationContext.monitorCalls.first
)

XCTAssertFalse(monitorCall.automaticErrorTracking)

XCTAssertEqual(
monitorCall.player,
playerViewController
)

let playerSoftwareName = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareName
)

XCTAssertEqual(
playerSoftwareName,
"MuxPlayerSwiftAVPlayerViewController"
)


let playerSoftwareVersion = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareVersion
)

XCTAssertEqual(
playerSoftwareVersion,
SemanticVersion.versionString
)

// Validate DRM flag

let viewDRMType = try XCTUnwrap(
monitorCall.customerData.customerViewData?.viewDrmType
)

XCTAssertEqual(
viewDRMType,
"fairplay"
)
}

func testPlayerMonitoringInputs_PlayerViewController_DRM_CustomEnvironmentKey() throws {
let testPlayerObservationContext = TestPlayerObservationContext()
let testMonitor = Monitor(
playerObservationContext: testPlayerObservationContext
)
PlayerSDK.shared.monitor = testMonitor

let playerViewController = AVPlayerViewController(
playbackID: "abc123",
playbackOptions: PlaybackOptions(
playbackToken: "def456",
drmToken: "ghi789"
)
)

let monitorCall = try XCTUnwrap(
testPlayerObservationContext.monitorCalls.first
)

XCTAssertFalse(monitorCall.automaticErrorTracking)

XCTAssertEqual(
monitorCall.player,
playerViewController
)

let playerSoftwareName = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareName
)

XCTAssertEqual(
playerSoftwareName,
"MuxPlayerSwiftAVPlayerViewController"
)


let playerSoftwareVersion = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareVersion
)

XCTAssertEqual(
playerSoftwareVersion,
SemanticVersion.versionString
)

// Validate DRM flag

let viewDRMType = try XCTUnwrap(
monitorCall.customerData.customerViewData?.viewDrmType
)

XCTAssertEqual(
viewDRMType,
"fairplay"
)
}

func testPlayerMonitoringInputs_PlayerLayer_DRM() throws {
let testPlayerObservationContext = TestPlayerObservationContext()
let testMonitor = Monitor(
playerObservationContext: testPlayerObservationContext
)
PlayerSDK.shared.monitor = testMonitor

let playerLayer = AVPlayerLayer(
playbackID: "abc123",
playbackOptions: PlaybackOptions(
playbackToken: "def456",
drmToken: "ghi789"
)
)

let monitorCall = try XCTUnwrap(
testPlayerObservationContext.monitorCalls.first
)

// Validate player reference
XCTAssertEqual(
monitorCall.player,
playerLayer
)

// Validate automatic error tracking
XCTAssertFalse(monitorCall.automaticErrorTracking)

// Validate customer data fields passed along to Mux Data

// Validate player software name and version
let playerSoftwareName = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareName
)
XCTAssertEqual(
playerSoftwareName,
"MuxPlayerSwiftAVPlayerLayer"
)

let playerSoftwareVersion = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareVersion
)
XCTAssertEqual(
playerSoftwareVersion,
SemanticVersion.versionString
)

// Validate DRM flag
let viewDRMType = try XCTUnwrap(
monitorCall.customerData.customerViewData?.viewDrmType
)
XCTAssertEqual(
viewDRMType,
"fairplay"
)
}

func testPlayerMonitoringInputsPlayerLayerDRM() throws {
func testPlayerMonitoringInputs_PlayerLayer_DRM_CustomEnvironmentKey() throws {
let testPlayerObservationContext = TestPlayerObservationContext()
let testMonitor = Monitor(
playerObservationContext: testPlayerObservationContext
Expand All @@ -1088,6 +1234,10 @@ class MonitorTests: XCTestCase {
playbackOptions: PlaybackOptions(
playbackToken: "def456",
drmToken: "ghi789"
),
monitoringOptions: MonitoringOptions(
environmentKey: "xyz321",
playerName: "test-player-name"
)
)

Expand All @@ -1099,6 +1249,51 @@ class MonitorTests: XCTestCase {
monitorCall.player,
playerLayer
)

XCTAssertEqual(
monitorCall.playerName,
"test-player-name"
)

XCTAssertFalse(monitorCall.automaticErrorTracking)

let environmentKey = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.environmentKey
)
XCTAssertEqual(
environmentKey,
"xyz321"
)

let playerSoftwareName = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareName
)

XCTAssertEqual(
playerSoftwareName,
"MuxPlayerSwiftAVPlayerLayer"
)


let playerSoftwareVersion = try XCTUnwrap(
monitorCall.customerData.customerPlayerData?.playerSoftwareVersion
)

XCTAssertEqual(
playerSoftwareVersion,
SemanticVersion.versionString
)

// Validate DRM flag

let viewDRMType = try XCTUnwrap(
monitorCall.customerData.customerViewData?.viewDrmType
)

XCTAssertEqual(
viewDRMType,
"fairplay"
)
}

// func testPlayerItemUpdates() throws {
Expand Down

0 comments on commit dca39c8

Please sign in to comment.