mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Test getItem(int)
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| package org.schabi.newpipe.player.playqueue; | ||||
|  | ||||
| import org.junit.Before; | ||||
| import org.junit.BeforeClass; | ||||
| import org.junit.Test; | ||||
| import org.junit.experimental.runners.Enclosed; | ||||
| import org.junit.runner.RunWith; | ||||
| @@ -10,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamType; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import static org.junit.Assert.assertEquals; | ||||
| 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 { | ||||
|         private final PlayQueueItem item1 = makeItemWithUrl("URL_1"); | ||||
|         private final PlayQueueItem item2 = makeItemWithUrl("URL_2"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Eric Xu
					Eric Xu