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;
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Test;
33 public class MediaListTest
38 private String mrl = getClass().getResource("/raffa_voice.ogg").getFile();
47 public void mediaListAddMedia()
49 MediaList mlist = new MediaList(jvlc);
51 Assert.assertEquals(1, mlist.size());
55 public void mediaListAddMedia2()
57 MediaList mlist = new MediaList(jvlc);
59 Assert.assertEquals(1, mlist.size());
61 Assert.assertEquals(1, mlist.size());
62 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
63 Assert.assertEquals(1, mlist.size());
64 mlist.addMedia("non-existing");
65 Assert.assertEquals(2, mlist.size());
69 public void mediaListRemoveMedia()
71 MediaList mlist = new MediaList(jvlc);
73 Assert.assertEquals(1, mlist.size());
75 Assert.assertEquals(0, mlist.size());
79 public void mediaListRemoveMedia2()
81 MediaList mlist = new MediaList(jvlc);
83 Assert.assertEquals(1, mlist.size());
85 Assert.assertEquals(0, mlist.size());
89 Assert.assertEquals(0, mlist.size());
91 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
93 Assert.assertEquals(0, mlist.size());
95 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
96 mlist.removeMedia(mrl);
97 Assert.assertEquals(0, mlist.size());
99 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
100 mlist.removeMedia(new MediaDescriptor(jvlc, mrl));
101 Assert.assertEquals(0, mlist.size());
105 public void mediaListRemoveNonExistingMedia()
107 MediaList mlist = new MediaList(jvlc);
108 boolean result = mlist.removeMedia(3);
109 Assert.assertFalse(result);
113 public void mediaListIndexOfNonExistingMediaDescriptor()
115 MediaList mlist = new MediaList(jvlc);
116 MediaDescriptor md = new MediaDescriptor(jvlc, "dummy");
117 int result = mlist.indexOf(md);
118 Assert.assertEquals(-1, result);
121 @Test(expected = IndexOutOfBoundsException.class)
122 public void mediaListGetMediaDesciptorAtInvalidIndex()
124 MediaList mlist = new MediaList(jvlc);
125 mlist.getMediaDescriptorAtIndex(5);
128 @Test(expected = IndexOutOfBoundsException.class)
129 public void mediaListGetMediaDesciptorAtInvalidIndex2()
131 MediaList mlist = new MediaList(jvlc);
132 mlist.getMediaDescriptorAtIndex(-5);
135 @Test(expected = IndexOutOfBoundsException.class)
136 public void mediaListGetMediaDesciptorAtInvalidIndex3()
138 MediaList mlist = new MediaList(jvlc);
139 mlist.getMediaDescriptorAtIndex(0);