From e68d22daf4785ce3fda026d88cd7893be19a38dd Mon Sep 17 00:00:00 2001 From: sahar Date: Tue, 15 Feb 2022 17:20:59 +0100 Subject: [PATCH] UsbPlayerTest.isAllAudioTestTest First Case --- src/main/java/device/usbPlayer/UsbPlayer.java | 4 ++-- .../java/device/usbPlayer/UsbPlayerTest.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 8e38ed0..41189a4 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -69,14 +69,14 @@ public class UsbPlayer implements Device { } //**********search method************* - private boolean isAllAudio() { + public boolean isAllAudio() { String song = ""; boolean flag = true; 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") | song.equals(".wav")) { + if (song.equals(".mp3") ) { flag = true; } else { flag = false; diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 2a613fb..5f09063 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -242,5 +242,22 @@ 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 isAllAudioOptions() { + UsbPlayer up1 = new UsbPlayer(); + //up1.GoTo("Musik 03.mp3"); + + return Stream.of( + Arguments.of("Go to Song : Musik 03.mp3 ", up1.isAllAudio(), true) + + ); + } + } \ No newline at end of file