[libpeas] Added Python version of PeasExtension tests



commit 11bf0c69de2c1d816eb8999830adcef0d3311ae2
Author: Garrett Regier <alias301 gmail com>
Date:   Mon Jan 17 03:25:41 2011 -0800

    Added Python version of PeasExtension tests
    
    For now the property tests are disabled because tests that
    should fail succeed.

 .gitignore                                         |    1 +
 configure.ac                                       |    1 +
 tests/libpeas/Makefile.am                          |    9 +++
 tests/libpeas/extension-python.c                   |   61 ++++++++++++++++++++
 tests/libpeas/plugins/Makefile.am                  |    4 +
 tests/libpeas/plugins/extension-python/Makefile.am |    5 ++
 .../extension-python/extension-python.plugin       |    9 +++
 .../plugins/extension-python/extension-python.py   |   38 ++++++++++++
 tests/libpeas/testing/testing.c                    |    2 +-
 9 files changed, 129 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 3725588..81330a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,6 +70,7 @@ Makefile.in
 /tests/*/vgdump-*
 /tests/libpeas/engine
 /tests/libpeas/extension-c
+/tests/libpeas/extension-python
 /tests/libpeas/extension-set
 /tests/libpeas/plugin-info
 /tests/libpeas-gtk/plugin-manager
diff --git a/configure.ac b/configure.ac
index 0e06e48..3840b77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -315,6 +315,7 @@ tests/Makefile
 tests/libpeas/Makefile
 tests/libpeas/plugins/Makefile
 tests/libpeas/plugins/extension-c/Makefile
+tests/libpeas/plugins/extension-python/Makefile
 tests/libpeas/introspection/Makefile
 tests/libpeas/testing/Makefile
 tests/libpeas-gtk/Makefile
diff --git a/tests/libpeas/Makefile.am b/tests/libpeas/Makefile.am
index 2f4f3e0..e33f2a7 100644
--- a/tests/libpeas/Makefile.am
+++ b/tests/libpeas/Makefile.am
@@ -23,12 +23,21 @@ TEST_PROGS += \
 	extension-set	\
 	plugin-info
 
+if ENABLE_PYTHON
+TEST_PROGS += extension-python
+endif
+
 engine_SOURCES = engine.c
 engine_LDADD   = $(progs_ldadd)
 
 extension_c_SOURCES = extension-c.c
 extension_c_LDADD   = $(progs_ldadd)
 
+if ENABLE_PYTHON
+extension_python_SOURCES = extension-python.c
+extension_python_LDADD   = $(progs_ldadd)
+endif
+
 extension_set_SOURCES = extension-set.c
 extension_set_LDADD   = $(progs_ldadd)
 
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
new file mode 100644
index 0000000..0cec9d5
--- /dev/null
+++ b/tests/libpeas/extension-python.c
@@ -0,0 +1,61 @@
+/*
+ * extension-python.c
+ * This file is part of libpeas
+ *
+ * Copyright (C) 2011 - Garrett Regier
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Library 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "testing/testing-extension.h"
+
+/*#define EXTENSION_TESTS("python")*/
+
+int
+main (int   argc,
+      char *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+
+  g_type_init ();
+
+  testing_extension_set_plugin_ ("extension-" "python");
+
+  _EXTENSION_TEST ("python", "create-valid", create_valid);
+  _EXTENSION_TEST ("python", "create-invalid", create_invalid);
+
+  _EXTENSION_TEST ("python", "call-invalid", call_invalid);
+  _EXTENSION_TEST ("python", "call-no-args", call_no_args);
+  _EXTENSION_TEST ("python", "call-with-return", call_with_return);
+  _EXTENSION_TEST ("python", "call-single-arg", call_single_arg);
+  _EXTENSION_TEST ("python", "call-multi-args", call_multi_args);
+
+#ifdef PYTHON_EXTENSION_PROPERTIES_DONT_WORK
+  /* Some tests don't fail when they should */
+
+  _EXTENSION_TEST ("python", "properties-construct-only", properties_construct_only);
+  _EXTENSION_TEST ("python", "properties-read-only", properties_read_only);
+  _EXTENSION_TEST ("python", "properties-write-only", properties_write_only);
+  _EXTENSION_TEST ("python", "properties-readwrite", properties_readwrite);
+#endif
+
+  g_object_unref (peas_engine_get_default ());
+
+  return g_test_run ();
+}
diff --git a/tests/libpeas/plugins/Makefile.am b/tests/libpeas/plugins/Makefile.am
index d60d2a5..43efb2d 100644
--- a/tests/libpeas/plugins/Makefile.am
+++ b/tests/libpeas/plugins/Makefile.am
@@ -1,5 +1,9 @@
 SUBDIRS = extension-c
 
