X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=test%2Fnative%2Flibvlc.c;h=35564a344d7b7e85add0cc6274dd733e37c19ea1;hb=55f19bbcf48c27ef29687d52bb113ccd0babb001;hp=b29ed3303e8a2343dab66fca58526b1296c234a3;hpb=8444ce1225006facbe1b6742f8b864c66a64fe0d;p=vlc diff --git a/test/native/libvlc.c b/test/native/libvlc.c index b29ed3303e..35564a344d 100644 --- a/test/native/libvlc.c +++ b/test/native/libvlc.c @@ -1,51 +1,81 @@ #include "../pyunit.h" #include -static PyObject *exception_test( PyObject *self, PyObject *args ) +PyObject *exception_test( PyObject *self, PyObject *args ) { - libvlc_exception_t exception; + libvlc_exception_t exception; - libvlc_exception_init( &exception ); - ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" ); - ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" ); + libvlc_exception_init( &exception ); + ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" ); + ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" ); - libvlc_exception_raise( &exception, NULL ); - ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" ); - ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); + libvlc_exception_raise( &exception, NULL ); + ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" ); + ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); - libvlc_exception_raise( &exception, "test" ); - ASSERT( libvlc_exception_get_message( &exception), "No Message" ); - ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); + libvlc_exception_raise( &exception, "test" ); + ASSERT( libvlc_exception_get_message( &exception), "No Message" ); + ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); - libvlc_exception_clear( &exception ); - ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" ); + libvlc_exception_clear( &exception ); + ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" ); - Py_INCREF( Py_None ); - return Py_None; + Py_INCREF( Py_None ); + return Py_None; } -static PyObject *create_destroy( PyObject *self, PyObject *args ) +PyObject *create_destroy( PyObject *self, PyObject *args ) { - libvlc_instance_t *p_instance; - char *argv[] = { "vlc", "--quiet" }; + libvlc_instance_t *p_i1, *p_i2; + char *argv1[] = { "vlc", "--quiet" }; + char *argv2[]= { "vlc", "-vvv" }; + int id1,id2; + + printf( "\n" ); libvlc_exception_t exception; libvlc_exception_init( &exception ); - p_instance = libvlc_new( 2, argv, &exception ); + /* Create and destroy a single instance */ + fprintf( stderr, "Create 1\n" ); + p_i1 = libvlc_new( 2, argv1, &exception ); + ASSERT( p_i1 != NULL, "Instance creation failed" ); + ASSERT_NOEXCEPTION; + id1 = libvlc_get_vlc_id( p_i1 ); + libvlc_release( p_i1, &exception ); + ASSERT_NOEXCEPTION; - ASSERT( p_instance != NULL, "Instance creation failed" ); + /* Create and destroy two instances */ + fprintf( stderr, "Create 2\n" ); + p_i1 = libvlc_new( 2, argv1, &exception ); + ASSERT( p_i1 != NULL, "Instance creation failed" ); + ASSERT_NOEXCEPTION; + + fprintf( stderr, "Create 3\n" ); + p_i2 = libvlc_new( 2, argv2, &exception ); + ASSERT( p_i2 != NULL, "Instance creation failed" ); + ASSERT_NOEXCEPTION; + + fprintf( stderr, "Destroy 1\n" ); + libvlc_release( p_i1, &exception ); + ASSERT_NOEXCEPTION; + fprintf( stderr, "Destroy 2\n" ); + libvlc_release( p_i2, &exception ); + ASSERT_NOEXCEPTION; + + /* Deinit */ + fprintf( stderr, "Create 4\n" ); + p_i1 = libvlc_new( 2, argv1, &exception ); + ASSERT_NOEXCEPTION; + id2 = libvlc_get_vlc_id( p_i1 ); - ASSERT( !libvlc_exception_raised( &exception ), - "Exception raised while creating instance" ); + ASSERT( id1 == id2, "libvlc object ids do not match after deinit" ); - libvlc_destroy( p_instance ); - Py_INCREF( Py_None ); return Py_None; } -static PyObject *playlist_test( PyObject *self, PyObject *args ) + PyObject *playlist_test( PyObject *self, PyObject *args ) { libvlc_instance_t *p_instance; char *argv[] = { "vlc", "--quiet" }; @@ -59,7 +89,7 @@ static PyObject *playlist_test( PyObject *self, PyObject *args ) /* Initial status */ 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" ); libvlc_exception_clear( &exception ); @@ -83,13 +113,13 @@ static PyObject *playlist_test( PyObject *self, PyObject *args ) ASSERT_NOEXCEPTION; ASSERT( i_playing == 0, "Playlist shouldn't be running" ); - /* */ - + /* */ + Py_INCREF( Py_None ); return Py_None; } -static PyObject *vlm_test( PyObject *self, PyObject *args ) + PyObject *vlm_test( PyObject *self, PyObject *args ) { libvlc_instance_t *p_instance; char *argv[] = { "vlc", "--quiet" }; @@ -99,7 +129,7 @@ static PyObject *vlm_test( PyObject *self, PyObject *args ) p_instance = libvlc_new( 2, argv, &exception ); ASSERT_NOEXCEPTION; - + /* Test that working on unexisting streams fail */ libvlc_vlm_set_enabled( p_instance, "test", 1, &exception ); ASSERT_EXCEPTION; @@ -146,13 +176,3 @@ static PyObject *vlm_test( PyObject *self, PyObject *args ) Py_INCREF( Py_None ); return Py_None; } - -static PyMethodDef native_libvlc_test_methods[] = { - DEF_METHOD( create_destroy, "Create and destroy" ) - DEF_METHOD( exception_test, "Test Exception handling" ) - DEF_METHOD( playlist_test, "Test Playlist interaction" ) - DEF_METHOD( vlm_test, "Test VLM" ) - { NULL, NULL, 0, NULL } -}; - -DECLARE_MODULE( native_libvlc_test )