empathy r1573 - trunk/tests



Author: xclaesse
Date: Mon Oct 13 07:55:25 2008
New Revision: 1573
URL: http://svn.gnome.org/viewvc/empathy?rev=1573&view=rev

Log:
reuse test account instead of creating one at each test to avoid to pollute gconf DB with loooooot of unremovable accounts

Modified:
   trunk/tests/check-empathy-chatroom-manager.c
   trunk/tests/check-empathy-chatroom.c
   trunk/tests/check-empathy-helpers.c
   trunk/tests/check-empathy-helpers.h

Modified: trunk/tests/check-empathy-chatroom-manager.c
==============================================================================
--- trunk/tests/check-empathy-chatroom-manager.c	(original)
+++ trunk/tests/check-empathy-chatroom-manager.c	Mon Oct 13 07:55:25 2008
@@ -92,7 +92,7 @@
         { "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 @@
 
   g_free (file);
   g_object_unref (mgr);
-  destroy_test_account (account);
+  g_object_unref (account);
 }
 END_TEST
 
@@ -125,7 +125,7 @@
         { "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 @@
 
   g_object_unref (mgr);
   g_free (file);
-  destroy_test_account (account);
+  g_object_unref (account);
 }
 END_TEST
 
@@ -184,7 +184,7 @@
         { "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 @@
 
   g_object_unref (mgr);
   g_free (file);
-  destroy_test_account (account);
+  g_object_unref (account);
 }
 END_TEST
 
@@ -241,7 +241,7 @@
         { "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 @@
   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 @@
         { "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 @@
 
   g_object_unref (mgr);
   g_free (file);
-  destroy_test_account (account);
+  g_object_unref (account);
 }
 END_TEST
 

Modified: trunk/tests/check-empathy-chatroom.c
==============================================================================
--- trunk/tests/check-empathy-chatroom.c	(original)
+++ trunk/tests/check-empathy-chatroom.c	Mon Oct 13 07:55:25 2008
@@ -15,7 +15,7 @@
   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 @@
   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 @@
   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

Modified: trunk/tests/check-empathy-helpers.c
==============================================================================
--- trunk/tests/check-empathy-helpers.c	(original)
+++ trunk/tests/check-empathy-helpers.c	Mon Oct 13 07:55:25 2008
@@ -64,19 +64,32 @@
 }
 
 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)
 {

Modified: trunk/tests/check-empathy-helpers.h
==============================================================================
--- trunk/tests/check-empathy-helpers.h	(original)
+++ trunk/tests/check-empathy-helpers.h	Mon Oct 13 07:55:25 2008
@@ -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__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]