X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bindings%2Fjava%2Fcore%2Fsrc%2Ftest%2Fjava%2Forg%2Fvideolan%2Fjvlc%2Finternal%2FMediaListTest.java;h=ebf5e36f289db5528f49054b2e4d05a32538fb56;hb=940734d9cb1999a247cc4c60b96442c20e804413;hp=d68e1949b9c2b58e186b73e291b59aab60b74ec0;hpb=a19cac2195024dc9992fa582eeb4701602695003;p=vlc diff --git a/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java b/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java index d68e1949b9..ebf5e36f28 100644 --- a/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java +++ b/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java @@ -36,25 +36,26 @@ import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList; import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t; - public class MediaListTest { - private LibVlc libvlc = LibVlc.INSTANCE; + + private LibVlc libvlc = LibVlc.SYNC_INSTANCE; + private LibVlcInstance libvlcInstance; - + @Before public void testSetup() { libvlc_exception_t exception = new libvlc_exception_t(); - libvlcInstance = libvlc.libvlc_new(0, new String[] {}, exception ); + libvlcInstance = libvlc.libvlc_new(0, new String[]{"-I","dummy","--aout=dummy","--vout=dummy"}, exception); } - + @After public void tearDown() { libvlc.libvlc_release(libvlcInstance); } - + @Test public void mediaListNew() { @@ -63,15 +64,102 @@ public class MediaListTest Assert.assertNotNull(mediaList); Assert.assertEquals(0, exception.raised); } - + @Test public void mediaListAddMediaDescriptor() { libvlc_exception_t exception = new libvlc_exception_t(); LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception); String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath(); - LibVlcMediaDescriptor libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new(libvlcInstance, mrl, exception); - libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor , exception); + LibVlcMediaDescriptor libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new( + libvlcInstance, + mrl, + exception); + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); Assert.assertEquals(0, exception.raised); } + + @Test + public void mediaListCountTest() + { + libvlc_exception_t exception = new libvlc_exception_t(); + LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception); + String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath(); + LibVlcMediaDescriptor libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new( + libvlcInstance, + mrl, + exception); + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); + int result = libvlc.libvlc_media_list_count(mediaList, exception); + Assert.assertEquals(1, result); + Assert.assertEquals(0, exception.raised); + + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); + result = libvlc.libvlc_media_list_count(mediaList, exception); + Assert.assertEquals(2, result); + Assert.assertEquals(0, exception.raised); + } + + @Test + public void mediaListEventManagerTest() + { + libvlc_exception_t exception = new libvlc_exception_t(); + LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception); + Assert.assertNotNull(libvlc.libvlc_media_list_event_manager(mediaList, exception)); + Assert.assertEquals(0, exception.raised); + } + + @Test + public void mediaListIndexOfItemTest() + { + libvlc_exception_t exception = new libvlc_exception_t(); + LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception); + String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath(); + LibVlcMediaDescriptor libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new( + libvlcInstance, + mrl, + exception); + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); + int index = libvlc.libvlc_media_list_index_of_item(mediaList, libvlc_media_descriptor, exception); + Assert.assertEquals(0, index); + Assert.assertEquals(0, exception.raised); + } + + @Test + public void mediaListRemoveIndexTest() + { + libvlc_exception_t exception = new libvlc_exception_t(); + LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception); + String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath(); + LibVlcMediaDescriptor libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new( + libvlcInstance, + mrl, + exception); + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); + libvlc.libvlc_media_list_remove_index(mediaList, 0, exception); + Assert.assertEquals(0, exception.raised); + } + + @Test + public void mediaListRemoveIndexTest2() + { + libvlc_exception_t exception = new libvlc_exception_t(); + LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception); + String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath(); + LibVlcMediaDescriptor libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new( + libvlcInstance, + mrl, + exception); + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); + libvlc.libvlc_media_list_remove_index(mediaList, 0, exception); + Assert.assertEquals(0, exception.raised); + + libvlc_media_descriptor = libvlc.libvlc_media_descriptor_new( + libvlcInstance, + mrl, + exception); + libvlc.libvlc_media_list_add_media_descriptor(mediaList, libvlc_media_descriptor, exception); + libvlc.libvlc_media_list_remove_index(mediaList, 0, exception); + } + }