Test getItem(int)
This commit is contained in:
parent
77f6940336
commit
363bbf5fd3
1 changed files with 30 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.player.playqueue;
|
package org.schabi.newpipe.player.playqueue;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.runners.Enclosed;
|
import org.junit.experimental.runners.Enclosed;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -10,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -110,6 +112,34 @@ public class PlayQueueTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class GetItemTests {
|
||||||
|
private static List<PlayQueueItem> streams;
|
||||||
|
private PlayQueue queue;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void init() {
|
||||||
|
streams = new ArrayList<>(Collections.nCopies(5, makeItemWithUrl("OTHER_URL")));
|
||||||
|
streams.set(3, makeItemWithUrl("TARGET_URL"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
queue = mockPlayQueue(0, streams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void inBounds() {
|
||||||
|
assertEquals("TARGET_URL", Objects.requireNonNull(queue.getItem(3)).getUrl());
|
||||||
|
assertEquals("OTHER_URL", Objects.requireNonNull(queue.getItem(1)).getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void outOfBounds() {
|
||||||
|
assertNull(queue.getItem(-1));
|
||||||
|
assertNull(queue.getItem(5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class EqualsTests {
|
public static class EqualsTests {
|
||||||
private final PlayQueueItem item1 = makeItemWithUrl("URL_1");
|
private final PlayQueueItem item1 = makeItemWithUrl("URL_1");
|
||||||
private final PlayQueueItem item2 = makeItemWithUrl("URL_2");
|
private final PlayQueueItem item2 = makeItemWithUrl("URL_2");
|
||||||
|
|
Loading…
Reference in a new issue