[libpeas] Add a test for a plugin that is not loadable



commit eeeba0bb26c92055c002099bf5047457099acc52
Author: Garrett Regier <alias301 gmail com>
Date:   Sat Mar 5 00:38:36 2011 -0800

    Add a test for a plugin that is not loadable

 tests/libpeas/engine.c                    |   23 +++++++++++++++++++++++
 tests/libpeas/plugins/Makefile.am         |    1 +
 tests/libpeas/plugins/not-loadable.plugin |    7 +++++++
 3 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index 5139d8f..53c7e97 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -221,6 +221,28 @@ test_engine_unavailable_plugin (PeasEngine *engine)
 }
 
 static void
+test_engine_not_loadable_plugin (PeasEngine *engine)
+{
+  GError *error = NULL;
+  PeasPluginInfo *info;
+
+  testing_util_push_log_hook ("*libnot-loadable.so: cannot open shared "
+                              "object file: No such file or directory");
+  testing_util_push_log_hook ("Could not load plugin module: 'Not loadable'");
+  testing_util_push_log_hook ("Error loading plugin 'Not loadable'");
+
+  info = peas_engine_get_plugin_info (engine, "not-loadable");
+
+  g_assert (!peas_engine_load_plugin (engine, info));
+  g_assert (!peas_plugin_info_is_loaded (info));
+  g_assert (!peas_plugin_info_is_available (info, &error));
+  g_assert_error (error, PEAS_PLUGIN_INFO_ERROR,
+                  PEAS_PLUGIN_INFO_ERROR_LOADING_FAILED);
+
+  g_error_free (error);
+}
+
+static void
 load_plugin_cb (PeasEngine     *engine,
                 PeasPluginInfo *info,
                 gint           *loaded)
@@ -439,6 +461,7 @@ main (int    argc,
   TEST ("unload-plugin-with-self-dep", unload_plugin_with_self_dep);
 
   TEST ("unavailable-plugin", unavailable_plugin);
+  TEST ("not-loadable-plugin", not_loadable_plugin);
 
   TEST ("loaded-plugins", loaded_plugins);
 
diff --git a/tests/libpeas/plugins/Makefile.am b/tests/libpeas/plugins/Makefile.am
index e130dd9..6c4eee3 100644
--- a/tests/libpeas/plugins/Makefile.am
+++ b/tests/libpeas/plugins/Makefile.am
@@ -19,6 +19,7 @@ noinst_PLUGIN = \
 	invalid-loader.plugin		\
 	nonexistent-dep.plugin		\
 	nonexistent-loader.plugin	\
+	not-loadable.plugin		\
 	os-dependant-help.plugin
 
 EXTRA_DIST = $(noinst_PLUGIN)
diff --git a/tests/libpeas/plugins/not-loadable.plugin b/tests/libpeas/plugins/not-loadable.plugin
new file mode 100644
index 0000000..035b617
--- /dev/null
+++ b/tests/libpeas/plugins/not-loadable.plugin
@@ -0,0 +1,7 @@
+[Plugin]
+Module=not-loadable
+IAge=2
+Name=Not loadable
+Description=This plugin is not loadable.
+Authors=Garrett Regier
+Copyright=Copyright © 2011 Garrett Regier



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