]> git.sesse.net Git - vlc/blob - test/native_libvlc/native_libvlc_test.c
b9b056bb0f9c7184b60f2e5ac38767f5abfde381
[vlc] / test / native_libvlc / native_libvlc_test.c
1 #include "../pyunit.h"
2 #include <vlc/libvlc.h>
3
4 static PyObject *exception_test( PyObject *self, PyObject *args )
5 {
6      libvlc_exception_t exception;
7
8      libvlc_exception_init( &exception );
9      ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" );
10      ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" );
11
12      libvlc_exception_raise( &exception, NULL );
13      ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" );
14      ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
15
16      libvlc_exception_raise( &exception, "test" );
17      ASSERT( libvlc_exception_get_message( &exception), "No Message" );
18      ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
19
20      Py_INCREF( Py_None );
21      return Py_None;
22 }
23
24 static PyObject *create_destroy( PyObject *self, PyObject *args )
25 {
26      libvlc_instance_t *p_instance;
27      char *argv[] = {};
28
29      libvlc_exception_t exception;
30      libvlc_exception_init( &exception );
31
32      p_instance = libvlc_new( 0, argv, &exception );
33
34      ASSERT( p_instance != NULL, "Instance creation failed" );
35
36      ASSERT( !libvlc_exception_raised( &exception ),
37              "Exception raised while creating instance" );
38
39      libvlc_destroy( p_instance );
40      
41      Py_INCREF( Py_None );
42      return Py_None;
43 }
44
45 static PyMethodDef native_libvlc_test_methods[] = {
46    DEF_METHOD( create_destroy, "Create and destroy" )
47    DEF_METHOD( exception_test, "Test Exception handling" )
48    { NULL, NULL, 0, NULL }
49 };
50
51 DECLARE_MODULE( native_libvlc_test )