@@ -22,7 +22,7 @@ final class WebRTCPermissionsAdapter_Tests: StreamVideoTestCase, @unchecked Send
2222 super. tearDown ( )
2323 }
2424
25- func test_willSet_audioOnTrue_withDeniedMic_downgradesAudioOff ( ) async {
25+ func test_willSet_audioOnTrue_withoutSendAudio_withDeniedMic_downgradesAudioOff ( ) async {
2626 mockAppStateAdapter. makeShared ( )
2727 mockPermissions. stubMicrophonePermission ( . denied)
2828 await fulfillment { self . mockPermissions. mockStore. state. microphonePermission == . denied }
@@ -34,7 +34,33 @@ final class WebRTCPermissionsAdapter_Tests: StreamVideoTestCase, @unchecked Send
3434 XCTAssertEqual ( output. videoOn, false )
3535 }
3636
37- func test_willSet_videoOnTrue_withDeniedCamera_downgradesVideoOff( ) async {
37+ func test_willSet_audioOnTrue_withSendAudio_withDeniedMic_downgradesAudioOff( ) async {
38+ mockAppStateAdapter. makeShared ( )
39+ mockPermissions. stubMicrophonePermission ( . denied)
40+ await fulfillment { self . mockPermissions. mockStore. state. microphonePermission == . denied }
41+
42+ let input = CallSettings ( audioOn: true , videoOn: false )
43+ subject. willSet ( ownCapabilities: [ . sendAudio] )
44+ let output = await subject. willSet ( callSettings: input)
45+
46+ XCTAssertEqual ( output. audioOn, false )
47+ XCTAssertEqual ( output. videoOn, false )
48+ }
49+
50+ func test_willSet_videoOnTrue_withSendVideo_withDeniedCamera_downgradesVideoOff( ) async {
51+ mockAppStateAdapter. makeShared ( )
52+ mockPermissions. stubCameraPermission ( . denied)
53+ await fulfillment { self . mockPermissions. mockStore. state. cameraPermission == . denied }
54+
55+ let input = CallSettings ( audioOn: false , videoOn: true )
56+ subject. willSet ( ownCapabilities: [ . sendVideo] )
57+ let output = await subject. willSet ( callSettings: input)
58+
59+ XCTAssertEqual ( output. audioOn, false )
60+ XCTAssertEqual ( output. videoOn, false )
61+ }
62+
63+ func test_willSet_videoOnTrue_withoutSendVideo_withDeniedCamera_downgradesVideoOff( ) async {
3864 mockAppStateAdapter. makeShared ( )
3965 mockPermissions. stubCameraPermission ( . denied)
4066 await fulfillment { self . mockPermissions. mockStore. state. cameraPermission == . denied }
@@ -46,10 +72,22 @@ final class WebRTCPermissionsAdapter_Tests: StreamVideoTestCase, @unchecked Send
4672 XCTAssertEqual ( output. videoOn, false )
4773 }
4874
49- func test_willSet_audioOnTrue_unknownMic_inForeground_requestsPermission_andKeepsAudioOnWhenGranted( ) async {
75+ func test_willSet_audioOnTrue_unknownMic_inForeground_withoutSendAudio_requestsPermission_andKeepsAudioOnWhenGranted( ) async {
76+ mockAppStateAdapter. makeShared ( )
77+ mockAppStateAdapter. stubbedState = . foreground
78+ mockPermissions. stubMicrophonePermission ( . unknown)
79+ await fulfillment { self . mockPermissions. mockStore. state. microphonePermission == . unknown }
80+
81+ let input = CallSettings ( audioOn: true , videoOn: false )
82+ let output = await self . subject. willSet ( callSettings: input)
83+ XCTAssertEqual ( output. audioOn, false )
84+ }
85+
86+ func test_willSet_audioOnTrue_unknownMic_inForeground_withSendAudio_requestsPermission_andKeepsAudioOnWhenGranted( ) async {
5087 mockAppStateAdapter. makeShared ( )
5188 mockAppStateAdapter. stubbedState = . foreground
5289 mockPermissions. stubMicrophonePermission ( . unknown)
90+ subject. willSet ( ownCapabilities: [ . sendAudio] )
5391 await fulfillment { self . mockPermissions. mockStore. state. microphonePermission == . unknown }
5492
5593 await withTaskGroup ( of: Void . self) { group in
@@ -71,10 +109,22 @@ final class WebRTCPermissionsAdapter_Tests: StreamVideoTestCase, @unchecked Send
71109 }
72110 }
73111
74- func test_willSet_videoOnTrue_unknownCamera_inForeground_requestsPermission_andKeepsVideoOnWhenGranted( ) async {
112+ func test_willSet_videoOnTrue_unknownCamera_inForeground_withoutSendVideo_requestsPermission_andKeepsVideoOnWhenGranted( ) async {
113+ mockAppStateAdapter. makeShared ( )
114+ mockAppStateAdapter. stubbedState = . foreground
115+ mockPermissions. stubCameraPermission ( . unknown)
116+ await fulfillment { self . mockPermissions. mockStore. state. cameraPermission == . unknown }
117+
118+ let input = CallSettings ( audioOn: false , videoOn: true )
119+ let output = await self . subject. willSet ( callSettings: input)
120+ XCTAssertEqual ( output. videoOn, false )
121+ }
122+
123+ func test_willSet_videoOnTrue_unknownCamera_inForeground_withSendVideo_requestsPermission_andKeepsVideoOnWhenGranted( ) async {
75124 mockAppStateAdapter. makeShared ( )
76125 mockAppStateAdapter. stubbedState = . foreground
77126 mockPermissions. stubCameraPermission ( . unknown)
127+ subject. willSet ( ownCapabilities: [ . sendVideo] )
78128 await fulfillment { self . mockPermissions. mockStore. state. cameraPermission == . unknown }
79129
80130 await withTaskGroup ( of: Void . self) { group in
0 commit comments