1 /*****************************************************************************
2 * MediaListTest.java: VLC Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2008 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 package org.videolan.jvlc.internal;
28 import junit.framework.Assert;
30 import org.junit.Test;
31 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
32 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList;
33 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
36 public class MediaListTest extends AbstractVLCInternalTest
40 public void mediaListNew()
42 libvlc_exception_t exception = new libvlc_exception_t();
43 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
44 Assert.assertNotNull(mediaList);
45 Assert.assertEquals(0, exception.raised);
49 public void mediaListAddMediaDescriptor()
51 libvlc_exception_t exception = new libvlc_exception_t();
52 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
53 String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath();
54 LibVlcMediaDescriptor libvlc_media = libvlc.libvlc_media_new(
58 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
59 Assert.assertEquals(0, exception.raised);
63 public void mediaListCountTest()
65 libvlc_exception_t exception = new libvlc_exception_t();
66 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
67 String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath();
68 LibVlcMediaDescriptor libvlc_media = libvlc.libvlc_media_new(
72 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
73 int result = libvlc.libvlc_media_list_count(mediaList, exception);
74 Assert.assertEquals(1, result);
75 Assert.assertEquals(0, exception.raised);
77 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
78 result = libvlc.libvlc_media_list_count(mediaList, exception);
79 Assert.assertEquals(2, result);
80 Assert.assertEquals(0, exception.raised);
84 public void mediaListEventManagerTest()
86 libvlc_exception_t exception = new libvlc_exception_t();
87 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
88 Assert.assertNotNull(libvlc.libvlc_media_list_event_manager(mediaList, exception));
89 Assert.assertEquals(0, exception.raised);
93 public void mediaListIndexOfItemTest()
95 libvlc_exception_t exception = new libvlc_exception_t();
96 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
97 String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath();
98 LibVlcMediaDescriptor libvlc_media = libvlc.libvlc_media_new(
102 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
103 int index = libvlc.libvlc_media_list_index_of_item(mediaList, libvlc_media, exception);
104 Assert.assertEquals(0, index);
105 Assert.assertEquals(0, exception.raised);
109 public void mediaListRemoveIndexTest()
111 libvlc_exception_t exception = new libvlc_exception_t();
112 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
113 String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath();
114 LibVlcMediaDescriptor libvlc_media = libvlc.libvlc_media_new(
118 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
119 libvlc.libvlc_media_list_remove_index(mediaList, 0, exception);
120 Assert.assertEquals(0, exception.raised);
124 public void mediaListRemoveIndexTest2()
126 libvlc_exception_t exception = new libvlc_exception_t();
127 LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
128 String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath();
129 LibVlcMediaDescriptor libvlc_media = libvlc.libvlc_media_new(
133 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
134 libvlc.libvlc_media_list_remove_index(mediaList, 0, exception);
135 Assert.assertEquals(0, exception.raised);
137 libvlc_media = libvlc.libvlc_media_new(
141 libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
142 libvlc.libvlc_media_list_remove_index(mediaList, 0, exception);