|
|
@ -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) { |
|
|
|
@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(); |
|
|
@ -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) { |
|
|
@ -242,5 +244,114 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("isAllAudioOptions") |
|
|
|
void isAllAudioTest(String testName, boolean inputTestResult, boolean expectedResult) { |
|
|
|
// String current_Track = inputPlay.getPlayTrack(); |
|
|
|
assertThat(inputTestResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> isAllAudioOptions() { |
|
|
|
//mp3 |
|
|
|
UsbPlayer up1 = new UsbPlayer(); |
|
|
|
//mp4 |
|
|
|
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(Pl1); |
|
|
|
//wav |
|
|
|
UsbPlayer up4 = new UsbPlayer(); |
|
|
|
ArrayList<String> Pl2 = new ArrayList<String>(); |
|
|
|
Pl2.add("Musik 01.wav"); |
|
|
|
Pl2.add("Musik 02.wav"); |
|
|
|
Pl2.add("Musik 03.wav"); |
|
|
|
up4.setPlaylist(Pl2); |
|
|
|
//wma |
|
|
|
UsbPlayer up5 = new UsbPlayer(); |
|
|
|
ArrayList<String> Pl3 = new ArrayList<String>(); |
|
|
|
Pl3.add("Musik 01.wma"); |
|
|
|
Pl3.add("Musik 02.wma"); |
|
|
|
Pl3.add("Musik 03.wma"); |
|
|
|
up5.setPlaylist(Pl3); |
|
|
|
//aac |
|
|
|
UsbPlayer up6 = new UsbPlayer(); |
|
|
|
ArrayList<String> Pl4 = new ArrayList<String>(); |
|
|
|
Pl4.add("Musik 01.aac"); |
|
|
|
Pl4.add("Musik 02.aac"); |
|
|
|
Pl4.add("Musik 03.aac"); |
|
|
|
up6.setPlaylist(Pl4); |
|
|
|
//mixed Audio and text Files in the Album |
|
|
|
UsbPlayer up7 = new UsbPlayer(); |
|
|
|
ArrayList<String> Pl5 = new ArrayList<String>(); |
|
|
|
Pl5.add("Musik 01.aac"); |
|
|
|
Pl5.add("Musik 02.txt"); |
|
|
|
Pl5.add("Musik 03.aac"); |
|
|
|
up7.setPlaylist(Pl5); |
|
|
|
|
|
|
|
return Stream.of( |
|
|
|
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), |
|
|
|
Arguments.of("Check if the Files are .wav ", up4.isAllAudio(), true), |
|
|
|
Arguments.of("Check if the Files are .wma ", up5.isAllAudio(), true), |
|
|
|
Arguments.of("Check if the Files are .aac ", up6.isAllAudio(), true), |
|
|
|
Arguments.of("Check case of mixed Files", up7.isAllAudio(), false) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
//GoToFirst() |
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("GoToFirstOptions") |
|
|
|
void GoToFirstTest(String testName, UsbPlayer inputUSB, String expectedResult) { |
|
|
|
String firstSong = inputUSB.getPlayTrack(); |
|
|
|
assertThat(firstSong ).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> GoToFirstOptions() { |
|
|
|
UsbPlayer up1 = new UsbPlayer(); |
|
|
|
up1.GoToFirst(); |
|
|
|
|
|
|
|
UsbPlayer up2 = new UsbPlayer(); |
|
|
|
up2.GoToFirst(); |
|
|
|
up2.GoToFirst(); |
|
|
|
|
|
|
|
UsbPlayer up3 = new UsbPlayer(); |
|
|
|
up3.next(); |
|
|
|
up3.GoToFirst(); |
|
|
|
|
|
|
|
return Stream.of( |
|
|
|
Arguments.of("It should go to the first Song ", up1,up1.getPlaylist().get(0)), |
|
|
|
Arguments.of("Call the function twice and it stills go to the first Song ", up2,up2.getPlaylist().get(0)), |
|
|
|
Arguments.of("go to the next Song then back to first Song ", up3,up3.getPlaylist().get(0)) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("GoToLastOptions") |
|
|
|
void GoToLastTest(String testName, UsbPlayer inputUSB, String expectedResult) { |
|
|
|
String firstSong = inputUSB.getPlayTrack(); |
|
|
|
assertThat(firstSong ).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> GoToLastOptions() { |
|
|
|
//first case |
|
|
|
UsbPlayer up1 = new UsbPlayer(); |
|
|
|
up1.GoToLast(); |
|
|
|
|
|
|
|
|
|
|
|
return Stream.of( |
|
|
|
Arguments.of("It should go to the first Song ", up1,"Musik 03.mp3") |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |