Browse Source

UsbPlayerTest.isAllAudioTestTest Third Case (m4a)

feature.pr-USB-NewTest
sahar 3 years ago
parent
commit
36b6cc48c9
  1. 2
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 25
      src/test/java/device/usbPlayer/UsbPlayerTest.java

2
src/main/java/device/usbPlayer/UsbPlayer.java

@ -76,7 +76,7 @@ public class UsbPlayer implements Device {
for (int i = 0; i < Playlist.size(); i++) { for (int i = 0; i < Playlist.size(); i++) {
song = Playlist.get(i).substring(Playlist.get(i).length() - 4); song = Playlist.get(i).substring(Playlist.get(i).length() - 4);
if (song.equals(".mp3") | song.equals(".mp4") ) {
if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a") ) {
flag = true; flag = true;
} else { } else {
flag = false; flag = false;

25
src/test/java/device/usbPlayer/UsbPlayerTest.java

@ -3,6 +3,7 @@ package device.usbPlayer;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.ArrayList; 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(); int volumeNum = inputPlay.getLautstaerke();
assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult);
}
}
static Stream<Arguments> louderOptions() { static Stream<Arguments> louderOptions() {
UsbPlayer up11 = new UsbPlayer(); 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) Arguments.of("Volume was 100, should stay 100 ", up3, 100)
); );
} }
@ParameterizedTest @ParameterizedTest
@MethodSource("quieter_10_Options") @MethodSource("quieter_10_Options")
void quieter_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) { void quieter_10_Test(String testName, UsbPlayer inputPlay, int expectedResult) {
@ -251,15 +253,24 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) {
static Stream<Arguments> isAllAudioOptions() { static Stream<Arguments> isAllAudioOptions() {
UsbPlayer up1 = new UsbPlayer(); UsbPlayer up1 = new UsbPlayer();
UsbPlayer up2=new UsbPlayer();
UsbPlayer up2 = new UsbPlayer();
ArrayList<String> Pl = new ArrayList<String>(); ArrayList<String> Pl = new ArrayList<String>();
Pl.add("Musik 01.mp4"); Pl.add("Musik 01.mp4");
Pl.add("Musik 02.mp4"); Pl.add("Musik 02.mp4");
Pl.add("Musik 03.mp4"); Pl.add("Musik 03.mp4");
up2.setPlaylist(Pl); 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( 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)
); );
} }

Loading…
Cancel
Save