Commit 6d4e2137 authored by Clément Stenac's avatar Clément Stenac

Change some test stuff

parent 702ca6c3
...@@ -5,11 +5,11 @@ import native_libvlc_test ...@@ -5,11 +5,11 @@ import native_libvlc_test
class NativeLibvlcTestCase( unittest.TestCase ): class NativeLibvlcTestCase( unittest.TestCase ):
def testException( self ): def testException( self ):
"""Checks libvlc_exception""" """[LibVLC] Checks libvlc_exception"""
native_libvlc_test.exception_test() native_libvlc_test.exception_test()
def testStartup( self ): def testStartup( self ):
"""Checks creation/destroy of libvlc""" """[LibVLC] Checks creation/destroy of libvlc"""
native_libvlc_test.create_destroy() native_libvlc_test.create_destroy()
def testPlaylist( self ): def testPlaylist( self ):
"""Checks basic playlist interaction""" """[LibVLC] Checks basic playlist interaction"""
native_libvlc_test.playlist_test() native_libvlc_test.playlist_test()
...@@ -3,10 +3,6 @@ import unittest ...@@ -3,10 +3,6 @@ import unittest
class BaseTestCase( unittest.TestCase ): class BaseTestCase( unittest.TestCase ):
def testStartup(self): def testStartup(self):
"""Checks that VLC starts""" """[PyMC] Check that VLC starts"""
mc = vlc.MediaControl( ['--quiet']) mc = vlc.MediaControl( ['--quiet'])
mc.exit() mc.exit()
# def testHelp(self):
# """Check help string"""
# mc=vlc.MediaControl( [ '--help'] )
...@@ -4,7 +4,7 @@ import unittest ...@@ -4,7 +4,7 @@ import unittest
# FIXME: How to avoid creating / killing vlc for each test method ? # FIXME: How to avoid creating / killing vlc for each test method ?
class VariablesTestCase( unittest.TestCase ): class VariablesTestCase( unittest.TestCase ):
"""Test misc variables interaction""" """[PyMC] Test misc variables interaction"""
def setUp( self ): def setUp( self ):
self.mc = vlc.MediaControl( [ '--quiet'] ) self.mc = vlc.MediaControl( [ '--quiet'] )
...@@ -12,7 +12,7 @@ class VariablesTestCase( unittest.TestCase ): ...@@ -12,7 +12,7 @@ class VariablesTestCase( unittest.TestCase ):
self.mc.exit() self.mc.exit()
def testSimple( self ): def testSimple( self ):
"""Test simple add/remove""" """[PyMC] Check simple add"""
assert len( self.mc.playlist_get_list() ) == 0 assert len( self.mc.playlist_get_list() ) == 0
self.mc.playlist_add_item( "test" ) self.mc.playlist_add_item( "test" )
assert len( self.mc.playlist_get_list() ) == 1 assert len( self.mc.playlist_get_list() ) == 1
...@@ -4,7 +4,7 @@ import unittest ...@@ -4,7 +4,7 @@ import unittest
# FIXME: How to avoid creating / killing vlc for each test method ? # FIXME: How to avoid creating / killing vlc for each test method ?
class VariablesTestCase( unittest.TestCase ): class VariablesTestCase( unittest.TestCase ):
"""Test misc variables interaction""" """[PyMC] Test misc variables interaction"""
def setUp( self ): def setUp( self ):
self.mc = vlc.MediaControl( [ '--quiet'] ) self.mc = vlc.MediaControl( [ '--quiet'] )
# FIXME ! - Get this through children test # FIXME ! - Get this through children test
...@@ -18,20 +18,20 @@ class VariablesTestCase( unittest.TestCase ): ...@@ -18,20 +18,20 @@ class VariablesTestCase( unittest.TestCase ):
# The Python binding can't create variables, so just get default ones # The Python binding can't create variables, so just get default ones
def testInt( self ): def testInt( self ):
"""Get/Set integer variable""" """[PyMC] Get/Set integer variable"""
assert self.libvlc.get( "width" ) == 0 assert self.libvlc.get( "width" ) == 0
self.libvlc.set( "width", 42 ) self.libvlc.set( "width", 42 )
assert self.libvlc.get( 'width' ) == 42 assert self.libvlc.get( 'width' ) == 42
# FIXME: Python binding should listen to return value and raise exception # FIXME: Python binding should listen to return value and raise exception
def testInvalidInt( self ): def testInvalidInt( self ):
"""Get/Set invalid integer""" """[PyMC] Get/Set invalid integer"""
self.libvlc.set( "width" , 5 ) self.libvlc.set( "width" , 5 )
self.libvlc.set( "width", "foo" ) self.libvlc.set( "width", "foo" )
assert self.libvlc.get( "width" ) == -1 assert self.libvlc.get( "width" ) == -1
def testString( self ): def testString( self ):
"""Get/Set string variable""" """[PyMC] Get/Set string variable"""
assert self.libvlc.get( "open" ) == '' assert self.libvlc.get( "open" ) == ''
self.libvlc.set( "open", "foo" ) self.libvlc.set( "open", "foo" )
assert self.libvlc.get( "open" ) == "foo" assert self.libvlc.get( "open" ) == "foo"
......
...@@ -46,24 +46,37 @@ static PyObject *playlist_test( PyObject *self, PyObject *args ) ...@@ -46,24 +46,37 @@ static PyObject *playlist_test( PyObject *self, PyObject *args )
{ {
libvlc_instance_t *p_instance; libvlc_instance_t *p_instance;
char *argv[] = { "vlc", "--quiet" }; char *argv[] = { "vlc", "--quiet" };
int i_id; int i_id, i_playing, i_items;
libvlc_exception_t exception; libvlc_exception_t exception;
libvlc_exception_init( &exception ); libvlc_exception_init( &exception );
p_instance = libvlc_new( 2, argv, &exception ); p_instance = libvlc_new( 2, argv, &exception );
/* Initial status */
libvlc_playlist_play( p_instance, 0, 0, argv, &exception ); libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
ASSERT( libvlc_exception_raised( &exception ), ASSERT( libvlc_exception_raised( &exception ),
"Playlist empty and exception not raised" ); "Playlist empty and exception not raised" );
i_playing = libvlc_playlist_isplaying( p_instance, &exception );
ASSERT_EXCEPTION;
ASSERT( i_playing == 0, "Playlist shouldn't be running" );
i_items = libvlc_playlist_items_count( p_instance, &exception );
ASSERT_EXCEPTION;
ASSERT( i_items == 0, "Playlist should be empty" );
/* Add 1 item */
libvlc_exception_clear( &exception ); libvlc_exception_clear( &exception );
i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception ); i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
ASSERT_EXCEPTION; ASSERT_EXCEPTION;
ASSERT( i_id > 0 , "Returned identifier is <= 0" ); ASSERT( i_id > 0 , "Returned identifier is <= 0" );
i_items = libvlc_playlist_items_count( p_instance, &exception );
ASSERT_EXCEPTION;
ASSERT( i_items == 1, "Playlist should have 1 item" );
i_playing = libvlc_playlist_isplaying( p_instance, &exception );
ASSERT_EXCEPTION;
ASSERT( i_playing == 0, "Playlist shouldn't be running" );
/* */
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
......
...@@ -39,11 +39,21 @@ def get_ldflags(): ...@@ -39,11 +39,21 @@ def get_ldflags():
# To compile in a local vlc tree # To compile in a local vlc tree
native_libvlc_test = Extension( 'native_libvlc_test', native_libvlc_test = Extension( 'native_libvlc_test',
sources = ['native_libvlc/native_libvlc_test.c'], sources = ['native/libvlc.c'],
include_dirs = ['../include', '../', '/usr/win32/include' ], include_dirs = ['../include', '../', '/usr/win32/include' ],
extra_objects = [ '../lib/libvlc_pic.a' ], extra_objects = [ '../lib/libvlc_pic.a' ],
extra_compile_args = get_cflags(), extra_compile_args = get_cflags(),
extra_link_args = [ '-L../..' ] + get_ldflags(), extra_link_args = [ '-L../..' ] + get_ldflags(),
) )
native_stats_test = Extension( 'native_stats_test',
sources = ['native/stats.c'],
include_dirs = ['../include', '../', '/usr/win32/include' ],
extra_objects = [ '../lib/libvlc_pic.a' ],
extra_compile_args = get_cflags(),
extra_link_args = [ '-L../..' ] + get_ldflags(),
)
setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] ) setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] )
setup( name = 'native_stats_test' ,version = '1242', ext_modules = [ native_stats_test ] )
#! /bin/sh #! /bin/sh
cd .. cd ..
export PYTHONPATH=$PYTHONPATH:bindings/python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3 export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3
python test/test.py -v python test/test.py -v
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment