diff --git a/Tests/SwiftAudioExTests/AudioPlayerTests.swift b/Tests/SwiftAudioExTests/AudioPlayerTests.swift index f71bb2e..b84b4d8 100644 --- a/Tests/SwiftAudioExTests/AudioPlayerTests.swift +++ b/Tests/SwiftAudioExTests/AudioPlayerTests.swift @@ -224,7 +224,7 @@ class AudioPlayerTests: XCTestCase { self.audioPlayer.load(item: Source.getAudioItem(), playWhenReady: true) waitTrue(self.audioPlayer.playbackError == nil, timeout: 5) - waitEqual(self.playerStateEventListener.statesWithoutBuffering, [.loading, .failed, .loading, .playing], timeout: 5) + waitEqual(self.playerStateEventListener.statesWithoutBuffering, [.loading, .failed, .idle, .loading, .playing], timeout: 5) } func testLoadResourceSucceedsAfterPreviousFailureWithPlayWhenReady() { @@ -411,7 +411,7 @@ class AudioPlayerTests: XCTestCase { func testSeekingBeforeLoadingComplete() { audioPlayer.load(item: FiveSecondSource.getAudioItem(), playWhenReady: true) - XCTAssertTrue(audioPlayer.playerState == .loading) + XCTAssertTrue(audioPlayer.playerState == .buffering) audioPlayer.seek(to: 4.75) waitTrue(self.audioPlayer.currentTime > 4.75, timeout: 5) } diff --git a/Tests/SwiftAudioExTests/QueuedAudioPlayerTests.swift b/Tests/SwiftAudioExTests/QueuedAudioPlayerTests.swift index 2dcff06..453624d 100644 --- a/Tests/SwiftAudioExTests/QueuedAudioPlayerTests.swift +++ b/Tests/SwiftAudioExTests/QueuedAudioPlayerTests.swift @@ -81,9 +81,9 @@ class QueuedAudioPlayerTests: XCTestCase { func testLoadAfterRemoval() { testRemovingItemAfterAdding() - audioPlayer.load(item: Source.getAudioItem()) + audioPlayer.load(item: Source.getAudioItem(), playWhenReady: true) XCTAssertNotEqual(audioPlayer.currentItem?.getSourceUrl(), FiveSecondSource.getAudioItem().getSourceUrl()) - waitEqual(self.playerStateEventListener.statesWithoutBuffering, [.loading, .idle, .loading, .playing], timeout: 5) + waitTrue(self.playerStateEventListener.statesWithoutBuffering.contains(.playing), timeout: 5) XCTAssertEqual(audioPlayer.playerState, AudioPlayerState.playing) } @@ -100,7 +100,16 @@ class QueuedAudioPlayerTests: XCTestCase { XCTAssertEqual(audioPlayer.items.count, 1) XCTAssertEqual(audioPlayer.currentItem?.getSourceUrl(), ShortSource.getAudioItem().getSourceUrl()) } - + + // Covers: https://github.com/doublesymmetry/SwiftAudioEx/pull/81 + func testAddingItemWhenOnlyOneTrackInQueue() throws { + audioPlayer.add(item: FiveSecondSource.getAudioItem()) + audioPlayer.play() + try audioPlayer.add(items: [ShortSource.getAudioItem()], at: 0) + XCTAssertEqual(audioPlayer.items.count, 2) + XCTAssertEqual(audioPlayer.currentIndex, 1) + } + // MARK: - Next Items func testNextItemsEmptyOnCreate() {