Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Apr 11, 2024
1 parent a574f94 commit fdc00e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Tests/SwiftAudioExTests/AudioPlayerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}
Expand Down
15 changes: 12 additions & 3 deletions Tests/SwiftAudioExTests/QueuedAudioPlayerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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() {
Expand Down

0 comments on commit fdc00e9

Please sign in to comment.