]> git.0d.be Git - empathy.git/commitdiff
reuse test account instead of creating one at each test to avoid to pollute gconf...
authorXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Oct 2008 07:55:25 +0000 (07:55 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Oct 2008 07:55:25 +0000 (07:55 +0000)
svn path=/trunk/; revision=1573

tests/check-empathy-chatroom-manager.c
tests/check-empathy-chatroom.c
tests/check-empathy-helpers.c
tests/check-empathy-helpers.h

index e59fe70209a26dedf1d69c851ded1e4c6f81700e..73f164b15597f25e3bb726c147904bceeac35a5b 100644 (file)
@@ -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
 
index af8687cf31c8e97c3396e609655c3e4370c91d9f..a4adf6ce1be62aa7f93c936bf89bce147df7e49f 100644 (file)
@@ -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
index 370fb2922d28fbf57cfd0ec8b0be6df1d283ed0e..2e808c0e742b2f58215a59315f6438f43cc8b566 100644 (file)
@@ -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)
 {
index 411816bc14aab74c2b012598a6828edf1bfb1dd2..4d52c04e5872c9ac4990d25725ffa04d14a3ad8e 100644 (file)
@@ -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__ */