aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:55:25 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:55:25 +0800
commita5f068db869d99cd7b3423cc0110e2e69b6ec4f5 (patch)
treed2f5a465ad15e91208d16f5d629ef7b1df2e06eb
parent063c6dbfe2fb57ab251fcd51060e4e326a96105f (diff)
downloadgsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.tar
gsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.tar.gz
gsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.tar.bz2
gsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.tar.lz
gsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.tar.xz
gsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.tar.zst
gsoc2013-empathy-a5f068db869d99cd7b3423cc0110e2e69b6ec4f5.zip
reuse test account instead of creating one at each test to avoid to pollute gconf DB with loooooot of unremovable accounts
svn path=/trunk/; revision=1573
-rw-r--r--tests/check-empathy-chatroom-manager.c20
-rw-r--r--tests/check-empathy-chatroom.c6
-rw-r--r--tests/check-empathy-helpers.c17
-rw-r--r--tests/check-empathy-helpers.h2
4 files changed, 29 insertions, 16 deletions
diff --git a/tests/check-empathy-chatroom-manager.c b/tests/check-empathy-chatroom-manager.c
index e59fe7020..73f164b15 100644
--- a/tests/check-empathy-chatroom-manager.c
+++ b/tests/check-empathy-chatroom-manager.c
@@ -92,7 +92,7 @@ START_TEST (test_empathy_chatroom_manager_new)
{ "name1", "room1", TRUE, TRUE },
{ "name2", "room2", FALSE, TRUE }};
- account = create_test_account ();
+ account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -108,7 +108,7 @@ START_TEST (test_empathy_chatroom_manager_new)
g_free (file);
g_object_unref (mgr);
- destroy_test_account (account);
+ g_object_unref (account);
}
END_TEST
@@ -125,7 +125,7 @@ START_TEST (test_empathy_chatroom_manager_add)
{ "name4", "room4", FALSE, FALSE }};
EmpathyChatroom *chatroom;
- account = create_test_account ();
+ account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -170,7 +170,7 @@ START_TEST (test_empathy_chatroom_manager_add)
g_object_unref (mgr);
g_free (file);
- destroy_test_account (account);
+ g_object_unref (account);
}
END_TEST
@@ -184,7 +184,7 @@ START_TEST (test_empathy_chatroom_manager_remove)
{ "name2", "room2", FALSE, TRUE }};
EmpathyChatroom *chatroom;
- account = create_test_account ();
+ account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -226,7 +226,7 @@ START_TEST (test_empathy_chatroom_manager_remove)
g_object_unref (mgr);
g_free (file);
- destroy_test_account (account);
+ g_object_unref (account);
}
END_TEST
@@ -241,7 +241,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite)
{ "name2", "room2", FALSE, FALSE }};
EmpathyChatroom *chatroom;
- account = create_test_account ();
+ account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -290,7 +290,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite)
g_object_unref (mgr);
g_object_unref (chatroom);
g_free (file);
- destroy_test_account (account);
+ g_object_unref (account);
}
END_TEST
@@ -305,7 +305,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom)
{ "name2", "room2", FALSE, TRUE }};
EmpathyChatroom *chatroom;
- account = create_test_account ();
+ account = get_test_account ();
/*
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -363,7 +363,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom)
g_object_unref (mgr);
g_free (file);
- destroy_test_account (account);
+ g_object_unref (account);
}
END_TEST
diff --git a/tests/check-empathy-chatroom.c b/tests/check-empathy-chatroom.c
index af8687cf3..a4adf6ce1 100644
--- a/tests/check-empathy-chatroom.c
+++ b/tests/check-empathy-chatroom.c
@@ -15,7 +15,7 @@ create_chatroom (void)
McAccount *account;
EmpathyChatroom *chatroom;
- account = create_test_account ();
+ account = get_test_account ();
chatroom = empathy_chatroom_new (account);
fail_if (chatroom == NULL);
@@ -36,7 +36,7 @@ START_TEST (test_empathy_chatroom_new)
fail_if (auto_connect);
fail_if (favorite);
- destroy_test_account (empathy_chatroom_get_account (chatroom));
+ g_object_unref (empathy_chatroom_get_account (chatroom));
g_object_unref (chatroom);
}
END_TEST
@@ -109,7 +109,7 @@ START_TEST (test_favorite_and_auto_connect)
fail_if (auto_connect);
fail_if (favorite);
- destroy_test_account (empathy_chatroom_get_account (chatroom));
+ g_object_unref (empathy_chatroom_get_account (chatroom));
g_object_unref (chatroom);
}
END_TEST
diff --git a/tests/check-empathy-helpers.c b/tests/check-empathy-helpers.c
index 370fb2922..2e808c0e7 100644
--- a/tests/check-empathy-helpers.c
+++ b/tests/check-empathy-helpers.c
@@ -64,19 +64,32 @@ copy_xml_file (const gchar *orig,
}
McAccount *
-create_test_account (void)
+get_test_account (void)
{
McProfile *profile;
McAccount *account;
+ GList *accounts;
profile = mc_profile_lookup ("test");
- account = mc_account_create (profile);
+ accounts = mc_accounts_list_by_profile (profile);
+ if (g_list_length (accounts) == 0)
+ {
+ /* need to create a test account */
+ account = mc_account_create (profile);
+ }
+ else
+ {
+ /* reuse an existing test account */
+ account = accounts->data;
+ }
g_object_unref (profile);
return account;
}
+/* Not used for now as there is no API to remove completely gconf keys.
+ * So we reuse existing accounts instead of creating new ones */
void
destroy_test_account (McAccount *account)
{
diff --git a/tests/check-empathy-helpers.h b/tests/check-empathy-helpers.h
index 411816bc1..4d52c04e5 100644
--- a/tests/check-empathy-helpers.h
+++ b/tests/check-empathy-helpers.h
@@ -25,7 +25,7 @@
gchar * get_xml_file (const gchar *filename);
gchar * get_user_xml_file (const gchar *filename);
void copy_xml_file (const gchar *orig, const gchar *dest);
-McAccount * create_test_account (void);
+McAccount * get_test_account (void);
void destroy_test_account (McAccount *account);
#endif /* #ifndef __CHECK_EMPATHY_HELPERS_H__ */