[libpeas: 14/18] Add tests for peas_engine_provides_extension()



commit 439233dd32004678b8bd4db1ec669629a9593df7
Author: Garrett Regier <alias301 gmail com>
Date:   Thu Mar 3 04:44:50 2011 -0800

    Add tests for peas_engine_provides_extension()

 tests/libpeas/extension-python.c          |    3 ++
 tests/libpeas/extension-seed.c            |    3 ++
 tests/libpeas/testing/testing-extension.c |   51 +++++++++++++++++++++++++++++
 tests/libpeas/testing/testing-extension.h |    5 +++
 4 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index ddd0304..df95e19 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -44,6 +44,9 @@ main (int   argc,
 
   _EXTENSION_TEST ("python", "garbage-collect", garbage_collect);
 
+  _EXTENSION_TEST ("python", "provides-valid", provides_valid);
+  _EXTENSION_TEST ("python", "provides-invalid", provides_invalid);
+
   _EXTENSION_TEST ("python", "create-valid", create_valid);
   _EXTENSION_TEST ("python", "create-invalid", create_invalid);
 
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index f2561a8..c40e22f 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -44,6 +44,9 @@ main (int   argc,
 
   _EXTENSION_TEST ("seed", "garbage-collect", garbage_collect);
 
+  _EXTENSION_TEST ("seed", "provides-valid", provides_valid);
+  _EXTENSION_TEST ("seed", "provides-invalid", provides_invalid);
+
   _EXTENSION_TEST ("seed", "create-valid", create_valid);
   _EXTENSION_TEST ("seed", "create-invalid", create_invalid);
 
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index 7770818..0b6ca14 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -82,6 +82,57 @@ testing_extension_garbage_collect_ (PeasEngine *engine)
 }
 
 void
+testing_extension_provides_valid_ (PeasEngine *engine)
+{
+  PeasPluginInfo *info;
+
+  info = peas_engine_get_plugin_info (engine, extension_plugin);
+
+  g_assert (peas_engine_load_plugin (engine, info));
+
+  g_assert (peas_engine_provides_extension (engine, info,
+                                            INTROSPECTION_TYPE_CALLABLE));
+}
+
+void
+testing_extension_provides_invalid_ (PeasEngine *engine)
+{
+  PeasPluginInfo *info;
+
+  info = peas_engine_get_plugin_info (engine, extension_plugin);
+
+  /* Not loaded */
+  g_assert (!peas_engine_provides_extension (engine, info,
+                                             INTROSPECTION_TYPE_CALLABLE));
+
+  g_assert (peas_engine_load_plugin (engine, info));
+
+  /* Invalid GType */
+  if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+    {
+      peas_engine_provides_extension (engine, info, G_TYPE_INVALID);
+      exit (0);
+    }
+  g_test_trap_assert_failed ();
+  g_test_trap_assert_stderr ("*CRITICAL*");
+
+
+  /* GObject but not a GInterface */
+  if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+    {
+      peas_engine_provides_extension (engine, info, PEAS_TYPE_ENGINE);
+      exit (0);
+    }
+  g_test_trap_assert_failed ();
+  g_test_trap_assert_stderr ("*CRITICAL*");
+
+
+  /* Does not implement this GType */
+  g_assert (!peas_engine_provides_extension (engine, info,
+                                             INTROSPECTION_TYPE_UNIMPLEMENTED));
+}
+
+void
 testing_extension_create_valid_ (PeasEngine *engine)
 {
   PeasPluginInfo *info;
diff --git a/tests/libpeas/testing/testing-extension.h b/tests/libpeas/testing/testing-extension.h
index 53945db..f0b6663 100644
--- a/tests/libpeas/testing/testing-extension.h
+++ b/tests/libpeas/testing/testing-extension.h
@@ -44,6 +44,8 @@ void testing_extension_test_runner_   (TestingExtensionFixture_ *fixture,
                                        gconstpointer             data);
 
 void testing_extension_garbage_collect_           (PeasEngine *engine);
+void testing_extension_provides_valid_            (PeasEngine *engine);
+void testing_extension_provides_invalid_          (PeasEngine *engine);
 void testing_extension_create_valid_              (PeasEngine *engine);
 void testing_extension_create_invalid_            (PeasEngine *engine);
 void testing_extension_reload_                    (PeasEngine *engine);
@@ -83,6 +85,9 @@ main (int   argc, \
 \
   _EXTENSION_TEST (loader, "garbage-collect", garbage_collect); \
 \
+  _EXTENSION_TEST (loader, "provides-valid", provides_valid); \
+  _EXTENSION_TEST (loader, "provides-invalid", provides_invalid); \
+\
   _EXTENSION_TEST (loader, "create-valid", create_valid); \
   _EXTENSION_TEST (loader, "create-invalid", create_invalid); \
 \



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