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" );
20 libvlc_exception_clear( &exception );
21 ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" );
27 static PyObject *create_destroy( PyObject *self, PyObject *args )
29 libvlc_instance_t *p_instance;
30 char *argv[] = { "vlc", "--quiet" };
32 libvlc_exception_t exception;
33 libvlc_exception_init( &exception );
35 p_instance = libvlc_new( 2, argv, &exception );
37 ASSERT( p_instance != NULL, "Instance creation failed" );
39 ASSERT( !libvlc_exception_raised( &exception ),
40 "Exception raised while creating instance" );
42 libvlc_destroy( p_instance );
48 static PyObject *playlist_test( PyObject *self, PyObject *args )
50 libvlc_instance_t *p_instance;
51 char *argv[] = { "vlc", "--quiet" };
52 int i_id, i_playing, i_items;
54 libvlc_exception_t exception;
55 libvlc_exception_init( &exception );
57 p_instance = libvlc_new( 2, argv, &exception );
61 libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
62 ASSERT( libvlc_exception_raised( &exception ),
63 "Playlist empty and exception not raised" );
65 libvlc_exception_clear( &exception );
67 i_playing = libvlc_playlist_isplaying( p_instance, &exception );
69 ASSERT( i_playing == 0, "Playlist shouldn't be running" );
70 i_items = libvlc_playlist_items_count( p_instance, &exception );
72 ASSERT( i_items == 0, "Playlist should be empty" );
75 libvlc_exception_clear( &exception );
76 i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
78 ASSERT( i_id > 0 , "Returned identifier is <= 0" );
79 i_items = libvlc_playlist_items_count( p_instance, &exception );
81 ASSERT( i_items == 1, "Playlist should have 1 item" );
82 i_playing = libvlc_playlist_isplaying( p_instance, &exception );
84 ASSERT( i_playing == 0, "Playlist shouldn't be running" );
92 static PyMethodDef native_libvlc_test_methods[] = {
93 DEF_METHOD( create_destroy, "Create and destroy" )
94 DEF_METHOD( exception_test, "Test Exception handling" )
95 DEF_METHOD( playlist_test, "Test Playlist interaction" )
96 { NULL, NULL, 0, NULL }
99 DECLARE_MODULE( native_libvlc_test )