Skip to content

Commit

Permalink
(#23) Filled out existing unit tests with PlaybackState
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasstarsz committed Jul 11, 2021
1 parent 989a7f9 commit f87019f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ void checkPlayMemoryAudio_shouldTriggerOpenAndStartEvents() throws InterruptedEx

assertTrue(audioOpenEventBoolean.get(), "After playing the audio, the \"audio open\" event action should have been triggered.");
assertTrue(audioStartEventBoolean.get(), "After playing the audio, the \"audio start\" event action should have been triggered.");
assertEquals(PlaybackState.Playing, audio.getCurrentPlaybackState(), "After playing the audio, the gotten audio should be in the \"playing\" playback state.");
assertEquals(PlaybackState.Stopped, audio.getPreviousPlaybackState(), "After playing the audio, the gotten audio's previous playback state should be \"stopped\".");
}

@Test
Expand All @@ -147,6 +149,9 @@ void checkPauseMemoryAudio_shouldTriggerPauseAndStopEvents() throws InterruptedE

assertTrue(audioPauseEventBoolean.get(), "After pausing the audio, the \"audio pause\" event action should have been triggered.");
assertTrue(audioStopEventBoolean.get(), "After pausing the audio, the \"audio stop\" event action should have been triggered.");
assertTrue(audioStopEventBoolean.get(), "After pausing the audio, the \"audio stop\" event action should have been triggered.");
assertEquals(PlaybackState.Paused, audio.getCurrentPlaybackState(), "After pausing the audio, the gotten audio should be in the \"paused\" playback state.");
assertEquals(PlaybackState.Playing, audio.getPreviousPlaybackState(), "After pausing the audio, the gotten audio's previous playback state should be \"playing\".");
}

@Test
Expand All @@ -166,6 +171,8 @@ void checkResumeMemoryAudio_shouldTriggerStartAndResumeEvents() throws Interrupt

assertTrue(audioResumeEventBoolean.get(), "After resuming the audio, the \"audio resume\" event action should have been triggered.");
assertTrue(audioStartEventBoolean.get(), "After resuming the audio, the \"audio start\" event action should have been triggered.");
assertEquals(PlaybackState.Playing, audio.getCurrentPlaybackState(), "After resuming the audio, the gotten audio should be in the \"playing\" playback state.");
assertEquals(PlaybackState.Paused, audio.getPreviousPlaybackState(), "After resuming the audio, the gotten audio's previous playback state should be \"paused\".");
}

@Test
Expand All @@ -183,6 +190,8 @@ void checkStopMemoryAudio_shouldTriggerStopAndCloseEvents() throws InterruptedEx

assertTrue(audioCloseEventBoolean.get(), "After stopping the audio, the \"audio close\" event action should have been triggered.");
assertTrue(audioStopEventBoolean.get(), "After stopping the audio, the \"audio stop\" event action should have been triggered.");
assertEquals(PlaybackState.Stopped, audio.getCurrentPlaybackState(), "After stopping the audio, the gotten audio should be in the \"stopped\" playback state.");
assertEquals(PlaybackState.Playing, audio.getPreviousPlaybackState(), "After stopping the audio, the gotten audio's previous playback state should be \"playing\" because its last state was not paused.");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void checkLoadStreamedAudioInstance_shouldMatchExpectedValues() {
assertEquals(PlaybackState.Stopped, audio.getCurrentPlaybackState(), "After loading the audio into memory, the gotten audio should be in the \"stopped\" playback state.");
assertEquals(PlaybackState.Stopped, audio.getPreviousPlaybackState(), "After loading the audio into memory, the gotten audio's previous playback state should also be \"stopped\".");
assertEquals(0L, audio.getPlaybackPosition(), "After loading the audio into memory, the gotten audio should be at the very beginning with playback position.");
assertNull(audio.getAudioEventListener().getAudioOpenAction(), "After loading the audio into memory, the gotten audio's event listener should not contain an \"audio open\" event action.");
assertNull(audio.getAudioEventListener().getAudioStartAction(), "After loading the audio into memory, the gotten audio's event listener should not contain an \"audio start\" event action.");
assertNull(audio.getAudioEventListener().getAudioPauseAction(), "After loading the audio into memory, the gotten audio's event listener should not contain an \"audio pause\" event action.");
assertNull(audio.getAudioEventListener().getAudioResumeAction(), "After loading the audio into memory, the gotten audio's event listener should not contain an \"audio resume\" event action.");
assertNull(audio.getAudioEventListener().getAudioStopAction(), "After loading the audio into memory, the gotten audio's event listener should not contain an \"audio stop\" event action.");
assertNull(audio.getAudioEventListener().getAudioCloseAction(), "After loading the audio into memory, the gotten audio's event listener should not contain an \"audio close\" event action.");
}

