]> git.0d.be Git - empathy.git/commitdiff
Port the tests to EmpathyAccount
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 26 Jun 2009 13:58:40 +0000 (14:58 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 1 Jul 2009 13:19:40 +0000 (14:19 +0100)
tests/check-empathy-chatroom-manager.c
tests/check-empathy-chatroom.c
tests/check-empathy-helpers.c
tests/check-empathy-helpers.h
tests/check-helpers.h

index ef5c7761853f08136791435c28e93cd8d8800ac5..1c0f924a200ef9542a5cbfa871ee155cad62e8dc 100644 (file)
@@ -13,6 +13,7 @@
 #include "check-empathy-helpers.h"
 
 #include <libempathy/empathy-chatroom-manager.h>
+#include <libempathy/empathy-account-manager.h>
 
 #define CHATROOM_SAMPLE "chatrooms-sample.xml"
 #define CHATROOM_FILE "chatrooms.xml"
@@ -43,7 +44,7 @@ struct chatroom_t
 
 static void
 check_chatrooms_list (EmpathyChatroomManager *mgr,
-                      McAccount *account,
+                      EmpathyAccount *account,
                       struct chatroom_t *_chatrooms,
                       guint nb_chatrooms)
 {
@@ -83,13 +84,13 @@ check_chatrooms_list (EmpathyChatroomManager *mgr,
 }
 
 static gboolean
-change_account_name_in_file (McAccount *account,
+change_account_name_in_file (EmpathyAccount *account,
                              const gchar *file)
 {
   gchar *cmd;
 
   cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
-      mc_account_get_unique_name (account), file);
+      empathy_account_get_unique_name (account), file);
 
   if (system (cmd) == -1)
     {
@@ -106,11 +107,13 @@ START_TEST (test_empathy_chatroom_manager_dup_singleton)
 {
   EmpathyChatroomManager *mgr;
   gchar *file;
-  McAccount *account;
+  EmpathyAccount *account;
+  EmpathyAccountManager *account_manager;
   struct chatroom_t chatrooms[] = {
         { "name1", "room1", TRUE, TRUE },
         { "name2", "room2", FALSE, TRUE }};
 
+  account_manager = empathy_account_manager_dup_singleton ();
   account = get_test_account ();
 
   copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -126,6 +129,7 @@ START_TEST (test_empathy_chatroom_manager_dup_singleton)
 
   g_free (file);
   g_object_unref (mgr);
+  g_object_unref (account_manager);
   g_object_unref (account);
 }
 END_TEST
@@ -134,7 +138,8 @@ START_TEST (test_empathy_chatroom_manager_add)
 {
   EmpathyChatroomManager *mgr;
   gchar *file;
-  McAccount *account;
+  EmpathyAccount *account;
+  EmpathyAccountManager *account_manager;
   struct chatroom_t chatrooms[] = {
         { "name1", "room1", TRUE, TRUE },
         { "name2", "room2", FALSE, TRUE },
@@ -142,6 +147,8 @@ START_TEST (test_empathy_chatroom_manager_add)
         { "name4", "room4", FALSE, FALSE }};
   EmpathyChatroom *chatroom;
 
+  account_manager = empathy_account_manager_dup_singleton ();
+
   account = get_test_account ();
 
   copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -149,8 +156,7 @@ START_TEST (test_empathy_chatroom_manager_add)
   file = get_user_xml_file (CHATROOM_FILE);
 
   /* change the chatrooms XML file to use the account we just created */
-  if (!change_account_name_in_file (account, file))
-    return;
+  fail_unless (change_account_name_in_file (account, file));
 
   mgr = empathy_chatroom_manager_dup_singleton (file);
 
@@ -186,6 +192,7 @@ START_TEST (test_empathy_chatroom_manager_add)
 
   g_object_unref (mgr);
   g_free (file);
+  g_object_unref (account_manager);
   g_object_unref (account);
 }
 END_TEST
@@ -194,11 +201,13 @@ START_TEST (test_empathy_chatroom_manager_remove)
 {
   EmpathyChatroomManager *mgr;
   gchar *file;
-  McAccount *account;
+  EmpathyAccount *account;
   struct chatroom_t chatrooms[] = {
         { "name2", "room2", FALSE, TRUE }};
   EmpathyChatroom *chatroom;
+  EmpathyAccountManager *account_mgr;
 
+  account_mgr = empathy_account_manager_dup_singleton ();
   account = get_test_account ();
 
   copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -206,8 +215,7 @@ START_TEST (test_empathy_chatroom_manager_remove)
   file = get_user_xml_file (CHATROOM_FILE);
 
   /* change the chatrooms XML file to use the account we just created */
-  if (!change_account_name_in_file (account, file))
-    return;
+  fail_unless (change_account_name_in_file (account, file));
 
   mgr = empathy_chatroom_manager_dup_singleton (file);
 
@@ -241,6 +249,7 @@ START_TEST (test_empathy_chatroom_manager_remove)
   g_object_unref (mgr);
   g_free (file);
   g_object_unref (account);
+  g_object_unref (account_mgr);
 }
 END_TEST
 
@@ -248,12 +257,14 @@ START_TEST (test_empathy_chatroom_manager_change_favorite)
 {
   EmpathyChatroomManager *mgr;
   gchar *file;
-  McAccount *account;
+  EmpathyAccount *account;
+  EmpathyAccountManager *account_manager;
   struct chatroom_t chatrooms[] = {
         { "name1", "room1", TRUE, TRUE },
         { "name2", "room2", FALSE, FALSE }};
   EmpathyChatroom *chatroom;
 
+  account_manager = empathy_account_manager_dup_singleton ();
   account = get_test_account ();
 
   copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -261,8 +272,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite)
   file = get_user_xml_file (CHATROOM_FILE);
 
   /* change the chatrooms XML file to use the account we just created */
-  if (!change_account_name_in_file (account, file))
-    return;
+  fail_unless (change_account_name_in_file (account, file));
 
   mgr = empathy_chatroom_manager_dup_singleton (file);
 
@@ -302,6 +312,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite)
   g_object_unref (mgr);
   g_object_unref (chatroom);
   g_free (file);
+  g_object_unref (account_manager);
   g_object_unref (account);
 }
 END_TEST
@@ -310,12 +321,14 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom)
 {
   EmpathyChatroomManager *mgr;
   gchar *file;
-  McAccount *account;
+  EmpathyAccount *account;
+  EmpathyAccountManager *account_manager;
   struct chatroom_t chatrooms[] = {
         { "name1", "room1", TRUE, TRUE },
         { "name2", "room2", FALSE, TRUE }};
   EmpathyChatroom *chatroom;
 
+  account_manager = empathy_account_manager_dup_singleton ();
   account = get_test_account ();
 
   copy_xml_file (CHATROOM_SAMPLE, "foo.xml");
@@ -323,8 +336,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom)
   file = get_user_xml_file ("foo.xml");
 
   /* change the chatrooms XML file to use the account we just created */
