Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis committed Dec 30, 2024
1 parent 6e57220 commit d24c5a9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion StreamVideoSwiftUITests/CallViewModel_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class CallViewModel_Tests: StreamVideoTestCase {
private lazy var eventNotificationCenter = streamVideo?.eventNotificationCenter
private lazy var callId: String! = UUID().uuidString
private lazy var participants: [Member]! = [firstUser, secondUser]
private lazy var peerConnectionFactory: PeerConnectionFactory! = .build(audioProcessingModule: MockAudioProcessingModule())
private lazy var peerConnectionFactory: PeerConnectionFactory! = .build(audioProcessingModule: MockAudioProcessingModule.shared)

private var cId: String { callCid(from: callId, callType: callType) }

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

final class StreamPictureInPictureTrackStateAdapterTests: XCTestCase, @unchecked Sendable {

private var factory: PeerConnectionFactory! = .build(audioProcessingModule: MockAudioProcessingModule())
private var factory: PeerConnectionFactory! = .build(audioProcessingModule: MockAudioProcessingModule.shared)
private var adapter: StreamPictureInPictureTrackStateAdapter! = .init()

private lazy var trackA: RTCVideoTrack! = factory.makeVideoTrack(source: factory.makeVideoSource(forScreenShare: false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ final class MockRTCPeerConnectionCoordinator:
screenShareSessionProvider: ScreenShareSessionProvider = .init()
) throws {
let peerConnectionFactory = PeerConnectionFactory.build(
audioProcessingModule: MockAudioProcessingModule()
audioProcessingModule: MockAudioProcessingModule.shared
)
self.init(
sessionId: .unique,
Expand Down
2 changes: 1 addition & 1 deletion StreamVideoTests/Mock/PeerConnectionFactory+Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ private var _pc: RTCPeerConnection?

extension PeerConnectionFactory {
static func mock(
_ audioProcessingModule: AudioProcessingModule = MockAudioProcessingModule()
_ audioProcessingModule: AudioProcessingModule = MockAudioProcessingModule.shared
) -> PeerConnectionFactory {
.build(
audioProcessingModule: audioProcessingModule
Expand Down
4 changes: 3 additions & 1 deletion StreamVideoTests/Mock/VideoConfig+Dummy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import StreamWebRTC

extension VideoConfig {
static func dummy(
audioProcessingModule: AudioProcessingModule = MockAudioProcessingModule()
audioProcessingModule: AudioProcessingModule = MockAudioProcessingModule.shared
) -> VideoConfig {
.init(audioProcessingModule: audioProcessingModule)
}
}

final class MockAudioProcessingModule: NSObject, AudioProcessingModule {
static let shared = MockAudioProcessingModule()
override private init() {}
var activeAudioFilter: AudioFilter? { nil }
func setAudioFilter(_ filter: AudioFilter?) {}
func apply(_ config: RTCAudioProcessingConfig) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ final class LocalAudioMediaAdapter_Tests: XCTestCase, @unchecked Sendable {
)

try await subject.didUpdateCallSettings(.init(audioOn: true))
await fulfillment { self.mockSFUStack.service.updateMuteStatesWasCalledWithRequest != nil }

let request = try XCTUnwrap(mockSFUStack.service.updateMuteStatesWasCalledWithRequest)
XCTAssertEqual(request.sessionID, sessionId)
Expand All @@ -144,6 +145,7 @@ final class LocalAudioMediaAdapter_Tests: XCTestCase, @unchecked Sendable {
subject.primaryTrack.isEnabled = true

try await subject.didUpdateCallSettings(.init(audioOn: false))
await fulfillment { self.mockSFUStack.service.updateMuteStatesWasCalledWithRequest != nil }

let request = try XCTUnwrap(mockSFUStack.service.updateMuteStatesWasCalledWithRequest)
XCTAssertEqual(request.sessionID, sessionId)
Expand Down

0 comments on commit d24c5a9

Please sign in to comment.