]> git.sesse.net Git - vlc/blob - bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java
jvlc: abstract test class added to not-internal tests too
[vlc] / bindings / java / core / src / test / java / org / videolan / jvlc / 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;
27
28 import org.junit.Assert;
29 import org.junit.Test;
30
31
32 public class MediaListTest extends AbstractJVLCTest
33 {
34
35     @Test
36     public void mediaListAddMedia()
37     {
38         MediaList mlist = new MediaList(jvlc);
39         mlist.addMedia(mrl);
40         Assert.assertEquals(1, mlist.size());
41     }
42     
43     @Test
44     public void mediaListAddMedia2()
45     {
46         MediaList mlist = new MediaList(jvlc);
47         mlist.addMedia(mrl);
48         Assert.assertEquals(1, mlist.size());
49         mlist.addMedia(mrl);
50         Assert.assertEquals(1, mlist.size());
51         mlist.addMedia(new MediaDescriptor(jvlc, mrl));
52         Assert.assertEquals(1, mlist.size());
53         mlist.addMedia("non-existing");
54         Assert.assertEquals(2, mlist.size());
55     }
56     
57     @Test
58     public void mediaListRemoveMedia()
59     {
60         MediaList mlist = new MediaList(jvlc);
61         mlist.addMedia(mrl);
62         Assert.assertEquals(1, mlist.size());
63         mlist.removeMedia(0);
64         Assert.assertEquals(0, mlist.size());
65     }
66
67     @Test
68     public void mediaListRemoveMedia2()
69     {
70         MediaList mlist = new MediaList(jvlc);
71         mlist.addMedia(mrl);
72         Assert.assertEquals(1, mlist.size());
73         mlist.removeMedia(0);
74         Assert.assertEquals(0, mlist.size());
75         
76         mlist.addMedia(mrl);
77         mlist.removeMedia(0);
78         Assert.assertEquals(0, mlist.size());
79         
80         mlist.addMedia(new MediaDescriptor(jvlc, mrl));
81         mlist.removeMedia(0);
82         Assert.assertEquals(0, mlist.size());
83         
84         mlist.addMedia(new MediaDescriptor(jvlc, mrl));
85         mlist.removeMedia(mrl);
86         Assert.assertEquals(0, mlist.size());
87         
88         mlist.addMedia(new MediaDescriptor(jvlc, mrl));
89         mlist.removeMedia(new MediaDescriptor(jvlc, mrl));
90         Assert.assertEquals(0, mlist.size());
91     }
92     
93     @Test
94     public void mediaListRemoveNonExistingMedia()
95     {
96         MediaList mlist = new MediaList(jvlc);
97         boolean result = mlist.removeMedia(3);
98         Assert.assertFalse(result);
99     }
100     
101     @Test
102     public void mediaListIndexOfNonExistingMediaDescriptor()
103     {
104         MediaList mlist = new MediaList(jvlc);
105         MediaDescriptor md = new MediaDescriptor(jvlc, "dummy");
106         int result = mlist.indexOf(md);
107         Assert.assertEquals(-1, result);
108     }
109     
110     @Test(expected = IndexOutOfBoundsException.class)
111     public void mediaListGetMediaDesciptorAtInvalidIndex()
112     {
113         MediaList mlist = new MediaList(jvlc);
114         mlist.getMediaDescriptorAtIndex(5);
115     }
116     
117     @Test(expected = IndexOutOfBoundsException.class)
118     public void mediaListGetMediaDesciptorAtInvalidIndex2()
119     {
120         MediaList mlist = new MediaList(jvlc);
121         mlist.getMediaDescriptorAtIndex(-5);
122     }
123     
124     @Test(expected = IndexOutOfBoundsException.class)
125     public void mediaListGetMediaDesciptorAtInvalidIndex3()
126     {
127         MediaList mlist = new MediaList(jvlc);
128         mlist.getMediaDescriptorAtIndex(0);
129     }
130 }