Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
5f584e4c
Commit
5f584e4c
authored
Mar 21, 2008
by
Filippo Carone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more unit tests
parent
5a0c3a51
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
248 additions
and
1 deletion
+248
-1
bindings/java/core/src/main/java/org/videolan/jvlc/MediaDescriptor.java
...core/src/main/java/org/videolan/jvlc/MediaDescriptor.java
+1
-0
bindings/java/core/src/main/java/org/videolan/jvlc/MediaList.java
.../java/core/src/main/java/org/videolan/jvlc/MediaList.java
+49
-1
bindings/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java
...s/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java
+55
-0
bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java
...a/core/src/test/java/org/videolan/jvlc/MediaListTest.java
+106
-0
bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java
...c/test/java/org/videolan/jvlc/internal/MediaListTest.java
+37
-0
No files found.
bindings/java/core/src/main/java/org/videolan/jvlc/MediaDescriptor.java
View file @
5f584e4c
...
...
@@ -84,6 +84,7 @@ public class MediaDescriptor
}
/**
* Returns the instance.
* @return the instance
...
...
bindings/java/core/src/main/java/org/videolan/jvlc/MediaList.java
View file @
5f584e4c
...
...
@@ -25,6 +25,10 @@
package
org.videolan.jvlc
;
import
java.util.ArrayList
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
org.videolan.jvlc.internal.LibVlc.LibVlcEventManager
;
import
org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor
;
import
org.videolan.jvlc.internal.LibVlc.LibVlcMediaList
;
...
...
@@ -40,6 +44,8 @@ public class MediaList
private
final
LibVlcEventManager
eventManager
;
private
List
<
String
>
items
=
new
ArrayList
<
String
>();
public
MediaList
(
JVLC
jvlc
)
{
this
.
jvlc
=
jvlc
;
...
...
@@ -56,6 +62,11 @@ public class MediaList
public
void
addMediaDescriptor
(
MediaDescriptor
descriptor
)
{
if
(
items
.
contains
(
descriptor
.
getMrl
()))
{
return
;
}
items
.
add
(
descriptor
.
getMrl
());
libvlc_exception_t
exception
=
new
libvlc_exception_t
();
jvlc
.
getLibvlc
().
libvlc_media_list_add_media_descriptor
(
instance
,
descriptor
.
getInstance
(),
exception
);
}
...
...
@@ -79,10 +90,33 @@ public class MediaList
return
new
MediaDescriptor
(
jvlc
,
descriptor
);
}
public
void
remove
(
int
index
)
/**
* @param index The index of the media to remove
* @return True if the media was successfully removed, false otherwise.
*/
public
boolean
removeMedia
(
int
index
)
{
libvlc_exception_t
exception
=
new
libvlc_exception_t
();
jvlc
.
getLibvlc
().
libvlc_media_list_remove_index
(
instance
,
index
,
exception
);
if
(
exception
.
raised
==
0
)
{
items
.
remove
(
index
);
return
true
;
}
return
false
;
}
/**
* @param media The media descriptor mrl
*/
public
boolean
removeMedia
(
String
mrl
)
{
int
index
=
items
.
indexOf
(
mrl
);
if
(
index
==
-
1
)
{
return
false
;
}
return
removeMedia
(
index
);
}
public
void
insertMediaDescriptor
(
MediaDescriptor
descriptor
,
int
index
)
...
...
@@ -112,4 +146,18 @@ public class MediaList
return
instance
;
}
/**
* @param mediaDescriptor
*/
public
boolean
removeMedia
(
MediaDescriptor
mediaDescriptor
)
{
String
mrl
=
mediaDescriptor
.
getMrl
();
int
index
=
items
.
indexOf
(
mrl
);
if
(
index
==
-
1
)
{
return
false
;
}
return
removeMedia
(
index
);
}
}
bindings/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java
0 → 100644
View file @
5f584e4c
/*****************************************************************************
* JVLCTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package
org.videolan.jvlc
;
import
junit.framework.Assert
;
import
org.junit.Test
;
public
class
JVLCTest
{
String
mrl
=
getClass
().
getResource
(
"/raffa_voice.ogg"
).
getFile
();
@Test
public
void
jvlcNew
()
{
JVLC
jvlc
=
new
JVLC
();
Assert
.
assertNotNull
(
jvlc
.
getMediaList
());
}
@Test
public
void
jvlcPlay
()
{
JVLC
jvlc
=
new
JVLC
();
MediaInstance
instance
=
jvlc
.
play
(
mrl
);
Assert
.
assertNotNull
(
instance
);
}
}
bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java
0 → 100644
View file @
5f584e4c
/*****************************************************************************
* MediaListTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package
org.videolan.jvlc
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
public
class
MediaListTest
{
private
JVLC
jvlc
;
private
String
mrl
=
getClass
().
getResource
(
"/raffa_voice.ogg"
).
getFile
();
@Before
public
void
setup
()
{
jvlc
=
new
JVLC
();
}
@Test
public
void
mediaListAddMedia
()
{
MediaList
mlist
=
new
MediaList
(
jvlc
);
mlist
.
addMedia
(
mrl
);
Assert
.
assertEquals
(
1
,
mlist
.
itemsCount
());
}
@Test
public
void
mediaListAddMedia2
()
{
MediaList
mlist
=
new
MediaList
(
jvlc
);
mlist
.
addMedia
(
mrl
);
Assert
.
assertEquals
(
1
,
mlist
.
itemsCount
());
mlist
.
addMedia
(
mrl
);
Assert
.
assertEquals
(
1
,
mlist
.
itemsCount
());
mlist
.
addMediaDescriptor
(
new
MediaDescriptor
(
jvlc
,
mrl
));
Assert
.
assertEquals
(
1
,
mlist
.
itemsCount
());
mlist
.
addMedia
(
"non-existing"
);
Assert
.
assertEquals
(
2
,
mlist
.
itemsCount
());
}
@Test
public
void
mediaListRemoveMedia
()
{
MediaList
mlist
=
new
MediaList
(
jvlc
);
mlist
.
addMedia
(
mrl
);
Assert
.
assertEquals
(
1
,
mlist
.
itemsCount
());
mlist
.
removeMedia
(
0
);
Assert
.
assertEquals
(
0
,
mlist
.
itemsCount
());
}
@Test
public
void
mediaListRemoveMedia2
()
{
MediaList
mlist
=
new
MediaList
(
jvlc
);
mlist
.
addMedia
(
mrl
);
Assert
.
assertEquals
(
1
,
mlist
.
itemsCount
());
mlist
.
removeMedia
(
0
);
Assert
.
assertEquals
(
0
,
mlist
.
itemsCount
());
mlist
.
addMedia
(
mrl
);
mlist
.
removeMedia
(
0
);
Assert
.
assertEquals
(
0
,
mlist
.
itemsCount
());
mlist
.
addMediaDescriptor
(
new
MediaDescriptor
(
jvlc
,
mrl
));
mlist
.
removeMedia
(
0
);
Assert
.
assertEquals
(
0
,
mlist
.
itemsCount
());
mlist
.
addMediaDescriptor
(
new
MediaDescriptor
(
jvlc
,
mrl
));
mlist
.
removeMedia
(
mrl
);
Assert
.
assertEquals
(
0
,
mlist
.
itemsCount
());
mlist
.
addMediaDescriptor
(
new
MediaDescriptor
(
jvlc
,
mrl
));
mlist
.
removeMedia
(
new
MediaDescriptor
(
jvlc
,
mrl
));
Assert
.
assertEquals
(
0
,
mlist
.
itemsCount
());
}
}
bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListTest.java
View file @
5f584e4c
...
...
@@ -125,4 +125,41 @@ public class MediaListTest
Assert
.
assertEquals
(
0
,
exception
.
raised
);
}
@Test
public
void
mediaListRemoveIndexTest
()
{
libvlc_exception_t
exception
=
new
libvlc_exception_t
();
LibVlcMediaList
mediaList
=
libvlc
.
libvlc_media_list_new
(
libvlcInstance
,
exception
);
String
mrl
=
this
.
getClass
().
getResource
(
"/raffa_voice.ogg"
).
getPath
();
LibVlcMediaDescriptor
libvlc_media_descriptor
=
libvlc
.
libvlc_media_descriptor_new
(
libvlcInstance
,
mrl
,
exception
);
libvlc
.
libvlc_media_list_add_media_descriptor
(
mediaList
,
libvlc_media_descriptor
,
exception
);
libvlc
.
libvlc_media_list_remove_index
(
mediaList
,
0
,
exception
);
Assert
.
assertEquals
(
0
,
exception
.
raised
);
}
@Test
public
void
mediaListRemoveIndexTest2
()
{
libvlc_exception_t
exception
=
new
libvlc_exception_t
();
LibVlcMediaList
mediaList
=
libvlc
.
libvlc_media_list_new
(
libvlcInstance
,
exception
);
String
mrl
=
this
.
getClass
().
getResource
(
"/raffa_voice.ogg"
).
getPath
();
LibVlcMediaDescriptor
libvlc_media_descriptor
=
libvlc
.
libvlc_media_descriptor_new
(
libvlcInstance
,
mrl
,
exception
);
libvlc
.
libvlc_media_list_add_media_descriptor
(
mediaList
,
libvlc_media_descriptor
,
exception
);
libvlc
.
libvlc_media_list_remove_index
(
mediaList
,
0
,
exception
);
Assert
.
assertEquals
(
0
,
exception
.
raised
);
libvlc_media_descriptor
=
libvlc
.
libvlc_media_descriptor_new
(
libvlcInstance
,
mrl
,
exception
);
libvlc
.
libvlc_media_list_add_media_descriptor
(
mediaList
,
libvlc_media_descriptor
,
exception
);
libvlc
.
libvlc_media_list_remove_index
(
mediaList
,
0
,
exception
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment