[libpeas: 13/18] Check that the extension GType is an interface



commit 6a0b340ec93b0a00bb11fd361c8802868c5db91d
Author: Garrett Regier <alias301 gmail com>
Date:   Thu Mar 3 04:43:49 2011 -0800

    Check that the extension GType is an interface

 libpeas/peas-engine.c                     |    2 ++
 tests/libpeas/testing/testing-extension.c |   11 +++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 5383984..ac5e1cd 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -942,6 +942,7 @@ peas_engine_provides_extension (PeasEngine     *engine,
 
   g_return_val_if_fail (PEAS_IS_ENGINE (engine), FALSE);
   g_return_val_if_fail (info != NULL, FALSE);
+  g_return_val_if_fail (G_TYPE_IS_INTERFACE (extension_type), FALSE);
 
   if (!peas_plugin_info_is_loaded (info))
     return FALSE;
@@ -982,6 +983,7 @@ peas_engine_create_extensionv (PeasEngine     *engine,
   g_return_val_if_fail (PEAS_IS_ENGINE (engine), NULL);
   g_return_val_if_fail (info != NULL, NULL);
   g_return_val_if_fail (peas_plugin_info_is_loaded (info), NULL);
+  g_return_val_if_fail (G_TYPE_IS_INTERFACE (extension_type), FALSE);
 
   loader = get_plugin_loader (engine, info);
   return peas_plugin_loader_create_extension (loader, info, extension_type,
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index 09cc76e..7770818 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -132,10 +132,13 @@ testing_extension_create_invalid_ (PeasEngine *engine)
 
 
   /* GObject but not a GInterface */
-  extension = peas_engine_create_extension (engine, info,
-                                            PEAS_TYPE_ENGINE,
-                                            NULL);
-  g_assert (!PEAS_IS_EXTENSION (extension));
+  if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+    {
+      peas_engine_create_extension (engine, info, PEAS_TYPE_ENGINE, NULL);
+      exit (0);
+    }
+  g_test_trap_assert_failed ();
+  g_test_trap_assert_stderr ("*CRITICAL*");
 
 
   /* Does not implement this GType */



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