Permalink
Show file tree
Hide file tree
15 changes: 13 additions & 2 deletions
15
Wire-iOS/Sources/UserInterface/Calling/VideoGridView/SelfVideoPreviewView.swift
8 changes: 4 additions & 4 deletions
8
Wire-iOS/Sources/UserInterface/Calling/VideoGridView/VideoGridViewController.swift
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Fix] video capture state (#4879)
* stop capture when there is no self video stream * update capture state when needed * update capture state on didMoveToWindow * add tests
- Loading branch information
1 parent
5f733cf
commit 7e3c301
Showing
4 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // | ||
| // Wire | ||
| // Copyright (C) 2021 Wire Swiss GmbH | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see http://www.gnu.org/licenses/. | ||
| // | ||
| import Foundation | ||
| import XCTest | ||
| import avs | ||
|
|
||
| @testable import Wire | ||
|
|
||
| class MockAVSVideoPreview: AVSVideoPreview { | ||
| var isCapturing: Bool = false | ||
|
|
||
| override func startVideoCapture() { | ||
| isCapturing = true | ||
| } | ||
|
|
||
| override func stopVideoCapture() { | ||
| isCapturing = false | ||
| } | ||
| } | ||
|
|
||
| class SelfVideoPreviewViewTests: XCTestCase { | ||
| var sut: SelfVideoPreviewView! | ||
| var stubProvider = VideoStreamStubProvider() | ||
| var previewViewMock = MockAVSVideoPreview() | ||
|
|
||
| override func setUp() { | ||
| super.setUp() | ||
|
|
||
| let stream = stubProvider.videoStream().stream | ||
| sut = SelfVideoPreviewView(stream: stream, isCovered: false, shouldShowActiveSpeakerFrame: false) | ||
| sut.previewView = previewViewMock | ||
| } | ||
|
|
||
| override func tearDown() { | ||
| sut = nil | ||
| super.tearDown() | ||
| } | ||
|
|
||
| func testCapturerState_ForVideoState_Started() { | ||
| // Given | ||
| previewViewMock.isCapturing = false | ||
|
|
||
| // When | ||
| sut.stream = stubProvider.videoStream(videoState: .started).stream | ||
|
|
||
| // Then | ||
| XCTAssertTrue(previewViewMock.isCapturing) | ||
| } | ||
|
|
||
| func testCapturerState_ForVideoState_Stopped() { | ||
| // Given | ||
| previewViewMock.isCapturing = false | ||
|
|
||
| // When | ||
| sut.stream = stubProvider.videoStream(videoState: .stopped).stream | ||
|
|
||
| // Then | ||
| XCTAssertFalse(previewViewMock.isCapturing) | ||
| } | ||
|
|
||
| func testCapturerState_ForVideoState_Paused() { | ||
| // Given | ||
| previewViewMock.isCapturing = false | ||
|
|
||
| // When | ||
| sut.stream = stubProvider.videoStream(videoState: .paused).stream | ||
|
|
||
| // Then | ||
| XCTAssertFalse(previewViewMock.isCapturing) | ||
| } | ||
|
|
||
| func testCapturerState_ForVideoState_BadConnection() { | ||
| // Given | ||
| previewViewMock.isCapturing = false | ||
|
|
||
| // When | ||
| sut.stream = stubProvider.videoStream(videoState: .badConnection).stream | ||
|
|
||
| // Then | ||
| XCTAssertFalse(previewViewMock.isCapturing) | ||
| } | ||
|
|
||
| func testCapturerState_ForVideoState_ScreenSharing() { | ||
| // Given | ||
| previewViewMock.isCapturing = false | ||
|
|
||
| // When | ||
| sut.stream = stubProvider.videoStream(videoState: .screenSharing).stream | ||
|
|
||
| // Then | ||
| XCTAssertFalse(previewViewMock.isCapturing) | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters