From 36b6cc48c9f820ec15d9ff48bb7548c2f499dfcd Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:30:54 +0100 Subject: [PATCH] UsbPlayerTest.isAllAudioTestTest Third Case (m4a) --- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- .../java/device/usbPlayer/UsbPlayerTest.java | 37 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 1c18978..2dac1b0 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -76,7 +76,7 @@ public class UsbPlayer implements Device { for (int i = 0; i < Playlist.size(); i++) { 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; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 37acd4a..fc121f7 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/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.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 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 isAllAudioOptions() { UsbPlayer up1 = new UsbPlayer(); - UsbPlayer up2=new UsbPlayer(); + + UsbPlayer up2 = new UsbPlayer(); ArrayList Pl = new ArrayList(); Pl.add("Musik 01.mp4"); Pl.add("Musik 02.mp4"); Pl.add("Musik 03.mp4"); up2.setPlaylist(Pl); +//m4a + UsbPlayer up3 = new UsbPlayer(); + ArrayList Pl1 = new ArrayList(); + 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) ); }