tests_: Add a simple python copy/paste test for groups
authorThibault Saunier <tsaunier@gnome.org>
Tue, 22 Dec 2015 22:21:44 +0000 (23:21 +0100)
committerThibault Saunier <tsaunier@gnome.org>
Sun, 17 Jan 2016 08:23:32 +0000 (09:23 +0100)
Integrating python tests in the build system

And cleanup configure.ac

Reviewed-by: Thibault Saunier <thibault.saunier@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D601

configure.ac
tests/check/Makefile.am
tests/check/python/test_group.py [new file with mode: 0644]

index a237f248229779d49424b241460d9ca667ed1ade..3423d35329ea8764c8ffb243c558648b367d3040 100644 (file)
@@ -125,27 +125,8 @@ GTK_DOC_CHECK([1.3])
 AS_PATH_PYTHON([2.1])
 AG_GST_PLUGIN_DOCS([1.3],[2.1])
 
-dnl check for python
-AM_PATH_PYTHON
-AC_MSG_CHECKING(for python >= 2.3)
-prog="
-import sys, string
-minver = (2,3,0,'final',0)
-if sys.version_info < minver:
-  sys.exit(1)
-sys.exit(0)"
-
-if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
-then
-  HAVE_PYTHON=yes
-  AC_MSG_RESULT(okay)
-else
-  HAVE_PYTHON=no
-  AC_MSG_RESULT(no python)
-fi
-
 dnl check for pygobject
-AC_SUBST(PYGOBJECT_REQ, 4.22)
+AC_SUBST(PYGOBJECT_REQ, 3.0)
 PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= $PYGOBJECT_REQ,
   [
     HAVE_PYGOBJECT=yes
@@ -153,7 +134,7 @@ PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= $PYGOBJECT_REQ,
 
 AM_CONDITIONAL(WITH_PYTHON, [test "x$HAVE_PYGOBJECT" = "xyes"])
 
-dnl check for pygobject
+dnl check for gst-validate
 PKG_CHECK_MODULES(GST_VALIDATE, gst-validate-1.0 >= 1.5.90,
   [
     HAVE_GST_VALIDATE=yes
@@ -203,6 +184,21 @@ if test "x$HAVE_UNISTD_H" != "xyes"; then
   GST_PLUGINS_SELECTED=`echo $GST_PLUGINS_SELECTED | $SED -e s/festival//`
 fi
 
+dnl *** checks for nosetests ***
+
+AC_MSG_CHECKING(for nosetests)
+NOSETESTS=nosetests
+if $NOSETESTS 1>&AC_FD_CC 2>&AC_FD_CC
+then
+  HAVE_NOSETESTS=yes
+  AC_MSG_RESULT(yes)
+else
+  HAVE_NOSETESTS=no
+  AC_MSG_RESULT(no nosetests)
+fi
+AC_SUBST([NOSETESTS])
+AM_CONDITIONAL(HAVE_NOSETESTS, test "x$HAVE_NOSETESTS" = "xyes")
+
 dnl *** checks for types/defines ***
 
 dnl *** checks for structures ***
index 222910575d7a5ec4c7ca5112af71d01c242855b9..e23c7d6fb355b3cddf32127c489c12329cc4deac 100644 (file)
@@ -122,3 +122,13 @@ coverage-report:
          perl $(top_srcdir)/common/coverage/coverage-report-entry.pl   \
            $(top_builddir)/$$file > coverage/$$file.html;              \
        done
+
+check:
+if HAVE_NOSETESTS
+if WITH_PYTHON
+       ${NOSETESTS} --verbose $(top_srcdir)/tests/check/python/test_*.py
+
+check-python:
+       ${NOSETESTS} --verbose $(top_srcdir)/tests/check/python/test_*.py
+endif
+endif
diff --git a/tests/check/python/test_group.py b/tests/check/python/test_group.py
new file mode 100644 (file)
index 0000000..1896582
--- /dev/null
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2015, Thibault Saunier
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+import gi
+
+gi.require_version("Gst", "1.0")
+gi.require_version("GES", "1.0")
+
+from gi.repository import Gst  # noqa
+from gi.repository import GES  # noqa
+import unittest  # noqa
+
+Gst.init(None)
+GES.init()
+
+
+class TestCopyPaste(unittest.TestCase):
+
+    def setUp(self):
+        self.timeline = GES.Timeline.new_audio_video()
+        self.assertEqual(len(self.timeline.get_tracks()), 2)
+        self.layer = self.timeline.append_layer()
+
+    def testCopyGroup(self):
+        clip1 = GES.TestClip.new()
+        clip1.props.duration = 10
+
+        self.layer.add_clip(clip1)
+
+        self.assertEqual(len(clip1.get_children(False)), 2)
+
+        group = GES.Group.new()
+        self.assertTrue(group.add(clip1))
+
+        self.assertEqual(len(group.get_children(False)), 1)
+
+        group_copy = group.copy(True)
+        self.assertEqual(len(group_copy.get_children(False)), 0)
+
+        self.assertTrue(group_copy.paste(10))
+        clips = self.layer.get_clips()
+        self.assertEqual(len(clips), 2)
+        self.assertEqual(clips[1].props.start, 10)
+
+        clips[1].edit([], 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 10)
+        clips = self.layer.get_clips()
+        self.assertEqual(len(clips), 1)