|
|
@ -3,6 +3,7 @@ package device.usbPlayer; |
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
@ -48,12 +49,12 @@ class UsbPlayerTest { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("louderOptions") |
|
|
|
void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
int volumeNum = inputPlay.getLautstaerke(); |
|
|
|
assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("louderOptions") |
|
|
|
void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
int volumeNum = inputPlay.getLautstaerke(); |
|
|
|
assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> louderOptions() { |
|
|
|
UsbPlayer up11 = new UsbPlayer(); |
|
|
@ -149,7 +150,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
|
|
|
|
UsbPlayer up2 = new UsbPlayer(); |
|
|
|
for (int i = 0; i <= 3; i++) { |
|
|
|
up2.Louder_10(); |
|
|
|
up2.Louder_10(); |
|
|
|
} |
|
|
|
up2.quieter_10(); |
|
|
|
|
|
|
@ -162,6 +163,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
Arguments.of("Volume was 100, should stay 100 ", up3, 100) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("quieter_10_Options") |
|
|
|
void quieter_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
@ -194,10 +196,10 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
@MethodSource("FindSongOptions") |
|
|
|
void findSongTest(String testName, int inputPlay, int expectedResult) { |
|
|
|
//first case: the song is not in the Album |
|
|
|
// int songLoc1 = inputPlay.findSong("song 4"); |
|
|
|
// int songLoc1 = inputPlay.findSong("song 4"); |
|
|
|
assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
//Second Case: the song is in the album |
|
|
|
// int songLoc2 = inputPlay.findSong("Musik 02"); |
|
|
|
// int songLoc2 = inputPlay.findSong("Musik 02"); |
|
|
|
assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
|
|
|
|
} |
|
|
@ -245,21 +247,30 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("isAllAudioOptions") |
|
|
|
void isAllAudioTest(String testName, boolean inputTestResult, boolean expectedResult) { |
|
|
|
// String current_Track = inputPlay.getPlayTrack(); |
|
|
|
// String current_Track = inputPlay.getPlayTrack(); |
|
|
|
assertThat(inputTestResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> isAllAudioOptions() { |
|
|
|
UsbPlayer up1 = new UsbPlayer(); |
|
|
|
UsbPlayer up2=new UsbPlayer(); |
|
|
|
|
|
|
|
UsbPlayer up2 = new UsbPlayer(); |
|
|
|
ArrayList<String> Pl = new ArrayList<String>(); |
|
|
|
Pl.add("Musik 01.mp4"); |
|
|
|
Pl.add("Musik 02.mp4"); |
|
|
|
Pl.add("Musik 03.mp4"); |
|
|
|
up2.setPlaylist(Pl); |
|
|
|
//m4a |
|
|
|
UsbPlayer up3 = new UsbPlayer(); |
|
|
|
ArrayList<String> Pl1 = new ArrayList<String>(); |
|
|
|
Pl1.add("Musik 01.m4a"); |
|
|
|
Pl1.add("Musik 02.m4a"); |
|
|
|
Pl1.add("Musik 03.m4a"); |
|
|
|
up3.setPlaylist(Pl); |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("Go to Song : Musik 03.mp3 ", up1.isAllAudio(), true), |
|
|
|
Arguments.of("Go to Song : Musik 03.mp3 ", up2.isAllAudio(), true) |
|
|
|
Arguments.of("Check if the Files are .mp3 ", up1.isAllAudio(), true), |
|
|
|
Arguments.of("Check if the Files are .mp4 ", up2.isAllAudio(), true), |
|
|
|
Arguments.of("Check if the Files are .m4a ", up3.isAllAudio(), true) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|