Browse Source

PullRequest for RadioPlayer function prev

feature-pr-rp_prev
Jan Ortner 3 years ago
parent
commit
1f04f62a72
  1. 5
      src/main/java/device/RadioPlayer.java
  2. 8
      src/test/java/device/RadioPlayerTest.java

5
src/main/java/device/RadioPlayer.java

@ -56,7 +56,10 @@ public class RadioPlayer implements Device {
@Override @Override
public void prev() { public void prev() {
int currentIndex=Playlist.indexOf(playTrack);
int nextIndex=Playlist.size()-1;
if(currentIndex!=0){nextIndex=(currentIndex-1);}
playTrack=Playlist.get(nextIndex);
} }
@Override @Override

8
src/test/java/device/RadioPlayerTest.java

@ -47,12 +47,16 @@ class RadioPlayerTest {
int currentIndex=rp.Playlist.indexOf(rp.playTrack); int currentIndex=rp.Playlist.indexOf(rp.playTrack);
assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size()));
} }
/*
@Test @Test
void prev() { void prev() {
}
rp.prev();
int currentIndex=rp.Playlist.indexOf(rp.playTrack);
assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size()));
}
/*
@Test @Test
void getInfoText() { void getInfoText() {
} }

Loading…
Cancel
Save