]> git.sesse.net Git - vlc/commitdiff
Merge test/ stuff
authorClément Stenac <zorglub@videolan.org>
Wed, 2 Nov 2005 18:33:23 +0000 (18:33 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 2 Nov 2005 18:33:23 +0000 (18:33 +0000)
test/BaseTest.py [new file with mode: 0644]
test/PlaylistTest.py [new file with mode: 0644]
test/TODO [new file with mode: 0644]
test/VariablesTest.py [new file with mode: 0644]
test/test.py [new file with mode: 0644]
test/test.sh [new file with mode: 0755]

diff --git a/test/BaseTest.py b/test/BaseTest.py
new file mode 100644 (file)
index 0000000..9e36ce8
--- /dev/null
@@ -0,0 +1,12 @@
+import vlc
+import unittest
+
+class BaseTestCase( unittest.TestCase ):
+    def testStartup(self):
+        """Checks that VLC starts"""
+       mc = vlc.MediaControl( ['--quiet'])
+        mc.exit()
+
+#    def testHelp(self):
+#        """Check help string"""
+#        mc=vlc.MediaControl( [ '--help'] )
diff --git a/test/PlaylistTest.py b/test/PlaylistTest.py
new file mode 100644 (file)
index 0000000..396d9b8
--- /dev/null
@@ -0,0 +1,18 @@
+import vlc
+import unittest
+
+# FIXME: How to avoid creating / killing vlc for each test method ?
+
+class VariablesTestCase( unittest.TestCase ):
+    """Test misc variables interaction"""
+    def setUp( self ):
+        self.mc = vlc.MediaControl( [ '--quiet'] )
+
+    def tearDown( self ):
+        self.mc.exit()
+           
+    def testSimple( self ):
+        """Test simple add/remove"""
+        assert len( self.mc.playlist_get_list() ) == 0
+        self.mc.playlist_add_item( "test" )
+        assert len( self.mc.playlist_get_list() ) == 1
diff --git a/test/TODO b/test/TODO
new file mode 100644 (file)
index 0000000..b493b10
--- /dev/null
+++ b/test/TODO
@@ -0,0 +1,4 @@
+
+* Write wrapper around MediaControl with output redirection / use of logger interface + log checker (look for error in log and fail if any)
+
+* 
diff --git a/test/VariablesTest.py b/test/VariablesTest.py
new file mode 100644 (file)
index 0000000..84d7747
--- /dev/null
@@ -0,0 +1,38 @@
+import vlc
+import unittest
+
+# FIXME: How to avoid creating / killing vlc for each test method ?
+
+class VariablesTestCase( unittest.TestCase ):
+    """Test misc variables interaction"""
+    def setUp( self ):
+        self.mc = vlc.MediaControl( [ '--quiet'] )
+        # FIXME ! - Get this through children test
+        self.libvlc = vlc.Object(1)
+        self.playlist = vlc.Object(268)
+
+    def tearDown( self ):
+        self.playlist.release() 
+        self.libvlc.release() 
+        self.mc.exit()
+            
+    # The Python binding can't create variables, so just get default ones
+    def testInt( self ):
+        """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"""
+        self.libvlc.set( "width" , 5 )
+        self.libvlc.set( "width", "foo" )
+        assert self.libvlc.get( "width" ) == -1
+    
+    def testString( self ):
+        """Get/Set string variable"""
+        assert self.libvlc.get( "open" ) == ''
+        self.libvlc.set( "open", "foo" ) 
+        assert self.libvlc.get( "open" ) == "foo"
+           
diff --git a/test/test.py b/test/test.py
new file mode 100644 (file)
index 0000000..9206c5b
--- /dev/null
@@ -0,0 +1,29 @@
+"""Regression testing framework
+
+This module will search for scripts in the same directory named
+XYZtest.py.  Each such script should be a test suite that tests a
+module through PyUnit.  (As of Python 2.1, PyUnit is included in
+the standard library as "unittest".)  This script will aggregate all
+found test suites into one big test suite and run them all at once.
+"""
+
+import sys, os, re, unittest
+
+def printAndRun( module ):
+    print "Running tests from module " + module.__name__;
+    return unittest.defaultTestLoader.loadTestsFromModule( module )
+
+def regressionTest():
+    path = os.path.abspath(os.path.dirname(sys.argv[0]))
+    files = os.listdir(path)                    
+    test = re.compile("test.py$", re.IGNORECASE)
+    files = filter(test.search, files)          
+    filenameToModuleName = lambda f: os.path.splitext(f)[0]
+    moduleNames = map(filenameToModuleName, files)         
+    modules = map(__import__, moduleNames)                 
+#    load = unittest.defaultTestLoader.loadTestsFromModule
+    load = printAndRun
+    return unittest.TestSuite(map(load, modules))        
+
+if __name__ == "__main__":
+    unittest.main(defaultTest="regressionTest")
diff --git a/test/test.sh b/test/test.sh
new file mode 100755 (executable)
index 0000000..2d41795
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+# FIXME - Get real .so
+cd ..
+export PYTHONPATH=$PYTHONPATH:bindings/python/build/lib.linux-i686-2.3
+
+python test/test.py -v