# HG changeset patch
# Node ID 12faf8af2a7c6ca94fb79260ebd36eaf5ff2b848
# Parent  9d22dec69f19eb25207e88a34d1d5bd45279da93
diff --git a/gplugin/tests/test-auto-load.c b/gplugin/tests/test-auto-load.c
--- a/gplugin/tests/test-auto-load.c
+++ b/gplugin/tests/test-auto-load.c
@@ -15,8 +15,6 @@
  * License along with this library; if not, see <https://www.gnu.org/licenses/>.
  */
 
-#include <stdlib.h>
-
 #include <glib.h>
 
 #include <gplugin.h>
@@ -28,10 +26,16 @@
 static void
 test_auto_load_pass(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
 
-	gplugin_manager_remove_paths(manager);
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	gplugin_manager_append_path(manager, TEST_AUTO_LOAD_PASS_DIR);
 	gplugin_manager_refresh(manager);
 
@@ -43,13 +47,22 @@
 		gplugin_plugin_get_state(plugin),
 		==,
 		GPLUGIN_PLUGIN_STATE_LOADED);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_auto_load_fail(void)
 {
 	if(g_test_subprocess()) {
-		GPluginManager *manager = gplugin_manager_get_default();
+		GPluginLoader *loader = NULL;
+		GPluginManager *manager = NULL;
+
+		manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+		loader = gplugin_native_loader_new();
+		gplugin_manager_register_loader(manager, loader, NULL);
+		g_clear_object(&loader);
 
 		/* this test is very simple since we can't get the exact error
 		 * condition that we want.
@@ -60,10 +73,13 @@
 		 * can't see the plugin stored twice.  This has been fixed in the code,
 		 * but it has to be looked for manually.
 		 */
-		gplugin_manager_remove_paths(manager);
 		gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
 		gplugin_manager_append_path(manager, TEST_AUTO_LOAD_FAIL_DIR);
 		gplugin_manager_refresh(manager);
+
+		g_assert_finalize_object(manager);
+
+		g_assert_not_reached();
 	}
 
 	g_test_trap_subprocess(NULL, 0, 0);
@@ -101,9 +117,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	/* test the load on query flag */
 	g_test_add_func("/loaders/native/auto-load/pass", test_auto_load_pass);
diff --git a/gplugin/tests/test-bind-global.c b/gplugin/tests/test-bind-global.c
--- a/gplugin/tests/test-bind-global.c
+++ b/gplugin/tests/test-bind-global.c
@@ -31,10 +31,16 @@
 static void
 test_bind_global(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
 
-	gplugin_manager_remove_paths(manager);
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	gplugin_manager_append_path(manager, TEST_BIND_GLOBAL_DIR);
 	gplugin_manager_refresh(manager);
 
@@ -42,6 +48,8 @@
 	g_assert_nonnull(plugin);
 	g_assert_true(GPLUGIN_IS_PLUGIN(plugin));
 	g_assert_true(GPLUGIN_IS_NATIVE_PLUGIN(plugin));
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -50,9 +58,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	/* test the load on query flag */
 	g_test_add_func("/loaders/native/bind-global", test_bind_global);
diff --git a/gplugin/tests/test-core.c b/gplugin/tests/test-core.c
--- a/gplugin/tests/test-core.c
+++ b/gplugin/tests/test-core.c
@@ -148,7 +148,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/core/init_uninit", test_gplugin_init_uninit);
 	g_test_add_func("/core/init_init_uninit", test_gplugin_init_init_uninit);
diff --git a/gplugin/tests/test-dynamic-type.c b/gplugin/tests/test-dynamic-type.c
--- a/gplugin/tests/test-dynamic-type.c
+++ b/gplugin/tests/test-dynamic-type.c
@@ -27,12 +27,19 @@
 static void
 test_dynamic_type(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *provider = NULL, *user = NULL;
 	GPluginPluginState state;
 	GError *error = NULL;
 	gboolean ret = FALSE;
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	gplugin_manager_append_path(manager, TEST_DYNAMIC_TYPE_DIR);
 	gplugin_manager_refresh(manager);
 
@@ -71,6 +78,8 @@
 
 	state = gplugin_plugin_get_state(provider);
 	g_assert_cmpint(state, ==, GPLUGIN_PLUGIN_STATE_QUERIED);
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -79,9 +88,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	/* test dynamic types */
 	g_test_add_func("/loaders/native/dynamic-type", test_dynamic_type);
diff --git a/gplugin/tests/test-find-plugins.c b/gplugin/tests/test-find-plugins.c
--- a/gplugin/tests/test-find-plugins.c
+++ b/gplugin/tests/test-find-plugins.c
@@ -18,6 +18,7 @@
 #include <glib.h>
 
 #include <gplugin.h>
+#include <gplugin-native.h>
 
 /******************************************************************************
  * Helpers
@@ -26,12 +27,11 @@
 test_gplugin_manager_foreach_load_plugins(
 	G_GNUC_UNUSED const char *id,
 	GSList *plugins,
-	G_GNUC_UNUSED gpointer data)
+	gpointer data)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
-	GSList *l = NULL;
+	GPluginManager *manager = data;
 
-	for(l = plugins; l != NULL; l = l->next) {
+	for(GSList *l = plugins; l != NULL; l = l->next) {
 		gplugin_manager_load_plugin(manager, GPLUGIN_PLUGIN(l->data), NULL);
 	}
 }
@@ -40,12 +40,11 @@
 test_gplugin_manager_foreach_unload_plugins(
 	G_GNUC_UNUSED const char *id,
 	GSList *plugins,
-	G_GNUC_UNUSED gpointer data)
+	gpointer data)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
-	GSList *l = NULL;
+	GPluginManager *manager = data;
 
-	for(l = plugins; l != NULL; l = l->next) {
+	for(GSList *l = plugins; l != NULL; l = l->next) {
 		gplugin_manager_unload_plugin(manager, GPLUGIN_PLUGIN(l->data), NULL);
 	}
 }
@@ -53,8 +52,8 @@
 /******************************************************************************
  * Tests
  *****************************************************************************/
-/*< private >
- * test_gplugin_manager_find_plugins_with_state:
+/**
+ * test_gplugin_manager_find_plugins_with_state: (skip)
  *
  * Runs through the normal plugins in the plugins directory, trying to progress
  * their state each iteration while checking that
@@ -66,6 +65,7 @@
 static void
 test_gplugin_manager_find_plugins_with_state(void)
 {
+	GPluginLoader *loader = NULL;
 	GPluginManager *manager = NULL;
 	GSList *plugins = NULL;
 
@@ -85,9 +85,11 @@
 	int UNLOADED = 3; /* unloaded plugins go back to the queried state */
 	int UNLOAD_FAILED = 2;
 
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
-	manager = gplugin_manager_get_default();
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
 
 	gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
 	gplugin_manager_refresh(manager);
@@ -103,7 +105,7 @@
 	gplugin_manager_foreach(
 		manager,
 		test_gplugin_manager_foreach_load_plugins,
-		NULL);
+		manager);
 
 	/* make sure we have the proper number loaded */
 	plugins = gplugin_manager_find_plugins_with_state(
@@ -123,7 +125,7 @@
 	gplugin_manager_foreach(
 		manager,
 		test_gplugin_manager_foreach_unload_plugins,
-		NULL);
+		manager);
 
 	/* make sure we have the proper number unloaded */
 	plugins = gplugin_manager_find_plugins_with_state(
@@ -139,7 +141,7 @@
 	g_assert_cmpint(g_slist_length(plugins), ==, UNLOAD_FAILED);
 	g_slist_free_full(plugins, g_object_unref);
 
-	gplugin_uninit();
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -148,7 +150,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func(
 		"/manager/find_plugins/with_state",
diff --git a/gplugin/tests/test-id-collision.c b/gplugin/tests/test-id-collision.c
--- a/gplugin/tests/test-id-collision.c
+++ b/gplugin/tests/test-id-collision.c
@@ -27,10 +27,15 @@
 static void
 test_id_collision(void)
 {
+	GPluginLoader *loader = NULL;
 	GPluginManager *manager = NULL;
 	GSList *plugins = NULL;
 
-	manager = gplugin_manager_get_default();
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
 
 	gplugin_manager_append_path(manager, TEST_ID_COLLISION_DIR);
 	gplugin_manager_refresh(manager);
@@ -41,6 +46,8 @@
 	g_assert_cmpuint(g_slist_length(plugins), ==, 2);
 
 	g_slist_free_full(plugins, g_object_unref);
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -49,9 +56,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/loaders/native/id-collision", test_id_collision);
 
diff --git a/gplugin/tests/test-id-normalize.c b/gplugin/tests/test-id-normalize.c
--- a/gplugin/tests/test-id-normalize.c
+++ b/gplugin/tests/test-id-normalize.c
@@ -30,7 +30,7 @@
 
 	info = gplugin_plugin_info_new(input, 0, NULL);
 	normalized = gplugin_plugin_info_get_id_normalized(info);
-	g_object_unref(info);
+	g_assert_finalize_object(info);
 
 	g_assert_cmpstr(normalized, ==, expected);
 
@@ -95,9 +95,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/id-normalize/null", test_id_normalize_null);
 	g_test_add_func("/id-normalize/alpha/upper", test_id_normalize_alpha_upper);
diff --git a/gplugin/tests/test-loader-registration.c b/gplugin/tests/test-loader-registration.c
--- a/gplugin/tests/test-loader-registration.c
+++ b/gplugin/tests/test-loader-registration.c
@@ -253,7 +253,7 @@
 {
 	int r = 0;
 
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
 
diff --git a/gplugin/tests/test-loader.c b/gplugin/tests/test-loader.c
--- a/gplugin/tests/test-loader.c
+++ b/gplugin/tests/test-loader.c
@@ -329,7 +329,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/loader/properties", test_gplugin_loader_properties);
 	g_test_add_func("/loader/methods", test_gplugin_loader_methods);
diff --git a/gplugin/tests/test-native-loader.c b/gplugin/tests/test-native-loader.c
--- a/gplugin/tests/test-native-loader.c
+++ b/gplugin/tests/test-native-loader.c
@@ -27,11 +27,18 @@
 static void
 test_broken_depend_plugin_load(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
 	GPluginPluginState state;
 	GError *error = NULL;
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	/* add the test directory to the plugin manager's search paths */
 	gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
 
@@ -51,6 +58,8 @@
 	g_assert_false(gplugin_manager_load_plugin(manager, plugin, &error));
 	g_assert_error(error, GPLUGIN_DOMAIN, 0);
 	g_error_free(error);
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -60,9 +69,16 @@
 test_query_error(void)
 {
 	if(g_test_subprocess()) {
-		GPluginManager *manager = gplugin_manager_get_default();
+		GPluginLoader *loader = NULL;
+		GPluginManager *manager = NULL;
 		GPluginPlugin *plugin = NULL;
 
+		manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+		loader = gplugin_native_loader_new();
+		gplugin_manager_register_loader(manager, loader, NULL);
+		g_clear_object(&loader);
+
 		/* add the test directory to the plugin manager's search paths */
 		gplugin_manager_append_path(manager, TEST_BAD_PLUGINS_DIR);
 
@@ -72,6 +88,10 @@
 		/* find the query-error plugin */
 		plugin = gplugin_manager_find_plugin(manager, "gplugin/query-error");
 		g_assert_null(plugin);
+
+		g_assert_finalize_object(manager);
+
+		g_assert_not_reached();
 	}
 
 	g_test_trap_subprocess(NULL, 0, 0);
@@ -84,9 +104,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	gplugin_loader_tests_main(NULL, TEST_PLUGINS_DIR, "native");
 
diff --git a/gplugin/tests/test-newest-version.c b/gplugin/tests/test-newest-version.c
--- a/gplugin/tests/test-newest-version.c
+++ b/gplugin/tests/test-newest-version.c
@@ -18,6 +18,7 @@
 #include <glib.h>
 
 #include <gplugin.h>
+#include <gplugin-native.h>
 
 /******************************************************************************
  * Helpers
@@ -25,10 +26,17 @@
 static void
 test_newest_version(const char *id, const char *version)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
 	GPluginPluginInfo *info = NULL;
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	gplugin_manager_append_path(manager, TEST_NEWEST_VERSION_DIR);
 	gplugin_manager_refresh(manager);
 
@@ -44,6 +52,8 @@
 
 	g_clear_object(&info);
 	g_clear_object(&plugin);
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -94,9 +104,7 @@
 main(int argc, char **argv)
 {
 
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func(
 		"/manager/find_plugin_newest_version/multiple-semantic",
diff --git a/gplugin/tests/test-option-group.c b/gplugin/tests/test-option-group.c
--- a/gplugin/tests/test-option-group.c
+++ b/gplugin/tests/test-option-group.c
@@ -191,7 +191,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func(
 		"/option-group/default-paths",
diff --git a/gplugin/tests/test-plugin-info.c b/gplugin/tests/test-plugin-info.c
--- a/gplugin/tests/test-plugin-info.c
+++ b/gplugin/tests/test-plugin-info.c
@@ -281,7 +281,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/plugin-info/new/full", test_gplugin_plugin_info_new_full);
 	g_test_add_func(
diff --git a/gplugin/tests/test-plugin-manager-paths.c b/gplugin/tests/test-plugin-manager-paths.c
--- a/gplugin/tests/test-plugin-manager-paths.c
+++ b/gplugin/tests/test-plugin-manager-paths.c
@@ -18,14 +18,7 @@
 #include <glib.h>
 
 #include <gplugin.h>
-
-#define test_path_count(manager, e) \
-	G_STMT_START \
-		{ \
-			GList *paths = gplugin_manager_get_paths((manager)); \
-			g_assert_cmpint(g_list_length(paths), ==, (e)); \
-		} \
-	G_STMT_END
+#include <gplugin-native.h>
 
 /******************************************************************************
  * Tests
@@ -33,130 +26,184 @@
 static void
 test_gplugin_manager_paths_single(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
+	GList *paths = NULL;
+
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
 	gplugin_manager_append_path(manager, "foo");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_remove_path(manager, "foo");
-	test_path_count(manager, 0);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_paths_duplicate(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
+	GList *paths = NULL;
+
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
 	gplugin_manager_append_path(manager, "foo");
 	gplugin_manager_append_path(manager, "foo");
 
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_remove_path(manager, "foo");
-	test_path_count(manager, 0);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_paths_multiple_fifo(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
+	GList *paths = NULL;
+
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
 	/* add */
 	gplugin_manager_append_path(manager, "foo");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_append_path(manager, "bar");
-	test_path_count(manager, 2);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 2);
 
 	/* remove */
 	gplugin_manager_remove_path(manager, "foo");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_remove_path(manager, "bar");
-	test_path_count(manager, 0);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_paths_multiple_filo(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
+	GList *paths = NULL;
+
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
 	/* add */
 	gplugin_manager_append_path(manager, "foo");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_append_path(manager, "bar");
-	test_path_count(manager, 2);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 2);
 
 	/* remove */
 	gplugin_manager_remove_path(manager, "bar");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_remove_path(manager, "foo");
-	test_path_count(manager, 0);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_paths_unicode(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
+	GList *paths = NULL;
 
-	test_path_count(manager, 0);
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
 
 	gplugin_manager_append_path(manager, "/home/🐦/.plugins");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_append_path(manager, "/home/user/.plugins");
-	test_path_count(manager, 2);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 2);
 
 	gplugin_manager_remove_path(manager, "/home/🐦/.plugins");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_remove_path(manager, "/home/user/.plugins");
-	test_path_count(manager, 0);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_add_multiple_mixed_trailing_slashes(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
+	GList *paths = NULL;
 
-	test_path_count(manager, 0);
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
 
 	gplugin_manager_append_path(
 		manager,
 		G_DIR_SEPARATOR_S "home" G_DIR_SEPARATOR_S "user1" G_DIR_SEPARATOR_S
 						  ".plugins");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_append_path(
 		manager,
 		G_DIR_SEPARATOR_S "home" G_DIR_SEPARATOR_S "user2" G_DIR_SEPARATOR_S
 						  ".plugins" G_DIR_SEPARATOR_S "");
-	test_path_count(manager, 2);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 2);
 
 	gplugin_manager_remove_path(
 		manager,
 		G_DIR_SEPARATOR_S "home" G_DIR_SEPARATOR_S "user1" G_DIR_SEPARATOR_S
 						  ".plugins" G_DIR_SEPARATOR_S "");
-	test_path_count(manager, 1);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 1);
 
 	gplugin_manager_remove_path(
 		manager,
 		G_DIR_SEPARATOR_S "home" G_DIR_SEPARATOR_S "user2" G_DIR_SEPARATOR_S
 						  ".plugins");
-	test_path_count(manager, 0);
+	paths = gplugin_manager_get_paths(manager);
+	g_assert_cmpuint(g_list_length(paths), ==, 0);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_add_default_paths(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
 	GHashTable *req = NULL;
 	GList *paths = NULL, *l = NULL;
 	char *path = NULL;
 	guint size = 0;
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
 	/* build our table of required paths */
 	req = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
@@ -185,12 +232,14 @@
 	g_hash_table_destroy(req);
 
 	g_assert_cmpuint(0, ==, size);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_add_app_paths(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginManager *manager = NULL;
 	GHashTable *req = NULL;
 	GList *paths = NULL, *l = NULL;
 	const char *prefix = "/usr/local/";
@@ -198,6 +247,8 @@
 	char *path = NULL;
 	guint size = 0;
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
 	/* build our table of required paths */
 	req = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
@@ -231,11 +282,14 @@
 	g_hash_table_destroy(req);
 
 	g_assert_cmpuint(0, ==, size);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_add_app_paths_via_environ(void)
 {
+	GPluginManager *manager = NULL;
 	GList *paths = NULL, *l = NULL;
 	int path_pos = 0;
 	char *pre_paths, *post_paths;
@@ -244,7 +298,7 @@
 	const char *pre_env_var_name = "GPLUGIN_EXTRA_TEST_PREPATHS";
 	const char *post_env_var_name = "GPLUGIN_EXTRA_TEST_POSTPATHS";
 
-	GPluginManager *manager = gplugin_manager_get_default();
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
 	/* get number of paths to start */
 	paths = gplugin_manager_get_paths(manager);
@@ -274,7 +328,7 @@
 	paths = gplugin_manager_get_paths(manager);
 
 	/* four more paths now */
-	test_path_count(manager, path_count + 4);
+	g_assert_cmpuint(g_list_length(paths), ==, path_count + 4);
 
 	/* check order is correct */
 	path_pos = 0;
@@ -304,15 +358,14 @@
 	g_assert_cmpint(4, ==, found_paths);
 	g_free(pre_paths);
 	g_free(post_paths);
+
+	g_assert_finalize_object(manager);
 }
 
 int
 main(int argc, char **argv)
 {
-
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func(
 		"/plugins/paths/add_remove_single",
diff --git a/gplugin/tests/test-signals.c b/gplugin/tests/test-signals.c
--- a/gplugin/tests/test-signals.c
+++ b/gplugin/tests/test-signals.c
@@ -18,6 +18,7 @@
 #include <glib.h>
 
 #include <gplugin.h>
+#include <gplugin-native.h>
 
 typedef struct {
 	gboolean loading;
@@ -143,8 +144,9 @@
 static void
 test_gplugin_manager_signals_normal(void)
 {
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
-	GPluginManager *manager = gplugin_manager_get_default();
 	GError *error = NULL;
 	TestGPluginManagerSignalsData data = {
 		.loading = FALSE,
@@ -154,6 +156,12 @@
 	};
 	gulong signals[] = {0, 0, 0, 0};
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	signals[0] = g_signal_connect(
 		manager,
 		"loading-plugin",
@@ -194,13 +202,16 @@
 	g_signal_handler_disconnect(manager, signals[1]);
 	g_signal_handler_disconnect(manager, signals[2]);
 	g_signal_handler_disconnect(manager, signals[3]);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_signals_loading_stopped(void)
 {
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
-	GPluginManager *manager = gplugin_manager_get_default();
 	GError *error = NULL;
 	TestGPluginManagerSignalsData data = {
 		.loading = FALSE,
@@ -210,6 +221,12 @@
 	};
 	gulong signals[] = {0, 0, 0, 0};
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	signals[0] = g_signal_connect(
 		manager,
 		"loading-plugin",
@@ -249,13 +266,16 @@
 	g_signal_handler_disconnect(manager, signals[1]);
 	g_signal_handler_disconnect(manager, signals[2]);
 	g_signal_handler_disconnect(manager, signals[3]);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_signals_unloading_stopped(void)
 {
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
-	GPluginManager *manager = gplugin_manager_get_default();
 	GError *error = NULL;
 	TestGPluginManagerSignalsData data = {
 		.loading = FALSE,
@@ -265,6 +285,12 @@
 	};
 	gulong signals[] = {0, 0, 0, 0};
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	signals[0] = g_signal_connect(
 		manager,
 		"loading-plugin",
@@ -307,13 +333,16 @@
 	g_signal_handler_disconnect(manager, signals[1]);
 	g_signal_handler_disconnect(manager, signals[2]);
 	g_signal_handler_disconnect(manager, signals[3]);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_signals_load_failure(void)
 {
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
-	GPluginManager *manager = gplugin_manager_get_default();
 	GError *error = NULL;
 	TestGPluginManagerSignalsData data = {
 		.loading = FALSE,
@@ -321,6 +350,12 @@
 	};
 	gulong signals[] = {0, 0, 0, 0};
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	signals[0] = g_signal_connect(
 		manager,
 		"loading-plugin",
@@ -345,13 +380,16 @@
 
 	g_signal_handler_disconnect(manager, signals[0]);
 	g_signal_handler_disconnect(manager, signals[1]);
+
+	g_assert_finalize_object(manager);
 }
 
 static void
 test_gplugin_manager_signals_unload_failure(void)
 {
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
-	GPluginManager *manager = gplugin_manager_get_default();
 	GError *error = NULL;
 	TestGPluginManagerSignalsData data = {
 		.loading = FALSE,
@@ -361,6 +399,12 @@
 	};
 	gulong signals[] = {0, 0, 0, 0};
 
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
+
 	signals[0] = g_signal_connect(
 		manager,
 		"loading-plugin",
@@ -401,6 +445,8 @@
 
 	g_signal_handler_disconnect(manager, signals[0]);
 	g_signal_handler_disconnect(manager, signals[1]);
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -409,9 +455,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func(
 		"/manager/signals/normal",
diff --git a/gplugin/tests/test-source.c b/gplugin/tests/test-source.c
--- a/gplugin/tests/test-source.c
+++ b/gplugin/tests/test-source.c
@@ -105,7 +105,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/source/scan/false", test_gplugin_source_scan_false);
 	g_test_add_func("/source/scan/true", test_gplugin_source_scan_true);
diff --git a/gplugin/tests/test-unresolved-symbol.c b/gplugin/tests/test-unresolved-symbol.c
--- a/gplugin/tests/test-unresolved-symbol.c
+++ b/gplugin/tests/test-unresolved-symbol.c
@@ -23,11 +23,17 @@
 /******************************************************************************
  * Tests
  *****************************************************************************/
-
 static void
 test_unresolved_symbol(void)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
+	GPluginLoader *loader = NULL;
+	GPluginManager *manager = NULL;
+
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
+
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
 
 	g_test_expect_message(
 		G_LOG_DOMAIN,
@@ -39,6 +45,8 @@
 	gplugin_manager_refresh(manager);
 
 	g_test_assert_expected_messages();
+
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -47,9 +55,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	/* test the load on query flag */
 	g_test_add_func(
diff --git a/gplugin/tests/test-version-compare.c b/gplugin/tests/test-version-compare.c
--- a/gplugin/tests/test-version-compare.c
+++ b/gplugin/tests/test-version-compare.c
@@ -152,9 +152,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
-
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	g_test_init(&argc, &argv, NULL);
 
 	/* bad versions */
 	g_test_add_func(
diff --git a/gplugin/tests/test-versioned-dependencies.c b/gplugin/tests/test-versioned-dependencies.c
--- a/gplugin/tests/test-versioned-dependencies.c
+++ b/gplugin/tests/test-versioned-dependencies.c
@@ -18,14 +18,14 @@
 #include <glib.h>
 
 #include <gplugin.h>
+#include <gplugin-native.h>
 
 /******************************************************************************
  * Helpers
  *****************************************************************************/
 static void
-_test_plugin_loaded(G_GNUC_UNUSED GPluginPlugin *dependent, const char *id)
+_test_plugin_loaded(GPluginManager *manager, const char *id)
 {
-	GPluginManager *manager = gplugin_manager_get_default();
 	GPluginPlugin *plugin = NULL;
 
 	plugin = gplugin_manager_find_plugin(manager, id);
@@ -43,14 +43,17 @@
 static void
 test_load_with_dependencies(void)
 {
+	GPluginLoader *loader = NULL;
 	GPluginManager *manager = NULL;
 	GPluginPlugin *plugin = NULL;
 	GError *error = NULL;
 	gboolean ret = FALSE;
 
-	gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+	manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
 
-	manager = gplugin_manager_get_default();
+	loader = gplugin_native_loader_new();
+	gplugin_manager_register_loader(manager, loader, NULL);
+	g_clear_object(&loader);
 
 	gplugin_manager_append_path(manager, TEST_VERSIONED_DEPENDENCIES_DIR);
 	gplugin_manager_refresh(manager);
@@ -69,20 +72,20 @@
 		GPLUGIN_PLUGIN_STATE_LOADED);
 
 	/* now make sure each dependent plugin that's available was loaded */
-	_test_plugin_loaded(plugin, "gplugin/test-no-version");
-	_test_plugin_loaded(plugin, "gplugin/test-exact1");
-	_test_plugin_loaded(plugin, "gplugin/test-exact2");
-	_test_plugin_loaded(plugin, "gplugin/test-greater");
-	_test_plugin_loaded(plugin, "gplugin/test-greater-equal");
-	_test_plugin_loaded(plugin, "gplugin/test-less");
-	_test_plugin_loaded(plugin, "gplugin/test-less-equal");
-	_test_plugin_loaded(plugin, "gplugin/bar");
-	_test_plugin_loaded(plugin, "gplugin/baz");
-	_test_plugin_loaded(plugin, "gplugin/fez");
+	_test_plugin_loaded(manager, "gplugin/test-no-version");
+	_test_plugin_loaded(manager, "gplugin/test-exact1");
+	_test_plugin_loaded(manager, "gplugin/test-exact2");
+	_test_plugin_loaded(manager, "gplugin/test-greater");
+	_test_plugin_loaded(manager, "gplugin/test-greater-equal");
+	_test_plugin_loaded(manager, "gplugin/test-less");
+	_test_plugin_loaded(manager, "gplugin/test-less-equal");
+	_test_plugin_loaded(manager, "gplugin/bar");
+	_test_plugin_loaded(manager, "gplugin/baz");
+	_test_plugin_loaded(manager, "gplugin/fez");
 
 	g_object_unref(plugin);
 
-	gplugin_uninit();
+	g_assert_finalize_object(manager);
 }
 
 /******************************************************************************
@@ -91,7 +94,7 @@
 int
 main(int argc, char **argv)
 {
-	g_test_init(&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
+	g_test_init(&argc, &argv, NULL);
 
 	/* test the load on query flag */
 	g_test_add_func(
