Browse Source

Merge commit 'fce439259bcd626f61070c1e8f108d5c0e814772' into HEAD

feature-pr-getVolume
Jenkins 3 years ago
parent
commit
5b3231fbe8
  1. 8
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 31
      src/test/java/device/cdPlayer/CDPlayerTest.java

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

@ -44,8 +44,10 @@ public class CDPlayer implements Device {
public void next() {
List<String> playList = Arrays.asList(loadedCD.getPlayList());
int indexOfActualPlayTrack=playList.indexOf(actualPlayTrack);
this.actualPlayTrack=playList.get(indexOfActualPlayTrack +1);
int indexOfNextPlayTrack=(indexOfActualPlayTrack+1)%loadedCD.getPlayList().length;
//System.out.println("actualIndex= "+indexOfActualPlayTrack);
this.actualPlayTrack=playList.get(indexOfNextPlayTrack );
//System.out.println("nextSong= "+actualPlayTrack);
}
@Override
@ -65,7 +67,7 @@ public class CDPlayer implements Device {
@Override
public String[] getItemList() {
return new String[0];
return loadedCD.getPlayList();
}

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

@ -156,10 +156,17 @@ class CDPlayerTest {
@ParameterizedTest
@MethodSource("nextTestData")
void nextTest(String testName,String testDirection, CDPlayer _cdPlayer,int anzClicks, String expectedResult){
if(testDirection.equals("SecondSongSelected")|| testDirection.equals("ThirdSongSelected")){
for (int i = 0; i < anzClicks; i++) {
_cdPlayer.next();
}
if(testDirection.equals("SecondSongSelected")){
assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult);
}
if(testDirection.equals("FirstSongSelected")){
for (int i = 0; i <anzClicks; i++) {
_cdPlayer.next();
}
assertThat(_cdPlayer.getActualPlayTrack()).describedAs(testName).isEqualTo(expectedResult);
}
}
@ -168,13 +175,25 @@ class CDPlayerTest {
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
CD audioCD=new CD("Audio",audioPlayList);
CDPlayer cdPlayer=new CDPlayer();
cdPlayer.tapOnCdFlap();
cdPlayer.setCD(audioCD);
cdPlayer.tapOnCdFlap();
CDPlayer cdPlayer1=new CDPlayer();
cdPlayer1.tapOnCdFlap();
cdPlayer1.setCD(audioCD);
cdPlayer1.tapOnCdFlap();
CDPlayer cdPlayer2=new CDPlayer();
cdPlayer2.tapOnCdFlap();
cdPlayer2.setCD(audioCD);
cdPlayer2.tapOnCdFlap();
CDPlayer cdPlayer3=new CDPlayer();
cdPlayer3.tapOnCdFlap();
cdPlayer3.setCD(audioCD);
cdPlayer3.tapOnCdFlap();
return Stream.of(
Arguments.of("[getActualPlayTrack() after 1x next() starting by firstSong] => SecondSongSelected","SecondSongSelected", cdPlayer, 1, cdPlayer.getSongByNumber(1))
Arguments.of("[getActualPlayTrack() after 1x next() starting by firstSong] => SecondSongSelected","SecondSongSelected", cdPlayer1, 1, cdPlayer1.getSongByNumber(1)),
Arguments.of("[getActualPlayTrack() after 2x next() starting by firstSong] => ThirdSongSelected","ThirdSongSelected" ,cdPlayer2,2,cdPlayer2.getSongByNumber(2)),
Arguments.of("[getActualPlayTrack() after 1x next() starting by lastSong] => FirstSongSelected","FirstSongSelected", cdPlayer3,cdPlayer3.getItemList().length,cdPlayer3.getSongByNumber(0))
);
}
Loading…
Cancel
Save