Skip to content

Commit

Permalink
Add/update tests IV
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis committed Dec 20, 2024
1 parent a5502a9 commit 503e96a
Show file tree
Hide file tree
Showing 4 changed files with 608 additions and 535 deletions.
6 changes: 6 additions & 0 deletions StreamVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@
40B48C4C2D14F721002C4EAB /* RTPMapVisitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B48C4B2D14F721002C4EAB /* RTPMapVisitorTests.swift */; };
40B48C4F2D14F77B002C4EAB /* SupportedPrefix_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B48C4E2D14F77B002C4EAB /* SupportedPrefix_Tests.swift */; };
40B48C512D14F7AE002C4EAB /* SDPParser_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B48C502D14F7AE002C4EAB /* SDPParser_Tests.swift */; };
40B48C572D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B48C562D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift */; };
40B48C582D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B48C562D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift */; };
40B499CA2AC1A5E100A53B60 /* OSLogDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B499C92AC1A5E100A53B60 /* OSLogDestination.swift */; };
40B499CC2AC1A90F00A53B60 /* DeeplinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40B499CB2AC1A90F00A53B60 /* DeeplinkTests.swift */; };
40B499CE2AC1AA0900A53B60 /* AppEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4030E59F2A9DF5BD003E8CBA /* AppEnvironment.swift */; };
Expand Down Expand Up @@ -1809,6 +1811,7 @@
40B48C4B2D14F721002C4EAB /* RTPMapVisitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RTPMapVisitorTests.swift; sourceTree = "<group>"; };
40B48C4E2D14F77B002C4EAB /* SupportedPrefix_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportedPrefix_Tests.swift; sourceTree = "<group>"; };
40B48C502D14F7AE002C4EAB /* SDPParser_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDPParser_Tests.swift; sourceTree = "<group>"; };
40B48C562D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Stream_Video_Sfu_Models_TrackInfo+Dummy.swift"; sourceTree = "<group>"; };
40B499C92AC1A5E100A53B60 /* OSLogDestination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLogDestination.swift; sourceTree = "<group>"; };
40B499CB2AC1A90F00A53B60 /* DeeplinkTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeeplinkTests.swift; sourceTree = "<group>"; };
40BBC4762C6227D5002AEF92 /* DemoTranscriptionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoTranscriptionButtonView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4333,6 +4336,7 @@
40F017432BBEEE6200E89FD1 /* Dummy */ = {
isa = PBXGroup;
children = (
40B48C562D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift */,
403CA9BD2CCA54A4001A88C2 /* Stream_Video_Sfu_Models_Codec+Dummy.swift */,
403CA9BA2CCA548D001A88C2 /* Stream_Video_Sfu_Event_VideoLayerSetting+Dummy.swift */,
40382F3E2C89C14300C2D00F /* RTCMediaStreamTrack+dummy.swift */,
Expand Down Expand Up @@ -7198,6 +7202,7 @@
40F017772BBEF43B00E89FD1 /* CallSessionParticipantLeftEvent+Dummy.swift in Sources */,
40B48C2A2D14CF3B002C4EAB /* MockRTCRtpCodecCapability.swift in Sources */,
842747FA29EEEC5A00E063AD /* EventLogger.swift in Sources */,
40B48C582D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift in Sources */,
40B48C282D14CDD5002C4EAB /* StreamVideoSfuModelsCodec_ConvenienceTests.swift in Sources */,
40E9B3B52BCD93F500ACF18F /* Credentials+Dummy.swift in Sources */,
8414080F29F2838F00FF2D7C /* RawJSON_Tests.swift in Sources */,
Expand Down Expand Up @@ -7544,6 +7549,7 @@
841FF5152A5E99B400809BBB /* CallEventsHandler_Tests.swift in Sources */,
82E3BA462A0BAE1E001AB93E /* VirtualTime.swift in Sources */,
40382F422C89CF9700C2D00F /* Stream_Video_Sfu_Models_ConnectionQuality+Convenience.swift in Sources */,
40B48C572D1588DB002C4EAB /* Stream_Video_Sfu_Models_TrackInfo+Dummy.swift in Sources */,
82FF40B72A17C6CD00B4D95E /* ReconnectionView_Tests.swift in Sources */,
829A1F6929FACCAF0072ED75 /* ParticipantsGridLayout_Tests.swift in Sources */,
829A1F6B29FACCC20072ED75 /* ParticipantsSpotlightLayout_Tests.swift in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions StreamVideoTests/Mock/MockRTCPeerConnectionCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class MockRTCPeerConnectionCoordinator:
case addVideoOutput
case removeVideoOutput
case zoom
case trackInfo
}

enum MockFunctionInputKey: Payloadable {
Expand All @@ -56,6 +57,7 @@ final class MockRTCPeerConnectionCoordinator:
case addVideoOutput(videoOutput: AVCaptureVideoDataOutput)
case removeVideoOutput(videoOutput: AVCaptureVideoDataOutput)
case zoom(factor: CGFloat)
case trackInfo(trackType: TrackType)

var payload: Any {
switch self {
Expand Down Expand Up @@ -95,6 +97,8 @@ final class MockRTCPeerConnectionCoordinator:
return videoOutput
case let .zoom(factor):
return factor
case let .trackInfo(trackType):
return trackType
}
}
}
Expand All @@ -117,6 +121,7 @@ final class MockRTCPeerConnectionCoordinator:

var stubbedMid: [TrackType: String] = [:]
var stubbedTrack: [TrackType: RTCMediaStreamTrack] = [:]
var stubbedTrackInfo: [TrackType: [Stream_Video_Sfu_Models_TrackInfo]] = [:]

override var disconnectedPublisher: AnyPublisher<Void, Never> {
if let stub = stubbedProperty[propertyKey(for: \.disconnectedPublisher)] as? AnyPublisher<Void, Never> {
Expand Down Expand Up @@ -275,4 +280,13 @@ final class MockRTCPeerConnectionCoordinator:
.zoom(factor: factor)
)
}

override func trackInfo(
for type: TrackType
) -> [Stream_Video_Sfu_Models_TrackInfo] {
stubbedFunctionInput[.trackInfo]?.append(
.trackInfo(trackType: type)
)
return stubbedTrackInfo[type] ?? []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

@testable import StreamVideo

extension Stream_Video_Sfu_Models_TrackInfo {
static func dummy(
trackID: String = .unique,
trackType: Stream_Video_Sfu_Models_TrackType,
layers: [Stream_Video_Sfu_Models_VideoLayer] = [],
mid: String
) -> Stream_Video_Sfu_Models_TrackInfo {
var result = Stream_Video_Sfu_Models_TrackInfo()
result.trackID = trackID
result.trackType = trackType
result.layers = layers
result.mid = mid
return result
}
}

extension Stream_Video_Sfu_Models_VideoLayer {
static func dummy(
rid: String = .unique,
videoDimension: Stream_Video_Sfu_Models_VideoDimension = .dummy(),
bitrate: UInt32 = 1000,
fps: UInt32 = 30,
quality: Stream_Video_Sfu_Models_VideoQuality = .high
) -> Stream_Video_Sfu_Models_VideoLayer {
var result = Stream_Video_Sfu_Models_VideoLayer()
result.rid = rid
result.videoDimension = videoDimension
result.bitrate = bitrate
result.fps = fps
result.quality = quality
return result
}
}

extension Stream_Video_Sfu_Models_VideoDimension {
static func dummy(
width: UInt32 = 1920,
height: UInt32 = 1080
) -> Stream_Video_Sfu_Models_VideoDimension {
var result = Stream_Video_Sfu_Models_VideoDimension()
result.width = width
result.height = height
return result
}
}

extension Stream_Video_Sfu_Models_VideoQuality {
static func dummy(
rawValue: Int = 2
) -> Stream_Video_Sfu_Models_VideoQuality {
Stream_Video_Sfu_Models_VideoQuality(rawValue: rawValue) ?? .high
}
}
Loading

0 comments on commit 503e96a

Please sign in to comment.