summaryrefslogtreecommitdiff
path: root/tests/libpeas
diff options
context:
space:
mode:
authorFabian Orccon <cfoch.fabian@gmail.com>2017-01-30 12:01:43 -0500
committerChristian Hergert <chergert@redhat.com>2019-10-24 13:57:32 -0700
commit936959ba46bd5205d7f439d9168cf8334f9ed2d3 (patch)
tree62329c79230546b28258d8df4866510043069998 /tests/libpeas
parentf7aae3257e5654a9c3be9bad85dcf5e7a12be6ed (diff)
downloadlibpeas-936959ba46bd5205d7f439d9168cf8334f9ed2d3.tar.gz
extension-set: adds peas_extension_set_new_with_properties()
Adds a new introspectable variant of peas_extension_set_new() for language bindings. Fixes #8
Diffstat (limited to 'tests/libpeas')
-rw-r--r--tests/libpeas/extension-set.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c
index c4d4d3c..3264651 100644
--- a/tests/libpeas/extension-set.c
+++ b/tests/libpeas/extension-set.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <glib.h>
+#include <glib-object.h>
#include <libpeas/peas.h>
#include "testing/testing.h"
@@ -147,6 +148,48 @@ test_extension_set_create_valid (PeasEngine *engine)
}
static void
+valid_extension_added_cb (PeasExtensionSet *extension_set,
+ PeasPluginInfo *info,
+ PeasExtension *extension,
+ GObject **obj_ptr)
+{
+ g_object_get (PEAS_ACTIVATABLE (extension), "object", obj_ptr, NULL);
+}
+
+static void
+test_extension_set_create_valid_with_properties (PeasEngine *engine)
+{
+ PeasPluginInfo *info;
+ PeasExtensionSet *extension_set;
+ GValue prop_value = G_VALUE_INIT;
+ GObject *obj, *obj_cmp;
+ const gchar *prop_names[1] = { "object" };
+
+ obj = g_object_new (G_TYPE_OBJECT, NULL);
+ g_value_init (&prop_value, G_TYPE_OBJECT);
+ g_value_set_object (&prop_value, obj);
+
+ extension_set = peas_extension_set_new_with_properties (engine,
+ PEAS_TYPE_ACTIVATABLE,
+ G_N_ELEMENTS (prop_names),
+ prop_names,
+ &prop_value);
+ g_signal_connect (extension_set,
+ "extension-added",
+ G_CALLBACK (valid_extension_added_cb),
+ &obj_cmp);
+ info = peas_engine_get_plugin_info (engine, "builtin");
+
+ g_assert (peas_engine_load_plugin (engine, info));
+ g_assert (obj == obj_cmp);
+
+ g_assert (PEAS_IS_EXTENSION_SET (extension_set));
+ g_object_unref (extension_set);
+ g_value_unset (&prop_value);
+}
+
+
+static void
test_extension_set_create_invalid (PeasEngine *engine)
{
PeasExtensionSet *extension_set;
@@ -173,6 +216,62 @@ test_extension_set_create_invalid (PeasEngine *engine)
}
static void
+test_extension_set_create_invalid_with_properties (PeasEngine *engine)
+{
+ PeasExtensionSet *extension_set;
+ GValue prop_values[2] = { G_VALUE_INIT };
+ const gchar *prop_names[2] = { "object", NULL };
+ const gchar *prop_names_not_exist[1] = { "aleb" };
+ guint n_elements;
+
+ testing_util_push_log_hook ("*property name*should not be NULL.");
+ testing_util_push_log_hook ("*assertion*G_TYPE_IS_INTERFACE*failed");
+ testing_util_push_log_hook ("*should be an initialized GValue.");
+ testing_util_push_log_hook ("*has no property named 'aleb'*");
+
+ g_value_init (&prop_values[0], G_TYPE_POINTER);
+ g_value_set_pointer (&prop_values[0], NULL);
+
+ /* Interface has a NULL property name*/
+ n_elements = G_N_ELEMENTS (prop_values);
+ extension_set = peas_extension_set_new_with_properties (engine,
+ PEAS_TYPE_ACTIVATABLE,
+ n_elements,
+ prop_names,
+ prop_values);
+ g_assert (!PEAS_IS_EXTENSION_SET (extension_set));
+ g_value_unset (&prop_values[0]);
+
+ /* Invalid GType */
+ extension_set = peas_extension_set_new_with_properties (engine,
+ G_TYPE_INVALID,
+ 0, NULL, NULL);
+ g_assert (!PEAS_IS_EXTENSION_SET (extension_set));
+
+ /* Uninitialized GValue */
+ n_elements = 1;
+ extension_set = peas_extension_set_new_with_properties (engine,
+ PEAS_TYPE_ACTIVATABLE,
+ n_elements,
+ prop_names,
+ prop_values);
+ g_assert (!PEAS_IS_EXTENSION_SET (extension_set));
+
+ /* Uninitialized GValue*/
+ g_value_init (&prop_values[0], G_TYPE_POINTER);
+ g_value_set_pointer (&prop_values[0], NULL);
+ n_elements = G_N_ELEMENTS (prop_names_not_exist);
+ extension_set = peas_extension_set_new_with_properties (engine,
+ PEAS_TYPE_ACTIVATABLE,
+ n_elements,
+ prop_names_not_exist,
+ prop_values);
+ g_assert (!PEAS_IS_EXTENSION_SET (extension_set));
+ g_value_unset (&prop_values[0]);
+}
+
+
+static void
test_extension_set_extension_added (PeasEngine *engine)
{
gint active;
@@ -345,6 +444,8 @@ main (int argc,
TEST ("create-valid", create_valid);
TEST ("create-invalid", create_invalid);
+ TEST ("create-valid-with-properties", create_valid_with_properties);
+ TEST ("create-invalid-with-properties", create_invalid_with_properties);
TEST ("extension-added", extension_added);
TEST ("extension-removed", extension_removed);