diff options
author | Fabian Orccon <cfoch.fabian@gmail.com> | 2017-04-21 17:31:30 -0500 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2019-10-24 13:58:21 -0700 |
commit | 65b8e1a13ad1bc4bc9edcf280ebb28f9779a7a1b (patch) | |
tree | 2b71e25d8d2114aae51d68b7388a31bc792d9ae7 /tests/libpeas | |
parent | 936959ba46bd5205d7f439d9168cf8334f9ed2d3 (diff) | |
download | libpeas-65b8e1a13ad1bc4bc9edcf280ebb28f9779a7a1b.tar.gz |
engine: add peas_engine_create_extension_with_properties()
Adds an introspectable variant of peas_engine_create_extension().
Fixes #8
Diffstat (limited to 'tests/libpeas')
-rw-r--r-- | tests/libpeas/testing/testing-extension.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c index e00588b..122c274 100644 --- a/tests/libpeas/testing/testing-extension.c +++ b/tests/libpeas/testing/testing-extension.c @@ -145,6 +145,49 @@ test_extension_create_valid (PeasEngine *engine, } static void +test_extension_create_valid_without_properties (PeasEngine *engine, + PeasPluginInfo *info) +{ + PeasExtension *extension; + + extension = + peas_engine_create_extension_with_properties (engine, info, + INTROSPECTION_TYPE_CALLABLE, + 0, NULL, NULL); + + g_assert (PEAS_IS_EXTENSION (extension)); + g_assert (INTROSPECTION_IS_CALLABLE (extension)); + + g_object_unref (extension); +} + +static void +test_extension_create_valid_with_properties (PeasEngine *engine, + PeasPluginInfo *info) +{ + PeasExtension *extension; + IntrospectionAbstract *abstract; + GValue prop_values[1] = { G_VALUE_INIT }; + const gchar *prop_names[1] = { "abstract-property" }; + + g_assert (peas_engine_load_plugin (engine, info)); + + g_value_init (&prop_values[0], G_TYPE_INT); + g_value_set_int (&prop_values[0], 47); + extension = + peas_engine_create_extension_with_properties (engine, info, + INTROSPECTION_TYPE_ABSTRACT, + G_N_ELEMENTS (prop_values), + prop_names, + prop_values); + abstract = INTROSPECTION_ABSTRACT (extension); + g_assert_cmpint (introspection_abstract_get_value (abstract), ==, 47); + + g_object_unref (extension); + g_value_unset (&prop_values[0]); +} + +static void test_extension_create_invalid (PeasEngine *engine, PeasPluginInfo *info) { @@ -187,6 +230,72 @@ test_extension_create_invalid (PeasEngine *engine, } static void +test_extension_create_invalid_with_properties (PeasEngine *engine, + PeasPluginInfo *info) +{ + PeasExtension *extension; + GValue prop_values[1] = { G_VALUE_INIT }; + const gchar *prop_names[1] = { NULL }; + GValue prop_values2[1] = { G_VALUE_INIT }; + const gchar *prop_names2[1] = { "does-not-exist" }; + + g_value_init (&prop_values[0], G_TYPE_STRING); + g_value_set_string (&prop_values[0], "foo"); + + testing_util_push_log_hook ("*assertion*G_TYPE_IS_INTERFACE*failed"); + testing_util_push_log_hook ("*does not provide a 'IntrospectionUnimplemented' extension"); + testing_util_push_log_hook ("*property name*should not be NULL."); + testing_util_push_log_hook ("*property value*should*initialized GValue."); + testing_util_push_log_hook ("*assertion*peas_plugin_info_is_loaded*failed"); + + /* Invalid GType */ + extension = peas_engine_create_extension_with_properties (engine, info, + G_TYPE_INVALID, 0, + NULL, NULL); + g_assert (!PEAS_IS_EXTENSION (extension)); + + /* GObject but not a GInterface */ + extension = peas_engine_create_extension_with_properties (engine, info, + PEAS_TYPE_ENGINE, 0, + NULL, NULL); + g_assert (!PEAS_IS_EXTENSION (extension)); + + /* Does not implement this GType */ + extension = + peas_engine_create_extension_with_properties (engine, info, + INTROSPECTION_TYPE_UNIMPLEMENTED, + 0, NULL, NULL); + g_assert (!PEAS_IS_EXTENSION (extension)); + + /* Interface has a NULL property name*/ + extension = + peas_engine_create_extension_with_properties (engine, info, + INTROSPECTION_TYPE_CALLABLE, + G_N_ELEMENTS (prop_names2), + prop_names, prop_values); + g_assert (!PEAS_IS_EXTENSION (extension)); + + /* Interface has a not initialiazed GValue */ + extension = + peas_engine_create_extension_with_properties (engine, info, + INTROSPECTION_TYPE_CALLABLE, + G_N_ELEMENTS (prop_names2), + prop_names2, prop_values2); + g_assert (!PEAS_IS_EXTENSION (extension)); + + /* Not loaded */ + g_assert (peas_engine_unload_plugin (engine, info)); + extension = + peas_engine_create_extension_with_properties (engine, info, + INTROSPECTION_TYPE_CALLABLE, + 0, NULL, NULL); + g_assert (!PEAS_IS_EXTENSION (extension)); + + g_value_unset (&prop_values[0]); + +} + +static void test_extension_create_with_prerequisite (PeasEngine *engine, PeasPluginInfo *info) { @@ -573,7 +682,13 @@ testing_extension_basic (const gchar *loader_) _EXTENSION_TEST (loader, "provides-invalid", provides_invalid); _EXTENSION_TEST (loader, "create-valid", create_valid); + _EXTENSION_TEST (loader, "create-valid-without-properties", + create_valid_without_properties); + _EXTENSION_TEST (loader, "create-valid-with-properties", + create_valid_with_properties); _EXTENSION_TEST (loader, "create-invalid", create_invalid); + _EXTENSION_TEST (loader, "create-invalid-with-properties", + create_invalid_with_properties); _EXTENSION_TEST (loader, "create-with-prerequisite", create_with_prerequisite); _EXTENSION_TEST (loader, "reload", reload); |