[libpeas: 16/18] Expand peas_engine_set_loaded_plugins() test



commit 5fa94f3d4ff95ecebec2422f595a3b8f37c89a89
Author: Garrett Regier <alias301 gmail com>
Date:   Thu Mar 3 04:47:12 2011 -0800

    Expand peas_engine_set_loaded_plugins() test

 tests/libpeas/engine.c |   59 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 47 insertions(+), 12 deletions(-)
---
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index ae55ecf..79a09d1 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -225,7 +225,9 @@ load_plugin_cb (PeasEngine     *engine,
                 PeasPluginInfo *info,
                 gint           *loaded)
 {
-  ++(*loaded);
+  /* PeasEngine:load is not stopped if loading fails */
+  if (peas_plugin_info_is_loaded (info))
+    ++(*loaded);
 }
 
 static void
@@ -252,36 +254,69 @@ test_engine_loaded_plugins (PeasEngine *engine)
 {
   PeasPluginInfo *info;
   gint loaded = 0;
+  gchar **load_plugins;
   gchar **loaded_plugins = NULL;
 
-  g_signal_connect (engine,
-                    "load-plugin",
-                    G_CALLBACK (load_plugin_cb),
-                    (gpointer) &loaded);
-  g_signal_connect (engine,
-                    "unload-plugin",
-                    G_CALLBACK (unload_plugin_cb),
-                    (gpointer) &loaded);
+  g_signal_connect_after (engine,
+                          "load-plugin",
+                          G_CALLBACK (load_plugin_cb),
+                          (gpointer) &loaded);
+  g_signal_connect_after (engine,
+                          "unload-plugin",
+                          G_CALLBACK (unload_plugin_cb),
+                          (gpointer) &loaded);
   g_signal_connect (engine,
                     "notify::loaded-plugins",
                     G_CALLBACK (notify_loaded_plugins_cb),
                     (gpointer) &loaded_plugins);
 
 
+  /* Need to cause the plugin to be unavailable */
+  info = peas_engine_get_plugin_info (engine, "unavailable");
+  g_assert (!peas_engine_load_plugin (engine, info));
+
   info = peas_engine_get_plugin_info (engine, "loadable");
 
-  g_assert (peas_engine_load_plugin (engine, info));
+  g_object_notify (G_OBJECT (engine), "loaded-plugins");
+
+
+  /* Unload all plugins */
+  peas_engine_set_loaded_plugins (engine, NULL);
+  g_assert_cmpint (loaded, ==, 0);
+  g_assert (loaded_plugins != NULL);
+  g_assert (loaded_plugins[0] == NULL);
+
+  load_plugins = g_new0 (gchar *, 1);
+  peas_engine_set_loaded_plugins (engine, (const gchar **) load_plugins);
+  g_strfreev (load_plugins);
+
+  g_assert_cmpint (loaded, ==, 0);
+  g_assert (loaded_plugins != NULL);
+  g_assert (loaded_plugins[0] == NULL);
+
+
+  /* Load a plugin */
+  load_plugins = g_new0 (gchar *, 2);
+  load_plugins[0] = g_strdup ("loadable");
+  peas_engine_set_loaded_plugins (engine, (const gchar **) load_plugins);
+  g_strfreev (load_plugins);
 
   g_assert_cmpint (loaded, ==, 1);
   g_assert (loaded_plugins != NULL);
   g_assert_cmpstr (loaded_plugins[0], ==, "loadable");
   g_assert (loaded_plugins[1] == NULL);
 
-  g_assert (peas_engine_unload_plugin (engine, info));
 
+  /* Try to load an unavailable plugin */
+  load_plugins = g_new0 (gchar *, 2);
+  load_plugins[0] = g_strdup ("unavailable");
+  peas_engine_set_loaded_plugins (engine, (const gchar **) load_plugins);
+  g_strfreev (load_plugins);
+
+  g_assert_cmpint (loaded, ==, 0);
   g_assert (loaded_plugins != NULL);
   g_assert (loaded_plugins[0] == NULL);
-  g_assert_cmpint (loaded, ==, 0);
+
 
   g_assert (peas_engine_load_plugin (engine, info));
 



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