mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Use native video call picture in picture! (#3190)
* Use native video call picture in picture! * Handle isSupported, isPossible and web view errors. * Use new canEnterPip method. * Hide a room's Call button when already joined to the call. * Tweak feature flag description. * PR comments.
This commit is contained in:
@@ -308,6 +308,7 @@ class RoomFlowCoordinatorTests: XCTestCase {
|
||||
roomTimelineControllerFactory: timelineControllerFactory,
|
||||
navigationStackCoordinator: navigationStackCoordinator,
|
||||
emojiProvider: EmojiProvider(),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
|
||||
@@ -44,6 +44,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxyMock.underlyingActionsPublisher = updateSubject.eraseToAnyPublisher()
|
||||
let viewModel = RoomScreenViewModel(roomProxy: roomProxyMock,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics)
|
||||
@@ -112,6 +113,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxyMock.underlyingActionsPublisher = updateSubject.eraseToAnyPublisher()
|
||||
let viewModel = RoomScreenViewModel(roomProxy: roomProxyMock,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics)
|
||||
@@ -140,4 +142,42 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
updateSubject.send(.roomInfoUpdate)
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testCallButtonVisibility() async throws {
|
||||
// Given a room screen with no ongoing call.
|
||||
let ongoingCallRoomIDSubject = CurrentValueSubject<String?, Never>(nil)
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(id: "MyRoomID"))
|
||||
let viewModel = RoomScreenViewModel(roomProxy: roomProxyMock,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
ongoingCallRoomIDPublisher: ongoingCallRoomIDSubject.asCurrentValuePublisher(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics)
|
||||
self.viewModel = viewModel
|
||||
XCTAssertTrue(viewModel.state.shouldShowCallButton)
|
||||
|
||||
// When a call starts in this room.
|
||||
var deferred = deferFulfillment(viewModel.context.$viewState) { !$0.shouldShowCallButton }
|
||||
ongoingCallRoomIDSubject.send("MyRoomID")
|
||||
try await deferred.fulfill()
|
||||
|
||||
// Then the call button should be hidden.
|
||||
XCTAssertFalse(viewModel.state.shouldShowCallButton)
|
||||
|
||||
// When a call starts in a different room.
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { $0.shouldShowCallButton }
|
||||
ongoingCallRoomIDSubject.send("OtherRoomID")
|
||||
try await deferred.fulfill()
|
||||
|
||||
// Then the call button should be shown again.
|
||||
XCTAssertTrue(viewModel.state.shouldShowCallButton)
|
||||
|
||||
// When the call from the other room finishes.
|
||||
let deferredFailure = deferFailure(viewModel.context.$viewState, timeout: 1) { !$0.shouldShowCallButton }
|
||||
ongoingCallRoomIDSubject.send(nil)
|
||||
try await deferredFailure.fulfill()
|
||||
|
||||
// Then the call button should remain visible shown.
|
||||
XCTAssertTrue(viewModel.state.shouldShowCallButton)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user