From d24c5a9c03cb3ecbbd83e068d45660ef50ff0f55 Mon Sep 17 00:00:00 2001 From: Ilias Pavlidakis Date: Mon, 30 Dec 2024 18:23:21 +0200 Subject: [PATCH] Fix tests --- StreamVideoSwiftUITests/CallViewModel_Tests.swift | 2 +- .../StreamPictureInPictureTrackStateAdapterTests.swift | 2 +- StreamVideoTests/Mock/MockRTCPeerConnectionCoordinator.swift | 2 +- StreamVideoTests/Mock/PeerConnectionFactory+Mock.swift | 2 +- StreamVideoTests/Mock/VideoConfig+Dummy.swift | 4 +++- .../LocalMediaAdapters/LocalAudioMediaAdapter_Tests.swift | 2 ++ 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/StreamVideoSwiftUITests/CallViewModel_Tests.swift b/StreamVideoSwiftUITests/CallViewModel_Tests.swift index 59d204631..24d2d0cd5 100644 --- a/StreamVideoSwiftUITests/CallViewModel_Tests.swift +++ b/StreamVideoSwiftUITests/CallViewModel_Tests.swift @@ -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) } diff --git a/StreamVideoSwiftUITests/Utils/PictureInPicture/StreamPictureInPictureTrackStateAdapterTests.swift b/StreamVideoSwiftUITests/Utils/PictureInPicture/StreamPictureInPictureTrackStateAdapterTests.swift index e02abfe32..0fda19a33 100644 --- a/StreamVideoSwiftUITests/Utils/PictureInPicture/StreamPictureInPictureTrackStateAdapterTests.swift +++ b/StreamVideoSwiftUITests/Utils/PictureInPicture/StreamPictureInPictureTrackStateAdapterTests.swift @@ -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)) diff --git a/StreamVideoTests/Mock/MockRTCPeerConnectionCoordinator.swift b/StreamVideoTests/Mock/MockRTCPeerConnectionCoordinator.swift index fbc194134..60285e649 100644 --- a/StreamVideoTests/Mock/MockRTCPeerConnectionCoordinator.swift +++ b/StreamVideoTests/Mock/MockRTCPeerConnectionCoordinator.swift @@ -144,7 +144,7 @@ final class MockRTCPeerConnectionCoordinator: screenShareSessionProvider: ScreenShareSessionProvider = .init() ) throws { let peerConnectionFactory = PeerConnectionFactory.build( - audioProcessingModule: MockAudioProcessingModule() + audioProcessingModule: MockAudioProcessingModule.shared ) self.init( sessionId: .unique, diff --git a/StreamVideoTests/Mock/PeerConnectionFactory+Mock.swift b/StreamVideoTests/Mock/PeerConnectionFactory+Mock.swift index 3fba9ed53..b549ce6c2 100644 --- a/StreamVideoTests/Mock/PeerConnectionFactory+Mock.swift +++ b/StreamVideoTests/Mock/PeerConnectionFactory+Mock.swift @@ -9,7 +9,7 @@ private var _pc: RTCPeerConnection? extension PeerConnectionFactory { static func mock( - _ audioProcessingModule: AudioProcessingModule = MockAudioProcessingModule() + _ audioProcessingModule: AudioProcessingModule = MockAudioProcessingModule.shared ) -> PeerConnectionFactory { .build( audioProcessingModule: audioProcessingModule diff --git a/StreamVideoTests/Mock/VideoConfig+Dummy.swift b/StreamVideoTests/Mock/VideoConfig+Dummy.swift index 0e433587f..b5eeacdcb 100644 --- a/StreamVideoTests/Mock/VideoConfig+Dummy.swift +++ b/StreamVideoTests/Mock/VideoConfig+Dummy.swift @@ -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) {} diff --git a/StreamVideoTests/WebRTC/v2/PeerConnection/MediaAdapters/LocalMediaAdapters/LocalAudioMediaAdapter_Tests.swift b/StreamVideoTests/WebRTC/v2/PeerConnection/MediaAdapters/LocalMediaAdapters/LocalAudioMediaAdapter_Tests.swift index bacd2c718..6c04e9558 100644 --- a/StreamVideoTests/WebRTC/v2/PeerConnection/MediaAdapters/LocalMediaAdapters/LocalAudioMediaAdapter_Tests.swift +++ b/StreamVideoTests/WebRTC/v2/PeerConnection/MediaAdapters/LocalMediaAdapters/LocalAudioMediaAdapter_Tests.swift @@ -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) @@ -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)