plugin-manager: Add API to unload all plugins

And add tests for it.

Signed-off-by: Evangelos Ribeiro Tzaras <devrtz@fortysixandtwo.eu>
Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/796>
This commit is contained in:
Evangelos Ribeiro Tzaras
2025-10-13 10:43:04 +02:00
parent 33e5b193a0
commit 9fab9ec7a5
4 changed files with 62 additions and 3 deletions

View File

@@ -66,6 +66,9 @@ on_idle_quit (gpointer user_data)
g_application_quit (app);
g_assert_true (calls_plugin_manager_has_any_plugins (plugins));
g_assert_true (calls_plugin_manager_unload_all_plugins (plugins, &error));
g_assert_no_error (error);
g_assert_false (calls_plugin_manager_has_any_plugins (plugins));
return G_SOURCE_REMOVE;
}

View File

@@ -112,13 +112,46 @@ test_calls_plugin_loading (void)
}
gint
main (gint argc,
gchar *argv[])
static void
test_calls_plugin_unload_all (void)
{
CallsPluginManager *manager = calls_plugin_manager_get_default ();
g_autoptr (GError) error = NULL;
g_assert_false (calls_plugin_manager_has_any_plugins (manager));
g_assert_true (calls_plugin_manager_load_plugin (manager, "dummy", &error));
g_assert_no_error (error);
g_assert_true (calls_plugin_manager_has_plugin (manager, "dummy"));
g_assert_true (calls_plugin_manager_load_plugin (manager, "mm", &error));
g_assert_no_error (error);
g_assert_true (calls_plugin_manager_has_plugin (manager, "mm"));
g_assert_true (calls_plugin_manager_load_plugin (manager, "sip", &error));
g_assert_no_error (error);
g_assert_true (calls_plugin_manager_has_plugin (manager, "sip"));
g_assert_true (calls_plugin_manager_has_any_plugins (manager));
g_assert_true (calls_plugin_manager_unload_all_plugins (manager, &error));
g_assert_no_error (error);
g_assert_false (calls_plugin_manager_has_plugin (manager, "dummy"));
g_assert_false (calls_plugin_manager_has_plugin (manager, "mm"));
g_assert_false (calls_plugin_manager_has_plugin (manager, "sip"));
g_assert_false (calls_plugin_manager_has_any_plugins (manager));
g_assert_finalize_object (manager);
}
int
main (int argc,
char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/Calls/Plugins/load_plugins", test_calls_plugin_loading);
g_test_add_func ("/Calls/Plugins/unload_all", test_calls_plugin_unload_all);
return g_test_run ();
}