Browse Source

Merge commit 'd5b13dadc8b57b1d4ebb73dce23c7b406e771cf9' into HEAD

feature-pr-cdPlayerGetOptions
Jenkins 3 years ago
parent
commit
a71a1e51a1
  1. 9
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 31
      src/test/java/device/cdPlayer/CDPlayerTest.java

9
src/main/java/device/cdPlayer/CDPlayer.java

@ -52,7 +52,14 @@ public class CDPlayer implements Device {
@Override @Override
public void prev() { public void prev() {
List<String> playList = Arrays.asList(loadedCD.getPlayList());
int actualIndex=playList.indexOf(actualPlayTrack);
if(actualIndex>0){
actualIndex-=1;
}else{
actualIndex=0;
}
this.actualPlayTrack=playList.get(actualIndex);
} }
@Override @Override

31
src/test/java/device/cdPlayer/CDPlayerTest.java

@ -197,4 +197,35 @@ class CDPlayerTest {
); );
} }
@ParameterizedTest
@MethodSource("prevTestData")
void prevTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, String expectedResult){
if(testDirection.equals("StartingBySecondSong")) {
_cdPlayer.next();
}
if(testDirection.equals("StartingByThirdSong")) {
_cdPlayer.next();
_cdPlayer.next();
}
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.prev();
}
assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> prevTestData () {
String[] audioPlayList = new String[]{"Audio 01", "Audio 02", "Audio 03", "Audio 04", "Audio 05"};
CD audioCD = new CD("Audio", audioPlayList);
CDPlayer cdPlayer1 = new CDPlayer();
cdPlayer1.tapOnCdFlap();
cdPlayer1.setCD(audioCD);
cdPlayer1.tapOnCdFlap();
return Stream.of(
Arguments.of("[getActualPlayTrack() after 1x prev() starting by secondSong] => FirstSongSelected", "StartingBySecondSong", cdPlayer1, 1, cdPlayer1.getSongByNumber(0)),
Arguments.of("[getActualPlayTrack() after 2x prev() starting by thirdSong] => FirstSongSelected", "StartingByThirdSong", cdPlayer1, 2, cdPlayer1.getSongByNumber(0)),
Arguments.of("[getActualPlayTrack() after 1x prev() starting by firstSong] => FirstSongSelected", "StartingByFirstSong", cdPlayer1, 1, cdPlayer1.getSongByNumber(0))
);
}
} }
Loading…
Cancel
Save