# HG changeset patch
# Node ID 17786b6d4047
# Parent  b7a1aab4b3be
diff --git a/libpurple/tests/meson.build b/libpurple/tests/meson.build
--- a/libpurple/tests/meson.build
+++ b/libpurple/tests/meson.build
@@ -5,6 +5,7 @@
     'circular_buffer',
     'contact',
     'contact_manager',
+    'credential_manager',
     'credential_provider',
     'history_adapter',
     'history_manager',
@@ -52,13 +53,4 @@
     )
 endforeach
 
-e = executable('test_credential_manager', 'test_credential_manager.c',
-               c_args : [
-                   '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir())
-               ],
-               dependencies : [libpurple_dep, glib],
-               link_with: test_ui,
-)
-test('credential_manager', e, env: testenv, is_parallel : false)
-
 subdir('sqlite3')
diff --git a/libpurple/tests/test_credential_manager.c b/libpurple/tests/test_credential_manager.c
--- a/libpurple/tests/test_credential_manager.c
+++ b/libpurple/tests/test_credential_manager.c
@@ -205,7 +205,7 @@
 	GError *error = NULL;
 	gboolean r = FALSE;
 
-	manager = purple_credential_manager_get_default();
+	manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 	g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager));
 
 	provider = test_purple_credential_provider_new();
@@ -234,6 +234,7 @@
 
 	/* Final clean ups. */
 	g_clear_object(&provider);
+	g_clear_object(&manager);
 }
 
 /******************************************************************************
@@ -245,13 +246,14 @@
 	GError *error = NULL;
 	gboolean ret = FALSE;
 
-	manager = purple_credential_manager_get_default();
+	manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	ret = purple_credential_manager_set_active(manager, NULL, &error);
 
 	g_assert_no_error(error);
 	g_assert_true(ret);
 
+	g_clear_object(&manager);
 }
 
 static void
@@ -260,13 +262,15 @@
 	GError *error = NULL;
 	gboolean ret = FALSE;
 
-	manager = purple_credential_manager_get_default();
+	manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	ret = purple_credential_manager_set_active(manager, "foo", &error);
 
 	g_assert_false(ret);
 	g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
 	g_clear_error(&error);
+
+	g_clear_object(&manager);
 }
 
 static void
@@ -276,7 +280,7 @@
 	GError *error = NULL;
 	gboolean r = FALSE;
 
-	manager = purple_credential_manager_get_default();
+	manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	/* Create the provider and register it in the manager. */
 	provider = test_purple_credential_provider_new();
@@ -308,6 +312,7 @@
 
 	/* And our final cleanup. */
 	g_clear_object(&provider);
