Change some test stuff
authorClément Stenac <zorglub@videolan.org>
Sun, 12 Feb 2006 17:14:07 +0000 (17:14 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 12 Feb 2006 17:14:07 +0000 (17:14 +0000)
test/NativeLibvlcTest.py
test/PyMediaControlBaseTest.py
test/PyMediaControlPlaylistTest.py
test/PyMediaControlVariablesTest.py
test/native/native_libvlc_test.c [new file with mode: 0644]
test/native_libvlc/native_libvlc_test.c [deleted file]
test/setup.py
test/test.sh

index 2c7c0aa..0eae7a8 100644 (file)
@@ -5,11 +5,11 @@ import native_libvlc_test
 
 class NativeLibvlcTestCase( unittest.TestCase ):
     def testException( self ):
-        """Checks libvlc_exception"""
+        """[LibVLC] Checks libvlc_exception"""
        native_libvlc_test.exception_test()
     def testStartup( self ):
-        """Checks creation/destroy of libvlc"""
+        """[LibVLC] Checks creation/destroy of libvlc"""
        native_libvlc_test.create_destroy()
     def testPlaylist( self ):
-        """Checks basic playlist interaction"""
+        """[LibVLC] Checks basic playlist interaction"""
        native_libvlc_test.playlist_test()
index 9e36ce8..23c6f30 100644 (file)
@@ -3,10 +3,6 @@ import unittest
 
 class BaseTestCase( unittest.TestCase ):
     def testStartup(self):
-        """Checks that VLC starts"""
+        """[PyMC] Check that VLC starts"""
        mc = vlc.MediaControl( ['--quiet'])
         mc.exit()
-
-#    def testHelp(self):
-#        """Check help string"""
-#        mc=vlc.MediaControl( [ '--help'] )
index 396d9b8..1a53a6a 100644 (file)
@@ -4,7 +4,7 @@ import unittest
 # FIXME: How to avoid creating / killing vlc for each test method ?
 
 class VariablesTestCase( unittest.TestCase ):
-    """Test misc variables interaction"""
+    """[PyMC] Test misc variables interaction"""
     def setUp( self ):
         self.mc = vlc.MediaControl( [ '--quiet'] )
 
@@ -12,7 +12,7 @@ class VariablesTestCase( unittest.TestCase ):
         self.mc.exit()
            
     def testSimple( self ):
-        """Test simple add/remove"""
+        """[PyMC] Check simple add"""
         assert len( self.mc.playlist_get_list() ) == 0
         self.mc.playlist_add_item( "test" )
         assert len( self.mc.playlist_get_list() ) == 1
index 84d7747..9d08a60 100644 (file)
@@ -4,7 +4,7 @@ import unittest
 # FIXME: How to avoid creating / killing vlc for each test method ?
 
 class VariablesTestCase( unittest.TestCase ):
-    """Test misc variables interaction"""
+    """[PyMC] Test misc variables interaction"""
     def setUp( self ):
         self.mc = vlc.MediaControl( [ '--quiet'] )
         # FIXME ! - Get this through children test
@@ -18,20 +18,20 @@ class VariablesTestCase( unittest.TestCase ):
             
     # The Python binding can't create variables, so just get default ones
     def testInt( self ):
-        """Get/Set integer variable"""
+        """[PyMC] Get/Set integer variable"""
         assert self.libvlc.get( "width" ) == 0
         self.libvlc.set( "width", 42 ) 
         assert self.libvlc.get( 'width' ) == 42
 
     # FIXME: Python binding should listen to return value and raise exception 
     def testInvalidInt( self ):
-        """Get/Set invalid integer"""
+        """[PyMC] Get/Set invalid integer"""
         self.libvlc.set( "width" , 5 )
         self.libvlc.set( "width", "foo" )
         assert self.libvlc.get( "width" ) == -1
     
     def testString( self ):
-        """Get/Set string variable"""
+        """[PyMC] Get/Set string variable"""
         assert self.libvlc.get( "open" ) == ''
         self.libvlc.set( "open", "foo" ) 
         assert self.libvlc.get( "open" ) == "foo"
diff --git a/test/native/native_libvlc_test.c b/test/native/native_libvlc_test.c
new file mode 100644 (file)
index 0000000..5ddab81
--- /dev/null
@@ -0,0 +1,92 @@
+#include "../pyunit.h"
+#include <vlc/libvlc.h>
+
+static PyObject *exception_test( PyObject *self, PyObject *args )
+{
+     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_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" );
+
+     Py_INCREF( Py_None );
+     return Py_None;
+}
+
+static PyObject *create_destroy( PyObject *self, PyObject *args )
+{
+    libvlc_instance_t *p_instance;
+    char *argv[] = { "vlc", "--quiet" };
+
+    libvlc_exception_t exception;
+    libvlc_exception_init( &exception );
+
+    p_instance = libvlc_new( 2, argv, &exception );
+
+    ASSERT( p_instance != NULL, "Instance creation failed" );
+
+    ASSERT( !libvlc_exception_raised( &exception ),
+             "Exception raised while creating instance" );
+
+    libvlc_destroy( p_instance );
+     
+    Py_INCREF( Py_None );
+    return Py_None;
+}
+
+static PyObject *playlist_test( PyObject *self, PyObject *args )
+{
+    libvlc_instance_t *p_instance;
+    char *argv[] = { "vlc", "--quiet" };
+    int i_id, i_playing, i_items;
+
+    libvlc_exception_t exception;
+    libvlc_exception_init( &exception );
+
+    p_instance = libvlc_new( 2, argv, &exception );
+
+    /* Initial status */
+    libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
+    ASSERT( libvlc_exception_raised( &exception ), 
+            "Playlist empty and exception not raised" );
+    i_playing  = libvlc_playlist_isplaying( p_instance, &exception  );
+    ASSERT_EXCEPTION;
+    ASSERT( i_playing == 0, "Playlist shouldn't be running" );
+    i_items = libvlc_playlist_items_count( p_instance, &exception );
+    ASSERT_EXCEPTION;
+    ASSERT( i_items == 0, "Playlist should be empty" );
+
+    /* Add 1 item */
+    libvlc_exception_clear( &exception );
+    i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
+    ASSERT_EXCEPTION;
+    ASSERT( i_id > 0 , "Returned identifier is <= 0" );
+    i_items = libvlc_playlist_items_count( p_instance, &exception );
+    ASSERT_EXCEPTION;
+    ASSERT( i_items == 1, "Playlist should have 1 item" );
+    i_playing  = libvlc_playlist_isplaying( p_instance, &exception  );
+    ASSERT_EXCEPTION;
+    ASSERT( i_playing == 0, "Playlist shouldn't be running" );
+
+    /* */ 
+    
+    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" )
+   { NULL, NULL, 0, NULL }
+};
+
+DECLARE_MODULE( native_libvlc_test )
diff --git a/test/native_libvlc/native_libvlc_test.c b/test/native_libvlc/native_libvlc_test.c
deleted file mode 100644 (file)
index 6064e92..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "../pyunit.h"
-#include <vlc/libvlc.h>
-
-static PyObject *exception_test( PyObject *self, PyObject *args )
-{
-     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_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" );
-
-     Py_INCREF( Py_None );
-     return Py_None;
-}
-
-static PyObject *create_destroy( PyObject *self, PyObject *args )
-{
-    libvlc_instance_t *p_instance;
-    char *argv[] = { "vlc", "--quiet" };
-
-    libvlc_exception_t exception;
-    libvlc_exception_init( &exception );
-
-    p_instance = libvlc_new( 2, argv, &exception );
-
-    ASSERT( p_instance != NULL, "Instance creation failed" );
-
-    ASSERT( !libvlc_exception_raised( &exception ),
-             "Exception raised while creating instance" );
-
-    libvlc_destroy( p_instance );
-     
-    Py_INCREF( Py_None );
-    return Py_None;
-}
-
-static PyObject *playlist_test( PyObject *self, PyObject *args )
-{
-    libvlc_instance_t *p_instance;
-    char *argv[] = { "vlc", "--quiet" };
-    int i_id;
-
-    libvlc_exception_t exception;
-    libvlc_exception_init( &exception );
-
-    p_instance = libvlc_new( 2, argv, &exception );
-
-    libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
-
-    ASSERT( libvlc_exception_raised( &exception ), 
-            "Playlist empty and exception not raised" );
-
-    libvlc_exception_clear( &exception );
-    i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
-
-    ASSERT_EXCEPTION;
-
-    ASSERT( i_id > 0 , "Returned identifier is <= 0" );
-    
-    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" )
-   { NULL, NULL, 0, NULL }
-};
-
-DECLARE_MODULE( native_libvlc_test )
index a43ac97..0f23226 100644 (file)
@@ -39,11 +39,21 @@ def get_ldflags():
 
 # To compile in a local vlc tree
 native_libvlc_test = Extension( 'native_libvlc_test',
-                sources = ['native_libvlc/native_libvlc_test.c'],
+                sources = ['native/libvlc.c'],
                 include_dirs = ['../include', '../', '/usr/win32/include' ],
                 extra_objects = [ '../lib/libvlc_pic.a' ],
                 extra_compile_args = get_cflags(),
                            extra_link_args = [ '-L../..' ]  + get_ldflags(),
                 )
 
+native_stats_test = Extension( 'native_stats_test',
+                sources = ['native/stats.c'],
+                include_dirs = ['../include', '../', '/usr/win32/include' ],
+                extra_objects = [ '../lib/libvlc_pic.a' ],
+                extra_compile_args = get_cflags(),
+                           extra_link_args = [ '-L../..' ]  + get_ldflags(),
+                )
+
+
 setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] )
+setup( name = 'native_stats_test' ,version = '1242', ext_modules = [ native_stats_test ] )
index e5d5663..bc11147 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 
 cd ..
-export PYTHONPATH=$PYTHONPATH:bindings/python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3
+export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3
 
 python test/test.py -v