summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-06-26 14:58:40 +0100
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-01 14:19:40 +0100
commitd3693520f43afa28ac328843ea3d01c2b1dac427 (patch)
tree31516866bd4de166295e1978d5366d792f48da84
parentf623e96f1e77b32d411150c4040055f11f17da2b (diff)
Port the tests to EmpathyAccount
-rw-r--r--tests/check-empathy-chatroom-manager.c45
-rw-r--r--tests/check-empathy-chatroom.c2
-rw-r--r--tests/check-empathy-helpers.c25
-rw-r--r--tests/check-empathy-helpers.h6
-rw-r--r--tests/check-helpers.h1
5 files changed, 51 insertions, 28 deletions
diff --git a/tests/check-empathy-chatroom-manager.c b/tests/check-empathy-chatroom-manager.c
index ef5c7761..1c0f924a 100644
--- a/tests/check-empathy-chatroom-manager.c
+++ b/tests/check-empathy-chatroom-manager.c
@@ -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
diff --git a/tests/check-empathy-chatroom.c b/tests/check-empathy-chatroom.c
index a4adf6ce..f2110a8f 100644
--- a/tests/check-empathy-chatroom.c
+++ b/tests/check-empathy-chatroom.c
@@ -12,7 +12,7 @@
static EmpathyChatroom *
create_chatroom (void)
{
- McAccount *account;
+ EmpathyAccount *account;
EmpathyChatroom *chatroom;
account = get_test_account ();
diff --git a/tests/check-empathy-helpers.c b/tests/check-empathy-helpers.c
index 65273f8c..c77cf9b7 100644
--- a/tests/check-empathy-helpers.c
+++ b/tests/check-empathy-helpers.c
@@ -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);
}
diff --git a/tests/check-empathy-helpers.h b/tests/check-empathy-helpers.h
index 4d52c04e..5544b80a 100644
--- a/tests/check-empathy-helpers.h
+++ b/tests/check-empathy-helpers.h
@@ -20,12 +20,12 @@
#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__ */
diff --git a/tests/check-helpers.h b/tests/check-helpers.h
index 3e078381..b71b3b65 100644
--- a/tests/check-helpers.h
+++ b/tests/check-helpers.h
@@ -21,7 +21,6 @@
#include <glib.h>
#include <check.h>
-#include <libmissioncontrol/mc-account.h>
void
check_helpers_init (void);