@@ -15,30 +15,61 @@ final class MockRTCAudioDeviceModule: RTCAudioDeviceModuleControlling, Mockable,
1515 typealias FunctionInputKey = MockFunctionInputKey
1616
1717 enum MockFunctionKey : Hashable , CaseIterable {
18- case initAndStartRecording
19- case stopRecording
2018 case setMicrophoneMuted
2119 case microphoneMutedPublisher
20+ case reset
21+ case initAndStartPlayout
22+ case startPlayout
23+ case stopPlayout
24+ case initAndStartRecording
25+ case startRecording
26+ case stopRecording
27+ case refreshStereoPlayoutState
2228 }
2329
2430 enum MockFunctionInputKey : Payloadable {
25- case initAndStartRecording
26- case stopRecording
2731 case setMicrophoneMuted( Bool )
2832 case microphoneMutedPublisher
33+ case reset
34+ case initAndStartPlayout
35+ case startPlayout
36+ case stopPlayout
37+ case initAndStartRecording
38+ case startRecording
39+ case stopRecording
40+ case refreshStereoPlayoutState
2941
3042 var payload : Any {
3143 switch self {
44+
45+ case . setMicrophoneMuted( let value) :
46+ return value
47+
48+ case . microphoneMutedPublisher:
49+ return ( )
50+
51+ case . reset:
52+ return ( )
53+
54+ case . initAndStartPlayout:
55+ return ( )
56+
57+ case . startPlayout:
58+ return ( )
59+
60+ case . stopPlayout:
61+ return ( )
62+
3263 case . initAndStartRecording:
3364 return ( )
3465
35- case . stopRecording :
66+ case . startRecording :
3667 return ( )
3768
38- case . setMicrophoneMuted ( let value ) :
39- return value
69+ case . stopRecording :
70+ return ( )
4071
41- case . microphoneMutedPublisher :
72+ case . refreshStereoPlayoutState :
4273 return ( )
4374 }
4475 }
@@ -59,6 +90,26 @@ final class MockRTCAudioDeviceModule: RTCAudioDeviceModuleControlling, Mockable,
5990
6091 init ( ) {
6192 stub ( for: \. isMicrophoneMuted, with: false )
93+ stub ( for: \. isPlaying, with: false )
94+ stub ( for: \. isRecording, with: false )
95+ stub ( for: \. isPlayoutInitialized, with: false )
96+ stub ( for: \. isRecordingInitialized, with: false )
97+ stub ( for: \. isMicrophoneMuted, with: false )
98+ stub ( for: \. isStereoPlayoutEnabled, with: false )
99+ stub ( for: \. isVoiceProcessingBypassed, with: false )
100+ stub ( for: \. isVoiceProcessingEnabled, with: false )
101+ stub ( for: \. isVoiceProcessingAGCEnabled, with: false )
102+ stub ( for: \. prefersStereoPlayout, with: false )
103+
104+ stub ( for: . initAndStartRecording, with: 0 )
105+ stub ( for: . setMicrophoneMuted, with: 0 )
106+ stub ( for: . stopRecording, with: 0 )
107+ stub ( for: . reset, with: 0 )
108+ stub ( for: . initAndStartPlayout, with: 0 )
109+ stub ( for: . startPlayout, with: 0 )
110+ stub ( for: . stopPlayout, with: 0 )
111+ stub ( for: . startRecording, with: 0 )
112+ stub ( for: . refreshStereoPlayoutState, with: 0 )
62113 }
63114
64115 // MARK: - RTCAudioDeviceModuleControlling
@@ -67,9 +118,46 @@ final class MockRTCAudioDeviceModule: RTCAudioDeviceModuleControlling, Mockable,
67118
68119 var observer : ( any RTCAudioDeviceModuleDelegate ) ?
69120
121+ var isPlaying : Bool {
122+ self [ dynamicMember: \. isPlaying]
123+ }
124+
125+ var isRecording : Bool {
126+ self [ dynamicMember: \. isRecording]
127+ }
128+
129+ var isPlayoutInitialized : Bool {
130+ self [ dynamicMember: \. isPlayoutInitialized]
131+ }
132+
133+ var isRecordingInitialized : Bool {
134+ self [ dynamicMember: \. isRecordingInitialized]
135+ }
136+
70137 var isMicrophoneMuted : Bool {
71- get { self [ dynamicMember: \. isMicrophoneMuted] }
72- set { _ = newValue }
138+ self [ dynamicMember: \. isMicrophoneMuted]
139+ }
140+
141+ var isStereoPlayoutEnabled : Bool {
142+ self [ dynamicMember: \. isStereoPlayoutEnabled]
143+ }
144+
145+ var isVoiceProcessingBypassed : Bool {
146+ get { self [ dynamicMember: \. isVoiceProcessingBypassed] }
147+ set { stub ( for: \. isVoiceProcessingBypassed, with: newValue) }
148+ }
149+
150+ var isVoiceProcessingEnabled : Bool {
151+ self [ dynamicMember: \. isVoiceProcessingEnabled]
152+ }
153+
154+ var isVoiceProcessingAGCEnabled : Bool {
155+ self [ dynamicMember: \. isVoiceProcessingAGCEnabled]
156+ }
157+
158+ var prefersStereoPlayout : Bool {
159+ get { self [ dynamicMember: \. prefersStereoPlayout] }
160+ set { stub ( for: \. prefersStereoPlayout, with: newValue) }
73161 }
74162
75163 func initAndStartRecording( ) -> Int {
@@ -81,7 +169,7 @@ final class MockRTCAudioDeviceModule: RTCAudioDeviceModuleControlling, Mockable,
81169 func setMicrophoneMuted( _ isMuted: Bool ) -> Int {
82170 stubbedFunctionInput [ . setMicrophoneMuted] ?
83171 . append ( . setMicrophoneMuted( isMuted) )
84- return stubbedFunction [ . setMicrophoneMuted] as? Int ?? 0
172+ return stubbedFunction [ . setMicrophoneMuted] as! Int
85173 }
86174
87175 func stopRecording( ) -> Int {
@@ -95,4 +183,39 @@ final class MockRTCAudioDeviceModule: RTCAudioDeviceModuleControlling, Mockable,
95183 . append ( . microphoneMutedPublisher)
96184 return microphoneMutedSubject. eraseToAnyPublisher ( )
97185 }
186+
187+ func reset( ) -> Int {
188+ stubbedFunctionInput [ . reset] ?
189+ . append ( . reset)
190+ return stubbedFunction [ . reset] as! Int
191+ }
192+
193+ func initAndStartPlayout( ) -> Int {
194+ stubbedFunctionInput [ . initAndStartPlayout] ?
195+ . append ( . initAndStartPlayout)
196+ return stubbedFunction [ . initAndStartPlayout] as! Int
197+ }
198+
199+ func startPlayout( ) -> Int {
200+ stubbedFunctionInput [ . startPlayout] ?
201+ . append ( . startPlayout)
202+ return stubbedFunction [ . startPlayout] as! Int
203+ }
204+
205+ func stopPlayout( ) -> Int {
206+ stubbedFunctionInput [ . stopPlayout] ?
207+ . append ( . stopPlayout)
208+ return stubbedFunction [ . stopPlayout] as! Int
209+ }
210+
211+ func startRecording( ) -> Int {
212+ stubbedFunctionInput [ . startRecording] ?
213+ . append ( . startRecording)
214+ return stubbedFunction [ . startRecording] as! Int
215+ }
216+
217+ func refreshStereoPlayoutState( ) {
218+ stubbedFunctionInput [ . refreshStereoPlayoutState] ?
219+ . append ( . refreshStereoPlayoutState)
220+ }
98221}
0 commit comments