[gegl] tests: Add infrastructure and some python (introspection) tests
- From: Jon Nordby <jonnor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] tests: Add infrastructure and some python (introspection) tests
- Date: Mon, 5 Sep 2011 17:46:24 +0000 (UTC)
commit cc86f3caa0d69ec23316db9ad4efda3088a1cdbe
Author: Jon Nordby <jononor gmail com>
Date: Mon Sep 5 00:26:37 2011 +0200
tests: Add infrastructure and some python (introspection) tests
configure.ac | 6 +++
tests/Makefile.am | 4 +-
tests/python/.gitignore | 2 +
tests/python/Makefile.am | 17 ++++++++
tests/python/test-gegl-node.py | 82 ++++++++++++++++++++++++++++++++++++++++
tests/python/test-gegl.py | 41 ++++++++++++++++++++
6 files changed, 151 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 32cf45e..8d999b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -568,6 +568,11 @@ else
fi
AM_CONDITIONAL(HAVE_DOT, test "x$have_dot" = "xyes")
+#################
+# Check for Python (optional, used for introspection unittests)
+#################
+AM_PATH_PYTHON([2.5.0],, [:])
+AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
#################
# Check for Cairo
@@ -1096,6 +1101,7 @@ tests/buffer/reference/Makefile
tests/buffer/tests/Makefile
tests/compositions/Makefile
tests/compositions/data/Makefile
+tests/python/Makefile
tests/simple/Makefile
tests/xml/Makefile
gegl.pc
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1354886..87b2cf5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,7 @@
+
SUBDIRS = \
buffer \
compositions \
simple \
- xml
+ xml \
+ python
diff --git a/tests/python/.gitignore b/tests/python/.gitignore
new file mode 100644
index 0000000..282522d
--- /dev/null
+++ b/tests/python/.gitignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/tests/python/Makefile.am b/tests/python/Makefile.am
new file mode 100644
index 0000000..34d3589
--- /dev/null
+++ b/tests/python/Makefile.am
@@ -0,0 +1,17 @@
+TESTS_ENVIRONMENT = \
+ LD_LIBRARY_PATH=$(top_builddir)/gegl/.libs \
+ GI_TYPELIB_PATH=$(top_builddir)/gegl:$(GI_TYPELIB_PATH) \
+ GEGL_SWAP=RAM \
+ GEGL_PATH=$(top_builddir)/operations/common:$(top_builddir)/operations/core:$(top_builddir)/operations/affine:$(top_builddir)/operations/generated \
+ $(PYTHON)
+
+if HAVE_PYTHON
+if HAVE_INTROSPECTION
+
+# List of tests.
+TESTS = \
+ test-gegl.py \
+ test-gegl-node.p
+
+endif # HAVE_INTROSPECTION
+endif # HAVE_PYTHON
diff --git a/tests/python/test-gegl-node.py b/tests/python/test-gegl-node.py
new file mode 100755
index 0000000..b17abe4
--- /dev/null
+++ b/tests/python/test-gegl-node.py
@@ -0,0 +1,82 @@
+""" This file is part of GEGL
+ *
+ * GEGL 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 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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 GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2011 Jon Nordby <jononor gmail com>
+"""
+
+import unittest
+
+import gi
+from gi.repository import Gegl
+
+invert_crop_xml = """<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='gegl:invert'>
+ </node>
+ <node operation='gegl:crop'>
+ <params>
+ <param name='x'>0</param>
+ <param name='y'>0</param>
+ <param name='width'>0</param>
+ <param name='height'>0</param>
+ </params>
+ </node>
+</gegl>
+"""
+
+class TestGeglNode(unittest.TestCase):
+
+ def test_exists(self):
+ Gegl.Node
+
+ def test_new(self):
+ graph = Gegl.Node.new()
+ self.assertEqual(type(graph), gi.repository.Gegl.Node)
+
+class TestGeglNodeLoadXml(unittest.TestCase):
+
+ def setUp(self):
+ self.graph = Gegl.Node.new_from_xml(invert_crop_xml, "")
+
+ def test_number_of_children(self):
+ children = self.graph.get_children()
+
+ self.assertEqual(len(children), 2)
+
+ def test_child_operation(self):
+ children = self.graph.get_children()
+
+ self.assertEqual(children[0].get_operation(), "gegl:crop")
+ self.assertEqual(children[1].get_operation(), "gegl:invert")
+
+
+class TestGeglNodeSaveXml(unittest.TestCase):
+
+ def setUp(self):
+ self.graph = Gegl.Node.new()
+
+ # Easiest way to test to_xml when we can't yet build graphs programatically
+ def test_load_save_roundtrip(self):
+ graph = Gegl.Node.new_from_xml(invert_crop_xml, "")
+ output = graph.to_xml("")
+
+ self.assertEqual(output, invert_crop_xml)
+
+if __name__ == '__main__':
+ Gegl.init(0, "");
+ #print dir(Gegl.Node)
+
+ unittest.main()
+
diff --git a/tests/python/test-gegl.py b/tests/python/test-gegl.py
new file mode 100644
index 0000000..97b6789
--- /dev/null
+++ b/tests/python/test-gegl.py
@@ -0,0 +1,41 @@
+""" This file is part of GEGL
+ *
+ * GEGL 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 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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 GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2011 Jon Nordby <jononor gmail com>
+"""
+
+import unittest
+
+import gi
+from gi.repository import Gegl
+
+class TestGegl(unittest.TestCase):
+ """Tests the Gegl"""
+
+ def test_init(self):
+ Gegl.init(0, "");
+
+ def test_exit(self):
+ pass
+ #Gegl.exit()
+
+ def test_init_exit(self):
+ Gegl.init(0, "");
+ Gegl.exit();
+
+if __name__ == '__main__':
+ #print dir(Gegl)
+ unittest.main()
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]