-  if (!change_account_name_in_file (account, file))
-    return;
+  fail_unless (change_account_name_in_file (account, file));
 
   mgr = empathy_chatroom_manager_dup_singleton (file);
 
@@ -369,6 +381,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom)
   g_object_unref (mgr);
   g_free (file);
   g_object_unref (account);
+  g_object_unref (account_manager);
 }
 END_TEST
 
index a4adf6ce1be62aa7f93c936bf89bce147df7e49f..f2110a8f86f6833d97f13ab6aefbfb4a3d31c0a7 100644 (file)
@@ -12,7 +12,7 @@
 static EmpathyChatroom *
 create_chatroom (void)
 {
-  McAccount *account;
+  EmpathyAccount *account;
   EmpathyChatroom *chatroom;
 
   account = get_test_account ();
index 65273f8c85ca4724cb02dbb60e491970abcf9107..c77cf9b75677888e9ac89540d9ad0e5126a020fa 100644 (file)
@@ -24,6 +24,8 @@
 #include <gconf/gconf.h>
 #include <gconf/gconf-client.h>
 
+#include <libempathy/empathy-account-manager.h>
+
 #include "check-helpers.h"
 #include "check-empathy-helpers.h"
 
@@ -63,25 +65,31 @@ copy_xml_file (const gchar *orig,
   g_free (buffer);
 }
 
-McAccount *
+EmpathyAccount *
 get_test_account (void)
 {
   McProfile *profile;
-  McAccount *account;
+  EmpathyAccountManager *account_manager;
+  EmpathyAccount *account;
   GList *accounts;
 
+  account_manager = empathy_account_manager_dup_singleton ();
   profile = mc_profile_lookup ("test");
   accounts = mc_accounts_list_by_profile (profile);
   if (g_list_length (accounts) == 0)
     {
       /* need to create a test account */
-      account = mc_account_create (profile);
+      account = empathy_account_manager_create (account_manager, profile);
     }
   else
     {
       /* reuse an existing test account */
-      account = accounts->data;
+      McAccount *mc_account;
+      mc_account = accounts->data;
+      account = empathy_account_manager_lookup (account_manager,
+        mc_account_get_unique_name (mc_account));
     }
+  g_object_unref (account_manager);
 
   g_object_unref (profile);
 
@@ -91,16 +99,17 @@ get_test_account (void)
 /* 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)
+destroy_test_account (EmpathyAccount *account)
 {
   GConfClient *client;
   gchar *path;
   GError *error = NULL;
   GSList *entries = NULL, *l;
+  EmpathyAccountManager *manager;
 
   client = gconf_client_get_default ();
   path = g_strdup_printf ("/apps/telepathy/mc/accounts/%s",
-      mc_account_get_unique_name (account));
+      empathy_account_get_unique_name (account));
 
   entries = gconf_client_all_entries (client, path, &error);
   if (error != NULL)
@@ -151,6 +160,8 @@ destroy_test_account (McAccount *account)
   g_object_unref (client);
   g_free (path);
 
-  mc_account_delete (account);
+  manager = empathy_account_manager_dup_singleton ();
+  empathy_account_manager_remove (manager, account);
   g_object_unref (account);
+  g_object_unref (manager);
 }
index 4d52c04e5872c9ac4990d25725ffa04d14a3ad8e..5544b80aa7f4ebe3d00939323393407a3920fe1c 100644 (file)
 #define __CHECK_EMPATHY_HELPERS_H__
 
 #include <glib.h>
-#include <libmissioncontrol/mc-account.h>
+#include <libempathy/empathy-account.h>
 
 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 * get_test_account (void);
-void destroy_test_account (McAccount *account);
+EmpathyAccount * get_test_account (void);
+void destroy_test_account (EmpathyAccount *account);
 
 #endif /* #ifndef __CHECK_EMPATHY_HELPERS_H__ */
index 3e0783811b0b7b67b3fc26ff4dee276a692ac323..b71b3b65b93817f2373702bf5b0778fe5d7581b5 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <glib.h>
 #include <check.h>
-#include <libmissioncontrol/mc-account.h>
 
 void
 check_helpers_init (void);