]> git.sesse.net Git - vlc/blob - bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java
jvlc: download a sample file to run tests, if needed
[vlc] / bindings / java / core / src / test / java / org / videolan / jvlc / internal / MediaListTest.java
1 /*****************************************************************************
2  * MediaListTest.java: VLC Java Bindings
3  *****************************************************************************
4  * Copyright (C) 1998-2008 the VideoLAN team
5  *
6  * Authors: Filippo Carone <filippo@carone.org>
7  *
8  *
9  * $Id $
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 package org.videolan.jvlc.internal;
27
28 import junit.framework.Assert;
29
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;
34
35
36 public class MediaListTest extends AbstractVLCInternalTest
37 {
38
39     @Test
40     public void mediaListNew()
41     {
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);
46     }
47
48     @Test
49     public void mediaListAddMediaDescriptor()
50     {
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(
55             libvlcInstance,
56             mrl,
57             exception);
58         libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
59         Assert.assertEquals(0, exception.raised);
60     }
61
62     @Test
63     public void mediaListCountTest()
64     {
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(
69             libvlcInstance,
70             mrl,
71             exception);
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);
76
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);
81     }
82
83     @Test
84     public void mediaListEventManagerTest()
85     {
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);
90     }
91
92     @Test
93     public void mediaListIndexOfItemTest()
94     {
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(
99             libvlcInstance,
100             mrl,
101             exception);
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);
106     }
107
108     @Test
109     public void mediaListRemoveIndexTest()
110     {
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(
115             libvlcInstance,
116             mrl,
117             exception);
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);
121     }
122
123     @Test
124     public void mediaListRemoveIndexTest2()
125     {
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(
130             libvlcInstance,
131             mrl,
132             exception);
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);
136
137         libvlc_media = libvlc.libvlc_media_new(
138             libvlcInstance,
139             mrl,
140             exception);
141         libvlc.libvlc_media_list_add_media(mediaList, libvlc_media, exception);
142         libvlc.libvlc_media_list_remove_index(mediaList, 0, exception);
143     }   
144     
145 }