2 #include <vlc/libvlc.h>
4 static PyObject *exception_test( PyObject *self, PyObject *args )
6 libvlc_exception_t exception;
8 libvlc_exception_init( &exception );
9 ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" );
10 ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" );
12 libvlc_exception_raise( &exception, NULL );
13 ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" );
14 ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
16 libvlc_exception_raise( &exception, "test" );
17 ASSERT( libvlc_exception_get_message( &exception), "No Message" );
18 ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
24 static PyObject *create_destroy( PyObject *self, PyObject *args )
26 libvlc_instance_t *p_instance;
27 char *argv[] = { "vlc", "--quiet" };
29 libvlc_exception_t exception;
30 libvlc_exception_init( &exception );
32 p_instance = libvlc_new( 2, argv, &exception );
34 ASSERT( p_instance != NULL, "Instance creation failed" );
36 ASSERT( !libvlc_exception_raised( &exception ),
37 "Exception raised while creating instance" );
39 libvlc_destroy( p_instance );
45 static PyObject *playlist_test( PyObject *self, PyObject *args )
47 libvlc_instance_t *p_instance;
48 char *argv[] = { "vlc", "--quiet" };
51 libvlc_exception_t exception;
52 libvlc_exception_init( &exception );
54 p_instance = libvlc_new( 2, argv, &exception );
56 libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
58 ASSERT( libvlc_exception_raised( &exception ),
59 "Playlist empty and exception not raised" );
61 libvlc_exception_clear( &exception );
62 i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
66 ASSERT( i_id > 0 , "Returned identifier is <= 0" );
72 static PyMethodDef native_libvlc_test_methods[] = {
73 DEF_METHOD( create_destroy, "Create and destroy" )
74 DEF_METHOD( exception_test, "Test Exception handling" )
75 DEF_METHOD( playlist_test, "Test Playlist interaction" )
76 { NULL, NULL, 0, NULL }
79 DECLARE_MODULE( native_libvlc_test )