Skip to content

Commit

Permalink
add unit tests for unloadAudio overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasstarsz committed Aug 9, 2021
1 parent 834ef05 commit 9c105db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,23 @@ void checkGetAudioAfterUnloading() {
AudioManager.unloadMemoryAudio(audio.getID());
assertNull(AudioManager.getMemoryAudio(audio.getID()), "After unloading the audio, it should not be present in the audio manager.");
}

@Test
void checkGetAudioAfterUnloading_withMultipleAudioFiles() {
MemoryAudio[] memoryAudios = new MemoryAudio[4];
memoryAudios[0] = AudioManager.loadMemoryAudio(TestAudioPath);
memoryAudios[1] = AudioManager.loadMemoryAudio(TestAudioURL);
memoryAudios[2] = AudioManager.loadMemoryAudio(TestAudioPath);
memoryAudios[3] = AudioManager.loadMemoryAudio(TestAudioURL);

for (MemoryAudio memoryAudio : memoryAudios) {
assertNotNull(AudioManager.getMemoryAudio(memoryAudio.getID()), "The audio should have been loaded into the audio manager successfully.");
}

AudioManager.unloadMemoryAudio(memoryAudios[0].getID(), memoryAudios[1].getID(), memoryAudios[2].getID(), memoryAudios[3].getID());

for (MemoryAudio memoryAudio : memoryAudios) {
assertNull(AudioManager.getMemoryAudio(memoryAudio.getID()), "After unloading the audio, it should not be present in the audio manager.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class StreamedAudioTests {

private static final Path TestAudioPath = Path.of("src/test/resources/test_audio.wav");
private static final URL TestAudioURL = Objects.requireNonNull(MemoryAudioTests.class.getClassLoader().getResource("test_audio.wav"));
private static final URL TestAudioURL = Objects.requireNonNull(StreamedAudioTests.class.getClassLoader().getResource("test_audio.wav"));

@BeforeAll
public static void onlyRunIfAudioOutputIsSupported() {
Expand Down Expand Up @@ -146,4 +146,23 @@ void checkGetAudioAfterUnloading() {
AudioManager.unloadStreamedAudio(audio.getID());
assertNull(AudioManager.getStreamedAudio(audio.getID()), "After unloading the audio, it should not be present in the audio manager.");
}

@Test
void checkGetAudioAfterUnloading_withMultipleAudioFiles() {
StreamedAudio[] streamedAudios = new StreamedAudio[4];
streamedAudios[0] = AudioManager.loadStreamedAudio(TestAudioPath);
streamedAudios[1] = AudioManager.loadStreamedAudio(TestAudioURL);
streamedAudios[2] = AudioManager.loadStreamedAudio(TestAudioPath);
streamedAudios[3] = AudioManager.loadStreamedAudio(TestAudioURL);

for (StreamedAudio streamedAudio : streamedAudios) {
assertNotNull(AudioManager.getStreamedAudio(streamedAudio.getID()), "The audio should have been loaded into the audio manager successfully.");
}

AudioManager.unloadStreamedAudio(streamedAudios[0].getID(), streamedAudios[1].getID(), streamedAudios[2].getID(), streamedAudios[3].getID());

for (StreamedAudio streamedAudio : streamedAudios) {
assertNull(AudioManager.getStreamedAudio(streamedAudio.getID()), "After unloading the audio, it should not be present in the audio manager.");
}
}
}

0 comments on commit 9c105db

Please sign in to comment.