@Test
Expand All @@ -50,6 +56,8 @@ void checkPlayStreamedAudio_shouldTriggerOpenAndStartEvents() throws Interrupted

assertTrue(audioOpenEventBoolean.get(), "After playing the audio, the \"audio open\" event action should have been triggered.");
assertTrue(audioStartEventBoolean.get(), "After playing the audio, the \"audio start\" event action should have been triggered.");
assertEquals(PlaybackState.Playing, audio.getCurrentPlaybackState(), "After playing the audio, the gotten audio should be in the \"playing\" playback state.");
assertEquals(PlaybackState.Stopped, audio.getPreviousPlaybackState(), "After playing the audio, the gotten audio's previous playback state should be \"stopped\".");
}

@Test
Expand All @@ -67,6 +75,8 @@ void checkPauseStreamedAudio_shouldTriggerPauseAndStopEvents() throws Interrupte

assertTrue(audioPauseEventBoolean.get(), "After pausing the audio, the \"audio pause\" event action should have been triggered.");
assertTrue(audioStopEventBoolean.get(), "After pausing the audio, the \"audio stop\" event action should have been triggered.");
assertEquals(PlaybackState.Paused, audio.getCurrentPlaybackState(), "After pausing the audio, the gotten audio should be in the \"paused\" playback state.");
assertEquals(PlaybackState.Playing, audio.getPreviousPlaybackState(), "After pausing the audio, the gotten audio's previous playback state should be \"playing\".");
}

@Test
Expand All @@ -86,6 +96,8 @@ void checkResumeStreamedAudio_shouldTriggerStartAndResumeEvents() throws Interru

assertTrue(audioResumeEventBoolean.get(), "After resuming the audio, the \"audio resume\" event action should have been triggered.");
assertTrue(audioStartEventBoolean.get(), "After resuming the audio, the \"audio start\" event action should have been triggered.");
assertEquals(PlaybackState.Playing, audio.getCurrentPlaybackState(), "After resuming the audio, the gotten audio should be in the \"playing\" playback state.");
assertEquals(PlaybackState.Paused, audio.getPreviousPlaybackState(), "After resuming the audio, the gotten audio's previous playback state should be \"paused\".");
}

@Test
Expand All @@ -103,6 +115,8 @@ void checkStopStreamedAudio_shouldTriggerStopAndCloseEvents() throws Interrupted

assertTrue(audioCloseEventBoolean.get(), "After stopping the audio, the \"audio close\" event action should have been triggered.");
assertTrue(audioStopEventBoolean.get(), "After stopping the audio, the \"audio stop\" event action should have been triggered.");
assertEquals(PlaybackState.Stopped, audio.getCurrentPlaybackState(), "After stopping the audio, the gotten audio should be in the \"stopped\" playback state.");
assertEquals(PlaybackState.Playing, audio.getPreviousPlaybackState(), "After stopping the audio, the gotten audio's previous playback state should be \"playing\" because its last state was not paused.");
}

@Test
Expand Down

0 comments on commit f87019f

Please sign in to comment.