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.Test;
32 public class MediaListTest extends AbstractJVLCTest
36 public void mediaListAddMedia()
38 MediaList mlist = new MediaList(jvlc);
40 Assert.assertEquals(1, mlist.size());
44 public void mediaListAddMedia2()
46 MediaList mlist = new MediaList(jvlc);
48 Assert.assertEquals(1, mlist.size());
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());
58 public void mediaListRemoveMedia()
60 MediaList mlist = new MediaList(jvlc);
62 Assert.assertEquals(1, mlist.size());
64 Assert.assertEquals(0, mlist.size());
68 public void mediaListRemoveMedia2()
70 MediaList mlist = new MediaList(jvlc);
72 Assert.assertEquals(1, mlist.size());
74 Assert.assertEquals(0, mlist.size());
78 Assert.assertEquals(0, mlist.size());
80 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
82 Assert.assertEquals(0, mlist.size());
84 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
85 mlist.removeMedia(mrl);
86 Assert.assertEquals(0, mlist.size());
88 mlist.addMedia(new MediaDescriptor(jvlc, mrl));
89 mlist.removeMedia(new MediaDescriptor(jvlc, mrl));
90 Assert.assertEquals(0, mlist.size());
94 public void mediaListRemoveNonExistingMedia()
96 MediaList mlist = new MediaList(jvlc);
97 boolean result = mlist.removeMedia(3);
98 Assert.assertFalse(result);
102 public void mediaListIndexOfNonExistingMediaDescriptor()
104 MediaList mlist = new MediaList(jvlc);
105 MediaDescriptor md = new MediaDescriptor(jvlc, "dummy");
106 int result = mlist.indexOf(md);
107 Assert.assertEquals(-1, result);
110 @Test(expected = IndexOutOfBoundsException.class)
111 public void mediaListGetMediaDesciptorAtInvalidIndex()
113 MediaList mlist = new MediaList(jvlc);
114 mlist.getMediaDescriptorAtIndex(5);
117 @Test(expected = IndexOutOfBoundsException.class)
118 public void mediaListGetMediaDesciptorAtInvalidIndex2()
120 MediaList mlist = new MediaList(jvlc);
121 mlist.getMediaDescriptorAtIndex(-5);
124 @Test(expected = IndexOutOfBoundsException.class)
125 public void mediaListGetMediaDesciptorAtInvalidIndex3()
127 MediaList mlist = new MediaList(jvlc);
128 mlist.getMediaDescriptorAtIndex(0);