Skip to content

Commit

Permalink
And the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daytime-em committed May 7, 2024
1 parent 7eabea5 commit 093b70c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
14 changes: 11 additions & 3 deletions Tests/MuxPlayerSwift/FairPlay/ContentKeySessionDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ContentKeySessionDelegateTests : XCTestCase {

var testPlaybackOptionsRegistry: TestPlaybackOptionsRegistry!
var testCredentialClient: TestFairPlayStreamingSessionCredentialClient!
var testSessionmanager: TestFairPlayStreamingSessionManager!

// object under test
var contentKeySessionDelegate: ContentKeySessionDelegate<
Expand All @@ -28,11 +29,14 @@ class ContentKeySessionDelegateTests : XCTestCase {
failsWith: error
)
testPlaybackOptionsRegistry = TestPlaybackOptionsRegistry()

contentKeySessionDelegate = ContentKeySessionDelegate(
testSessionmanager = TestFairPlayStreamingSessionManager(
credentialClient: testCredentialClient,
optionsRegistry: testPlaybackOptionsRegistry
)

contentKeySessionDelegate = ContentKeySessionDelegate(
sessionManager: testSessionmanager
)
}

private func setUpForSuccess() {
Expand All @@ -42,10 +46,14 @@ class ContentKeySessionDelegateTests : XCTestCase {
)
testPlaybackOptionsRegistry = TestPlaybackOptionsRegistry()

contentKeySessionDelegate = ContentKeySessionDelegate(
testSessionmanager = TestFairPlayStreamingSessionManager(
credentialClient: testCredentialClient,
optionsRegistry: testPlaybackOptionsRegistry
)

contentKeySessionDelegate = ContentKeySessionDelegate(
sessionManager: testSessionmanager
)
}

private func makeFakeSkdUrl(fakePlaybackID: String) -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@ import Foundation
import AVFoundation
@testable import MuxPlayerSwift

// TODO: Still needed?
class TestFairPlayStreamingSessionManager : FairPlayStreamingSessionManager {
class TestFairPlayStreamingSessionManager : FairPlayStreamingSessionCredentialClient & PlaybackOptionsRegistry {

let credentialClient: FairPlayStreamingSessionCredentialClient
let optionsRegistry: PlaybackOptionsRegistry
let contentKeyRegistry: ContentKeyRecipientRegistry

func addContentKeyRecipient(_ recipient: any AVContentKeyRecipient) {
contentKeyRegistry.addContentKeyRecipient(recipient)
}

func removeContentKeyRecipient(_ recipient: any AVContentKeyRecipient) {
contentKeyRegistry.removeContentKeyRecipient(recipient)
}

func requestCertificate(fromDomain rootDomain: String, playbackID: String, drmToken: String, completion requestCompletion: @escaping (Result<Data, any Error>) -> Void) {
credentialClient.requestCertificate(fromDomain: rootDomain, playbackID: playbackID, drmToken: drmToken, completion: requestCompletion)
Expand All @@ -45,10 +35,8 @@ class TestFairPlayStreamingSessionManager : FairPlayStreamingSessionManager {
}

init(credentialClient: any FairPlayStreamingSessionCredentialClient,
optionsRegistry: any PlaybackOptionsRegistry,
contentKeyRegistry: any ContentKeyRecipientRegistry) {
optionsRegistry: any PlaybackOptionsRegistry) {
self.credentialClient = credentialClient
self.optionsRegistry = optionsRegistry
self.contentKeyRegistry = contentKeyRegistry
}
}

0 comments on commit 093b70c

Please sign in to comment.