[libpeas] Add tests for extensions being able to get the PeasPluginInfo



commit 9c57921ec56858442c89d12e9ec254830407900b
Author: Garrett Regier <alias301 gmail com>
Date:   Mon Mar 21 06:40:10 2011 -0700

    Add tests for extensions being able to get the PeasPluginInfo

 tests/libpeas/Makefile.am        |    5 ++-
 tests/libpeas/extension-c.c      |   28 ++++++++++++++++++++++
 tests/libpeas/extension-python.c |   27 +++++++++++++++++++++
 tests/libpeas/extension-seed.c   |   47 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 105 insertions(+), 2 deletions(-)
---
diff --git a/tests/libpeas/Makefile.am b/tests/libpeas/Makefile.am
index e074407..a859306 100644
--- a/tests/libpeas/Makefile.am
+++ b/tests/libpeas/Makefile.am
@@ -32,13 +32,14 @@ if ENABLE_PYTHON
 TEST_PROGS               += extension-python
 extension_python_SOURCES  = extension-python.c
 extension_python_CFLAGS   = $(PYTHON_CFLAGS)
-extension_python_LDADD    = $(progs_ldadd)
+extension_python_LDADD    = $(progs_ldadd) $(PYTHON_LIBS)
 endif
 
 if ENABLE_SEED
 TEST_PROGS             += extension-seed
 extension_seed_SOURCES  = extension-seed.c
-extension_seed_LDADD    = $(progs_ldadd)
+extension_seed_CFLAGS   = $(SEED_CFLAGS)
+extension_seed_LDADD    = $(progs_ldadd)  $(SEED_LIBS)
 endif
 
 TEST_PROGS            += extension-set
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index b34f3f9..c387734 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -23,10 +23,12 @@
 #include <config.h>
 #endif
 
+#include "libpeas/peas-extension-base.h"
 #include "loaders/c/peas-extension-c.h"
 
 #include "testing/testing-extension.h"
 #include "introspection/introspection-callable.h"
+#include "introspection/introspection-properties.h"
 
 static void
 test_extension_c_instance_refcount (PeasEngine *engine)
@@ -55,6 +57,31 @@ test_extension_c_instance_refcount (PeasEngine *engine)
   g_object_unref (extension);
 }
 
+static void
+test_extension_c_plugin_info (PeasEngine *engine)
+{
+  PeasPluginInfo *info;
+  PeasExtension *extension;
+  PeasExtensionBase *instance;
+
+  info = peas_engine_get_plugin_info (engine, "extension-c");
+
+  g_assert (peas_engine_load_plugin (engine, info));
+
+  extension = peas_engine_create_extension (engine, info,
+                                            INTROSPECTION_TYPE_PROPERTIES,
+                                            NULL);
+
+  g_assert (PEAS_IS_EXTENSION (extension));
+
+  instance = (PeasExtensionBase *) ((PeasExtensionC *) extension)->instance;
+
+  g_assert (PEAS_IS_EXTENSION_BASE (instance));
+  g_assert (peas_extension_base_get_plugin_info (instance) == info);
+
+  g_object_unref (extension);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -65,6 +92,7 @@ main (int   argc,
   EXTENSION_TESTS (c);
 
   EXTENSION_TEST (c, "instance-refcount", instance_refcount);
+  EXTENSION_TEST (c, "plugin-info", plugin_info);
 
   return testing_run_tests ();
 }
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index 9010f69..00c1d0b 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -102,6 +102,32 @@ test_extension_python_activatable_subject_refcount (PeasEngine *engine)
   g_object_unref (object);
 }
 
+static void
+test_extension_python_plugin_info (PeasEngine *engine)
+{
+  PeasPluginInfo *info;
+  PeasExtension *extension;
+  PyObject *instance;
+  PyObject *plugin_info;
+
+  info = peas_engine_get_plugin_info (engine, "extension-python");
+
+  g_assert (peas_engine_load_plugin (engine, info));
+
+  extension = peas_engine_create_extension (engine, info,
+                                            INTROSPECTION_TYPE_CALLABLE,
+                                            NULL);
+
+  g_assert (PEAS_IS_EXTENSION (extension));
+
+  instance = ((PeasExtensionPython *) extension)->instance;
+
+  plugin_info = PyObject_GetAttrString (instance, "plugin_info");
+  g_assert (((PyGBoxed *) plugin_info)->boxed == info);
+
+  g_object_unref (extension);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -113,6 +139,7 @@ main (int   argc,
 
   EXTENSION_TEST (python, "instance-refcount", instance_refcount);
   EXTENSION_TEST (python, "activatable-subject-refcount", activatable_subject_refcount);
+  EXTENSION_TEST (python, "plugin-info", plugin_info);
 
   return testing_run_tests ();
 }
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index 65d60c9..9df58dc 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -23,7 +23,52 @@
 #include <config.h>
 #endif
 
+#include <seed.h>
+
+#include "loaders/seed/peas-extension-seed.h"
+
 #include "testing/testing-extension.h"
+#include "introspection/introspection-callable.h"
+
+gboolean seed_gvalue_from_seed_value (SeedContext    ctx,
+                                      SeedValue      val,
+                                      GType          type,
+                                      GValue        *gval,
+                                      SeedException *exception);
+
+static void
+test_extension_seed_plugin_info (PeasEngine *engine)
+{
+  PeasPluginInfo *info;
+  PeasExtension *extension;
+  PeasExtensionSeed *sexten;
+  SeedValue seed_value;
+  GValue gvalue = { 0 };
+
+  info = peas_engine_get_plugin_info (engine, "extension-seed");
+
+  g_assert (peas_engine_load_plugin (engine, info));
+
+  extension = peas_engine_create_extension (engine, info,
+                                            INTROSPECTION_TYPE_CALLABLE,
+                                            NULL);
+
+  g_assert (PEAS_IS_EXTENSION (extension));
+
+  sexten = (PeasExtensionSeed *) extension;
+  seed_value = seed_object_get_property (sexten->js_context, sexten->js_object,
+                                         "plugin_info");
+
+  g_assert (seed_gvalue_from_seed_value (sexten->js_context, seed_value,
+                                         PEAS_TYPE_PLUGIN_INFO, &gvalue,
+                                         NULL));
+
+  g_assert (g_value_get_boxed (&gvalue) == info);
+
+  g_value_unset (&gvalue);
+
+  g_object_unref (extension);
+}
 
 int
 main (int   argc,
@@ -35,5 +80,7 @@ main (int   argc,
 
   EXTENSION_TESTS (seed);
 
+  EXTENSION_TEST (seed, "plugin-info", plugin_info);
+
   return testing_run_tests ();
 }



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