+	g_clear_object(&manager);
 }
 
 /******************************************************************************
@@ -350,12 +355,16 @@
 
 static void
 test_purple_credential_manager_no_provider_read_password_async(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
+	PurpleCredentialManager *m = NULL;
+
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	g_idle_add(test_purple_credential_manager_no_provider_read_password_idle, m);
 	g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
 
 	g_main_loop_run(loop);
+
+	g_clear_object(&m);
 }
 
 static void
@@ -394,13 +403,17 @@
 
 static void
 test_purple_credential_manager_no_provider_write_password_async(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
+	PurpleCredentialManager *m = NULL;
+
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	g_idle_add(test_purple_credential_manager_no_provider_write_password_idle,
 	           m);
 	g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
 
 	g_main_loop_run(loop);
+
+	g_clear_object(&m);
 }
 
 static void
@@ -439,13 +452,17 @@
 
 static void
 test_purple_credential_manager_no_provider_clear_password_async(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
+	PurpleCredentialManager *m = NULL;
+
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	g_idle_add(test_purple_credential_manager_no_provider_clear_password_idle,
 	           m);
 	g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
 
 	g_main_loop_run(loop);
+
+	g_clear_object(&m);
 }
 
 static void
@@ -454,7 +471,7 @@
 	PurpleRequestFields *fields = NULL;
 	GError *error = NULL;
 
-	manager = purple_credential_manager_get_default();
+	manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	fields = purple_credential_manager_read_settings(manager, &error);
 
@@ -462,6 +479,8 @@
 	g_clear_error(&error);
 
 	g_assert_null(fields);
+
+	g_clear_object(&manager);
 }
 
 static void
@@ -469,13 +488,14 @@
 	PurpleCredentialManager *manager = NULL;
 	GError *error = NULL;
 
-	manager = purple_credential_manager_get_default();
+	manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
 
 	purple_credential_manager_write_settings(manager, NULL, &error);
 
 	g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
 	g_clear_error(&error);
 
+	g_clear_object(&manager);
 }
 
 /******************************************************************************
@@ -518,11 +538,14 @@
 
 static void
 test_purple_credential_manager_read_password_async(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
-	PurpleCredentialProvider *p = test_purple_credential_provider_new();
+	PurpleCredentialManager *m = NULL;
+	PurpleCredentialProvider *p = NULL;
 	GError *e = NULL;
 	gboolean r = FALSE;
 
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
+	p = test_purple_credential_provider_new();
+
 	r = purple_credential_manager_register(m, p, &e);
 	g_assert_no_error(e);
 	g_assert_true(r);
@@ -545,6 +568,7 @@
 	g_assert_true(r);
 
 	g_clear_object(&p);
+	g_clear_object(&m);
 }
 
 static void
@@ -582,11 +606,14 @@
 
 static void
 test_purple_credential_manager_write_password_async(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
-	PurpleCredentialProvider *p = test_purple_credential_provider_new();
+	PurpleCredentialManager *m = NULL;
+	PurpleCredentialProvider *p = NULL;
 	GError *e = NULL;
 	gboolean r = FALSE;
 
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
+	p = test_purple_credential_provider_new();
+
 	r = purple_credential_manager_register(m, p, &e);
 	g_assert_no_error(e);
 	g_assert_true(r);
@@ -609,6 +636,7 @@
 	g_assert_true(r);
 
 	g_clear_object(&p);
+	g_clear_object(&m);
 }
 
 static void
@@ -646,11 +674,14 @@
 
 static void
 test_purple_credential_manager_clear_password_async(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
-	PurpleCredentialProvider *p = test_purple_credential_provider_new();
+	PurpleCredentialManager *m = NULL;
+	PurpleCredentialProvider *p = NULL;
 	GError *e = NULL;
 	gboolean r = FALSE;
 
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
+	p = test_purple_credential_provider_new();
+
 	r = purple_credential_manager_register(m, p, &e);
 	g_assert_no_error(e);
 	g_assert_true(r);
@@ -673,17 +704,22 @@
 	g_assert_true(r);
 
 	g_clear_object(&p);
+	g_clear_object(&m);
 }
 
 static void
 test_purple_credential_manager_settings(void) {
-	PurpleCredentialManager *m = purple_credential_manager_get_default();
-	PurpleCredentialProvider *p = test_purple_credential_provider_new();
-	TestPurpleCredentialProvider *tp = TEST_PURPLE_CREDENTIAL_PROVIDER(p);
+	PurpleCredentialManager *m = NULL;
+	PurpleCredentialProvider *p = NULL;
+	TestPurpleCredentialProvider *tp = NULL;
 	PurpleRequestFields *fields = NULL;
 	GError *e = NULL;
 	gboolean r = FALSE;
 
+	m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
+	p = test_purple_credential_provider_new();
+	tp = TEST_PURPLE_CREDENTIAL_PROVIDER(p);
+
 	r = purple_credential_manager_register(m, p, &e);
 	g_assert_no_error(e);
 	g_assert_true(r);
@@ -714,6 +750,7 @@
 	g_assert_true(r);
 
 	g_clear_object(&p);
+	g_clear_object(&m);
 }
 
 /******************************************************************************
