Browse Source

test+productive code for case:3 of method prev in CDPlayer created.

feature-pr-cdPlayerPrev
JPANZO 3 years ago
parent
commit
d5b13dadc8
  1. 8
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 9
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

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

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

@ -202,17 +202,14 @@ class CDPlayerTest {
void prevTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, String expectedResult){ void prevTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, String expectedResult){
if(testDirection.equals("StartingBySecondSong")) { if(testDirection.equals("StartingBySecondSong")) {
_cdPlayer.next(); _cdPlayer.next();
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.prev();
}
} }
if(testDirection.equals("StartingByThirdSong")) { if(testDirection.equals("StartingByThirdSong")) {
_cdPlayer.next(); _cdPlayer.next();
_cdPlayer.next(); _cdPlayer.next();
}
for (int i = 0; i < anzClicks; i++) { for (int i = 0; i < anzClicks; i++) {
_cdPlayer.prev(); _cdPlayer.prev();
} }
}
assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult); assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult);
} }
static Stream<Arguments> prevTestData () { static Stream<Arguments> prevTestData () {
@ -225,10 +222,10 @@ class CDPlayerTest {
cdPlayer1.setCD(audioCD); cdPlayer1.setCD(audioCD);
cdPlayer1.tapOnCdFlap(); cdPlayer1.tapOnCdFlap();
return Stream.of( return Stream.of(
Arguments.of("[getActualPlayTrack() after 1x prev() starting by secondSong] => FirstSongSelected", "StartingBySecondSong", cdPlayer1, 1, cdPlayer1.getSongByNumber(0)), 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 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