+if ENABLE_PYTHON
+SUBDIRS += extension-python
+endif
+
 noinst_DATA = \
 	info-missing-iage.plugin	\
 	info-missing-module.plugin	\
diff --git a/tests/libpeas/plugins/extension-python/Makefile.am b/tests/libpeas/plugins/extension-python/Makefile.am
new file mode 100644
index 0000000..1ccd058
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python/Makefile.am
@@ -0,0 +1,5 @@
+noinst_PYTHON = extension-python.py
+
+noinst_DATA = extension-python.plugin
+
+EXTRA_DIST = $(noinst_DATA)
diff --git a/tests/libpeas/plugins/extension-python/extension-python.plugin b/tests/libpeas/plugins/extension-python/extension-python.plugin
new file mode 100644
index 0000000..ca6b105
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python/extension-python.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Module=extension-python
+Loader=python
+IAge=2
+Name=Extension Python
+Description=This plugin is for the Python PeasExtension tests.
+Authors=Garrett Regier
+Copyright=Copyright © 2010 Garrett Regier
+Website=http://live.gnome.org/Libpeas
diff --git a/tests/libpeas/plugins/extension-python/extension-python.py b/tests/libpeas/plugins/extension-python/extension-python.py
new file mode 100644
index 0000000..fc09062
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python/extension-python.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# ex:set ts=4 et sw=4 ai:
+
+import gobject
+from gi.repository import Introspection
+
+class CallablePythonPlugin(gobject.GObject, Introspection.Callable):
+    __gtype_name__ = "CallablePythonPlugin"
+
+    def do_call_with_return(self):
+        return "Hello, World!";
+
+    def do_call_no_args(self):
+        pass
+
+    def do_call_single_arg(self):
+        return True
+
+    def do_call_multi_args(self):
+        return (True, True, True)
+
+class PropertiesPythonPlugin(gobject.GObject, Introspection.Properties):
+    __gtype_name__ = "PropertiesPythonPlugin"
+
+    construct_only = gobject.property(type=str, #default="construct-only",
+                                      flags=(gobject.PARAM_READWRITE |
+                                             gobject.PARAM_CONSTRUCT_ONLY))
+
+    read_only = gobject.property(type=str, #default="read-only",
+                                 flags=gobject.PARAM_READABLE)
+                                      
+    write_only = gobject.property(type=str, #default="write-only",
+                                  flags=(gobject.PARAM_WRITABLE |
+                                         gobject.PARAM_CONSTRUCT))
+
+    readwrite = gobject.property(type=str, #default="readwrite",
+                                 flags=(gobject.PARAM_READWRITE |
+                                        gobject.PARAM_CONSTRUCT))
diff --git a/tests/libpeas/testing/testing.c b/tests/libpeas/testing/testing.c
index af7cdf4..ce7506d 100644
--- a/tests/libpeas/testing/testing.c
+++ b/tests/libpeas/testing/testing.c
@@ -41,7 +41,7 @@ static GLogFunc default_log_func;
  */
 static const gchar *allowed_patterns[] = {
   "*Plugin not found: does-not-exist*",
-  "*libcloader.so*cannot open shared object file: No such file or directory*",
+  "*lib*loader.so*cannot open shared object file: No such file or directory*",
   "*Could not find 'IAge' in *info-missing-iage.plugin*",
   "*Could not find 'Module' in *info-missing-module.plugin*",
   "*Could not find 'Name' in *info-missing-name.plugin*",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]