]> git.sesse.net Git - vlc/blob - test/native_libvlc/native_libvlc_test.c
Play and add (Refs:#457)
[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[] = { "vlc", "--quiet" };
28
29     libvlc_exception_t exception;
30     libvlc_exception_init( &exception );
31
32     p_instance = libvlc_new( 2, 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 PyObject *playlist_test( PyObject *self, PyObject *args )
46 {
47     libvlc_instance_t *p_instance;
48     char *argv[] = { "vlc", "--quiet" };
49     int i_id;
50
51     libvlc_exception_t exception;
52     libvlc_exception_init( &exception );
53
54     p_instance = libvlc_new( 2, argv, &exception );
55
56     libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
57
58     ASSERT( libvlc_exception_raised( &exception ), 
59             "Playlist empty and exception not raised" );
60
61     libvlc_exception_clear( &exception );
62     i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
63
64     ASSERT_EXCEPTION;
65
66     ASSERT( i_id > 0 , "Returned identifier is <= 0" );
67     
68     Py_INCREF( Py_None );
69     return Py_None;
70 }
71
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 }
77 };
78
79 DECLARE_MODULE( native_libvlc_test )