[vlc-devel] commit: python-ctypes: implement basic unit tests (Olivier Aubert )

git version control git at videolan.org
Wed Sep 2 11:18:27 CEST 2009


vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Wed Sep  2 11:17:21 2009 +0200| [8421105c5e0d03cc19d5a97e848705e924d74754] | committer: Olivier Aubert 

python-ctypes: implement basic unit tests

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8421105c5e0d03cc19d5a97e848705e924d74754
---

 bindings/python-ctypes/Makefile |    5 ++-
 bindings/python-ctypes/test.py  |  105 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+), 1 deletions(-)

diff --git a/bindings/python-ctypes/Makefile b/bindings/python-ctypes/Makefile
index 760bb9c..3c10756 100644
--- a/bindings/python-ctypes/Makefile
+++ b/bindings/python-ctypes/Makefile
@@ -3,10 +3,13 @@ MODULE_NAME=vlc.py
 all: $(MODULE_NAME)
 
 $(MODULE_NAME): generate.py header.py footer.py override.py ../../include/vlc/*.h
-	./generate.py ../../include/vlc/*.h > $@
+	python generate.py ../../include/vlc/*.h > $@
 
 doc: $(MODULE_NAME)
 	-epydoc -v -o doc $<
 
+test: $(MODULE_NAME)
+	python test.py
+
 clean:
 	-$(RM) $(MODULE_NAME)
diff --git a/bindings/python-ctypes/test.py b/bindings/python-ctypes/test.py
new file mode 100755
index 0000000..bd0c4a3
--- /dev/null
+++ b/bindings/python-ctypes/test.py
@@ -0,0 +1,105 @@
+#! /usr/bin/python
+
+#
+# Code generator for python ctypes bindings for VLC
+# Copyright (C) 2009 the VideoLAN team
+# $Id: $
+#
+# Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+#
+
+"""Unittest module.
+"""
+
+import unittest
+import vlc
+
+class TestVLCAPI(unittest.TestCase):
+    #def setUp(self):
+    #    self.seq = range(10)
+    #self.assert_(element in self.seq)
+
+    # We check enum definitions against hardcoded values. In case of
+    # failure, check that the reason is not a change in the .h
+    # definitions.
+    def test_enum_event_type(self):
+        self.assertEqual(vlc.EventType.MediaStateChanged, 5)
+
+    def test_enum_meta(self):
+        self.assertEqual(vlc.Meta.Description, 6)
+
+    def test_enum_state(self):
+        self.assertEqual(vlc.State.Playing, 3)
+
+    def test_enum_media_option(self):
+        self.assertEqual(vlc.MediaOption.unique, 256)
+
+    def test_enum_playback_mode(self):
+        self.assertEqual(vlc.PlaybackMode.repeat, 2)
+
+    def test_enum_marquee_int_option(self):
+        self.assertEqual(vlc.VideoMarqueeIntOption.Size, 5)
+
+    def test_enum_output_device_type(self):
+        self.assertEqual(vlc.AudioOutputDeviceTypes._2F2R, 4)
+
+    def test_enum_output_channel(self):
+        self.assertEqual(vlc.AudioOutputChannel.Dolbys, 5)
+
+    def test_enum_position_origin(self):
+        self.assertEqual(vlc.PositionOrigin.ModuloPosition, 2)
+
+    def test_enum_position_key(self):
+        self.assertEqual(vlc.PositionKey.MediaTime, 2)
+
+    def test_enum_player_status(self):
+        self.assertEqual(vlc.PlayerStatus.StopStatus, 5)
+
+    # Basic MediaControl tests
+    def test_mediacontrol_creation(self):
+        mc=vlc.MediaControl()
+        self.assert_(mc)
+
+    def test_mediacontrol_initial_mrl(self):
+        mc=vlc.MediaControl()
+        self.assertEqual(mc.get_mrl(), '')
+
+    def test_mediacontrol_set_mrl(self):
+        mrl='/tmp/foo.avi'
+        mc=vlc.MediaControl()
+        mc.set_mrl(mrl)
+        self.assertEqual(mc.get_mrl(), mrl)
+
+    # Basic libvlc tests
+    def test_instance_creation(self):
+        i=vlc.Instance()
+        self.assert_(i)
+
+    def test_libvlc_media(self):
+        mrl='/tmp/foo.avi'
+        i=vlc.Instance()
+        m=i.media_new(mrl)
+        self.assertEqual(m.get_mrl(), mrl)
+
+    def test_libvlc_player(self):
+        mrl='/tmp/foo.avi'
+        i=vlc.Instance()
+        p=i.media_player_new(mrl)
+        self.assertEqual(p.get_media().get_mrl(), mrl)
+
+if __name__ == '__main__':
+    unittest.main()




More information about the vlc-devel mailing list