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. 37
      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;

37
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) {
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() { static Stream<Arguments> louderOptions() {
UsbPlayer up11 = new UsbPlayer(); UsbPlayer up11 = new UsbPlayer();
@ -149,7 +150,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) {
UsbPlayer up2 = new UsbPlayer(); UsbPlayer up2 = new UsbPlayer();
for (int i = 0; i <= 3; i++) { for (int i = 0; i <= 3; i++) {
up2.Louder_10();
up2.Louder_10();
} }
up2.quieter_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) 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) {
@ -194,10 +196,10 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) {
@MethodSource("FindSongOptions") @MethodSource("FindSongOptions")
void findSongTest(String testName, int inputPlay, int expectedResult) { void findSongTest(String testName, int inputPlay, int expectedResult) {
//first case: the song is not in the Album //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); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);
//Second Case: the song is in the album //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); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);
} }
@ -245,21 +247,30 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) {
@ParameterizedTest @ParameterizedTest
@MethodSource("isAllAudioOptions") @MethodSource("isAllAudioOptions")
void isAllAudioTest(String testName, boolean inputTestResult, boolean expectedResult) { void isAllAudioTest(String testName, boolean inputTestResult, boolean expectedResult) {
// String current_Track = inputPlay.getPlayTrack();
// String current_Track = inputPlay.getPlayTrack();
assertThat(inputTestResult).describedAs(testName).isEqualTo(expectedResult); assertThat(inputTestResult).describedAs(testName).isEqualTo(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