]> git.sesse.net Git - vlc/blob - bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListPlayerTest.java
fix for libvlc_get_input_thread: check for null before locking. fixes #1522
[vlc] / bindings / java / core / src / test / java / org / videolan / jvlc / internal / MediaListPlayerTest.java
1 /*****************************************************************************
2  * MediaListPlayerTest.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.After;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
34 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
35 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
36 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList;
37 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaListPlayer;
38 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
39
40
41 public class MediaListPlayerTest
42 {
43     
44     private LibVlc libvlc = LibVlc.SYNC_INSTANCE;
45
46     private LibVlcInstance libvlcInstance;
47     
48     private String mrl = this.getClass().getResource("/raffa_voice.ogg").getPath();
49
50
51     @Before
52     public void testSetup()
53     {
54         libvlc_exception_t exception = new libvlc_exception_t();
55         libvlcInstance = libvlc.libvlc_new(0, new String[]{}, exception);
56     }
57
58     @After
59     public void tearDown()
60     {
61         libvlc.libvlc_release(libvlcInstance);
62     }
63
64     @Test
65     public void mediaListPlayerNewTest()
66     {
67         libvlc_exception_t exception = new libvlc_exception_t();
68         LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
69         Assert.assertNotNull(mediaListPlayer);
70         Assert.assertEquals(0, exception.raised);
71     }
72     
73     @Test
74     public void mediaListPlayerSetMediaListTest()
75     {
76         libvlc_exception_t exception = new libvlc_exception_t();
77         LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
78         LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
79         libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
80         Assert.assertEquals(0, exception.raised);
81     }
82     
83     @Test
84     public void mediaListPlayerSetMediaListTest2()
85     {
86         libvlc_exception_t exception = new libvlc_exception_t();
87         LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
88         LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
89         LibVlcMediaDescriptor mediaDescriptor = libvlc.libvlc_media_descriptor_new(libvlcInstance, mrl, exception);
90         libvlc.libvlc_media_list_add_media_descriptor(mediaList, mediaDescriptor, exception);
91         libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
92         Assert.assertEquals(0, exception.raised);
93     }
94     
95     @Test
96     public void mediaListPlayerIsPlayingTest()
97     {
98         libvlc_exception_t exception = new libvlc_exception_t();
99         LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
100         int result = libvlc.libvlc_media_list_player_is_playing(mediaListPlayer, exception);
101         Assert.assertEquals(0, result);
102         Assert.assertEquals(0, exception.raised);
103     }
104
105 }