Browse Source

Merge commit '77768e5230a252ffb2657e59465d5df7cded6c61' into HEAD

feature-pr-cdPlayerNextTest
Jenkins 3 years ago
parent
commit
c2d338064b
  1. 7
      src/main/java/device/usbPlayer/UsbPlayer.java
  2. 23
      src/test/java/device/usbPlayer/UsbPlayerTest.java

7
src/main/java/device/usbPlayer/UsbPlayer.java

@ -118,7 +118,12 @@ public class UsbPlayer implements Device {
@Override
public void prev() {
int currentIdex = Playlist.indexOf(playTrack);
int nextIndex = Playlist.size() - 1;
if (currentIdex != 0) {
nextIndex = (currentIdex - 1);
}
playTrack = Playlist.get(nextIndex);
}
@Override

23
src/test/java/device/usbPlayer/UsbPlayerTest.java

@ -114,4 +114,27 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) {
);
}
////////////////
@ParameterizedTest
@MethodSource("PrevOptions")
void PrevTest(String testName, UsbPlayer inputPlay, String expectedResult) {
String current_Track = inputPlay.getPlayTrack();
assertThat(current_Track).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> PrevOptions() {
UsbPlayer up1 = new UsbPlayer();
up1.prev();
UsbPlayer up2 = new UsbPlayer();
for (int i = 1; i < up2.getPlaylist().size(); i++) {//3
up2.prev();
}
return Stream.of(
Arguments.of("From first-Song to last-Song : Musik 03.mp3 ", up1, "Musik 03.mp3"),
Arguments.of("From first-Song to second-Song(Backward) : Musik 02.mp3 ", up2, "Musik 02.mp3")
);
}
}
Loading…
Cancel
Save