[grilo] check: test for registry and unregistry of plugins
- From: Victor Manuel Jaquez Leal <vjaquez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] check: test for registry and unregistry of plugins
- Date: Thu, 19 Aug 2010 19:04:53 +0000 (UTC)
commit 1eba27545f9b40dc7025ef143034575ed6b49cc6
Author: VÃctor Manuel Jáquez Leal <vjaquez igalia com>
Date: Thu Aug 19 20:54:41 2010 +0200
check: test for registry and unregistry of plugins
Based on the patch submitted by Simón Pena <spenap gmail com>
https://bugzilla.gnome.org/show_bug.cgi?id=627207
x# Please enter the commit message for your changes. Lines starting
src/tests/registry.c | 84 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 71 insertions(+), 13 deletions(-)
---
diff --git a/src/tests/registry.c b/src/tests/registry.c
index 09f5a23..5c5d772 100644
--- a/src/tests/registry.c
+++ b/src/tests/registry.c
@@ -38,7 +38,8 @@ registry_load_error_handler (const gchar *log_domain,
if (g_str_has_prefix (message, "Failed to initialize plugin") ||
g_str_has_prefix (message, "Configuration not provided") ||
g_strcmp0 (message, "Missing configuration") == 0 ||
- g_str_has_prefix (message, "Could not open plugin directory")) {
+ g_str_has_prefix (message, "Could not open plugin directory") ||
+ g_str_has_prefix (message, "Could not read XML file")) {
return FALSE;
}
@@ -46,6 +47,28 @@ registry_load_error_handler (const gchar *log_domain,
}
#endif
+typedef struct {
+ GrlPluginRegistry *registry;
+ GMainLoop *loop;
+} RegistryFixture;
+
+static void
+registry_fixture_setup (RegistryFixture *fixture, gconstpointer data)
+{
+#if GLIB_CHECK_VERSION(2,22,0)
+ g_test_log_set_fatal_handler (registry_load_error_handler, NULL);
+#endif
+
+ fixture->registry = grl_plugin_registry_get_default ();
+ fixture->loop = g_main_loop_new (NULL, TRUE);
+}
+
+static void
+registry_fixture_teardown (RegistryFixture *fixture, gconstpointer data)
+{
+ g_main_loop_unref(fixture->loop);
+}
+
static void
registry_init (void)
{
@@ -56,31 +79,66 @@ registry_init (void)
}
static void
-registry_load (void)
+registry_load (RegistryFixture *fixture, gconstpointer data)
{
- GrlPluginRegistry *registry;
gboolean res;
-#if GLIB_CHECK_VERSION(2,22,0)
- g_test_log_set_fatal_handler (registry_load_error_handler, NULL);
-#endif
-
- registry = grl_plugin_registry_get_default ();
- res = grl_plugin_registry_load_all (registry);
+ res = grl_plugin_registry_load_all (fixture->registry);
g_assert_cmpint (res, ==, TRUE);
}
+static void
+registry_unregister (RegistryFixture *fixture, gconstpointer data)
+{
+ GrlMediaPlugin **sources;
+ int i;
+
+ g_test_bug ("627207");
+
+ sources = grl_plugin_registry_get_sources (fixture->registry, FALSE);
+
+ i = 0;
+ while (sources[i]) {
+ grl_plugin_registry_unregister_source (fixture->registry, sources[i]);
+ i++;
+ }
+ g_free (sources);
+
+ /* We expect to have loaded sources */
+ g_assert_cmpint (i, !=, 0);
+
+ sources = grl_plugin_registry_get_sources (fixture->registry, FALSE);
+ for (i = 0; sources[i]; i++)
+ ;
+ g_free (sources);
+
+ /* After unregistering the sources, we don't expect any */
+ g_assert_cmpint (i, ==, 0);
+}
+
int
-main (int argc, char *argv[])
+main (int argc, char **argv)
{
- g_type_init ();
g_test_init (&argc, &argv, NULL);
- //g_test_bug_base ("http://bugs.gnome.org/%s");
+ g_test_bug_base ("http://bugs.gnome.org/%s");
+
+ grl_init (&argc, &argv);
/* registry tests */
g_test_add_func ("/registry/init", registry_init);
- g_test_add_func ("/registry/load", registry_load);
+
+ g_test_add ("/registry/load",
+ RegistryFixture, NULL,
+ registry_fixture_setup,
+ registry_load,
+ registry_fixture_teardown);
+
+ g_test_add ("/registry/unregister",
+ RegistryFixture, NULL,
+ registry_fixture_setup,
+ registry_unregister,
+ registry_fixture_teardown);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]