diff --git a/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift b/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift index ff70514e..3d80b1ec 100644 --- a/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift +++ b/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift @@ -10,12 +10,13 @@ final class AVPlayerExtensions: XCTestCase { _ = observer.readyExpectation let avPlayer = AVPlayer(playerItem: nil) + avPlayer.addObserver(observer, forKeyPath: "status", options: .new, context: nil) avPlayer.replaceCurrentItem(withHls: VideoOptions(videoId: VideoId.validVideoId, videoType: .vod)) - avPlayer.currentItem?.addObserver(observer, forKeyPath: "status", options: .new, context: nil) + avPlayer.play() waitForExpectations(timeout: 10, handler: nil) - avPlayer.currentItem?.removeObserver(observer, forKeyPath: "status") + avPlayer.removeObserver(observer, forKeyPath: "status") } func testValidMP4VideoIdPlay() throws { @@ -23,12 +24,13 @@ final class AVPlayerExtensions: XCTestCase { _ = observer.readyExpectation let avPlayer = AVPlayer(playerItem: nil) + avPlayer.addObserver(observer, forKeyPath: "status", options: .new, context: nil) avPlayer.replaceCurrentItem(withMp4: VideoOptions(videoId: VideoId.validVideoId, videoType: .vod)) - avPlayer.currentItem?.addObserver(observer, forKeyPath: "status", options: .new, context: nil) + avPlayer.play() waitForExpectations(timeout: 10, handler: nil) - avPlayer.currentItem?.removeObserver(observer, forKeyPath: "status") + avPlayer.removeObserver(observer, forKeyPath: "status") } } diff --git a/Tests/ApiVideoPlayerTests/IntegrationTests/ApiVideoPlayerControllerIntegrationTests.swift b/Tests/ApiVideoPlayerTests/IntegrationTests/ApiVideoPlayerControllerIntegrationTests.swift index 163ebc92..11be3a9e 100644 --- a/Tests/ApiVideoPlayerTests/IntegrationTests/ApiVideoPlayerControllerIntegrationTests.swift +++ b/Tests/ApiVideoPlayerTests/IntegrationTests/ApiVideoPlayerControllerIntegrationTests.swift @@ -112,15 +112,15 @@ final class ApiVideoPlayerControllerIntegrationTests: XCTestCase { func testInvalidVideoId() throws { let mockDelegate = MockedPlayerDelegate(testCase: self) - _ = mockDelegate.expectationReady(true) - _ = mockDelegate.expectationError() + let ready = mockDelegate.expectationReady(true) + let error = mockDelegate.expectationError() let controller = ApiVideoPlayerController( videoOptions: VideoOptions(videoId: VideoId.invalidVideoId, videoType: .vod), delegates: [mockDelegate] ) - waitForExpectations(timeout: 5, handler: nil) + wait(for: [ready, error], timeout: 5) } @available(iOS 13.0, *)