aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check-empathy-chatroom-manager.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:54:40 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:54:40 +0800
commitcd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44 (patch)
tree66e632f55ce7280dd2189443756de4a1e7ca22a8 /tests/check-empathy-chatroom-manager.c
parent7d83d3fdde1ea98df35fe5a093cf0f2a591f1c07 (diff)
downloadgsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.tar
gsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.tar.gz
gsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.tar.bz2
gsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.tar.lz
gsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.tar.xz
gsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.tar.zst
gsoc2013-empathy-cd2c292aefc1ce60bf51a7e9aaa070dd59ef7c44.zip
factor out check_chatrooms_list
svn path=/trunk/; revision=1559
Diffstat (limited to 'tests/check-empathy-chatroom-manager.c')
-rw-r--r--tests/check-empathy-chatroom-manager.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/tests/check-empathy-chatroom-manager.c b/tests/check-empathy-chatroom-manager.c
index 276a388fe..97feb7bfd 100644
--- a/tests/check-empathy-chatroom-manager.c
+++ b/tests/check-empathy-chatroom-manager.c
@@ -33,14 +33,46 @@ check_chatroom (EmpathyChatroom *chatroom,
fail_if (favorite != _favorite);
}
+struct chatroom_t
+{
+ gchar *name;
+ gchar *room;
+ gboolean auto_connect;
+ gboolean favorite;
+};
+
+static void
+check_chatrooms_list (EmpathyChatroomManager *mgr,
+ McAccount *account,
+ struct chatroom_t *_chatrooms,
+ guint nb_chatrooms)
+{
+ GList *chatrooms, *l;
+ guint i;
+
+ fail_if (empathy_chatroom_manager_get_count (mgr, account) != nb_chatrooms);
+
+ chatrooms = empathy_chatroom_manager_get_chatrooms (mgr, account);
+ fail_if (g_list_length (chatrooms) != nb_chatrooms);
+
+ for (l = chatrooms, i = 0; l != NULL; l = g_list_next (l), i++)
+ {
+ EmpathyChatroom *chatroom = l->data;
+
+ check_chatroom (chatroom, _chatrooms[i].name, _chatrooms[i].room,
+ _chatrooms[i].auto_connect, _chatrooms[i].favorite);
+ }
+}
+
START_TEST (test_empathy_chatroom_manager_new)
{
EmpathyChatroomManager *mgr;
gchar *cmd;
gchar *file;
McAccount *account;
- GList *chatrooms, *l;
- gboolean room1_found, room2_found;
+ struct chatroom_t chatrooms[] = {
+ { "name2", "room2", FALSE, TRUE },
+ { "name1", "room1", TRUE, TRUE }};
account = create_test_account ();
@@ -54,34 +86,7 @@ START_TEST (test_empathy_chatroom_manager_new)
g_free (cmd);
mgr = empathy_chatroom_manager_new (file);
-
- fail_if (empathy_chatroom_manager_get_count (mgr, account) != 2);
-
- chatrooms = empathy_chatroom_manager_get_chatrooms (mgr, account);
- fail_if (g_list_length (chatrooms) != 2);
-
- room1_found = room2_found = FALSE;
- for (l = chatrooms; l != NULL; l = g_list_next (l))
- {
- EmpathyChatroom *chatroom = l->data;
-
- if (!tp_strdiff (empathy_chatroom_get_room (chatroom), "room1"))
- {
- room1_found = TRUE;
- check_chatroom (chatroom, "name1", "room1", TRUE, TRUE);
- }
- else if (!tp_strdiff (empathy_chatroom_get_room (chatroom), "room2"))
- {
- room2_found = TRUE;
- check_chatroom (chatroom, "name2", "room2", FALSE, TRUE);
- }
- else
- {
- g_assert_not_reached ();
- }
- }
-
- fail_if (!room1_found || !room2_found);
+ check_chatrooms_list (mgr, account, chatrooms, 2);
g_free (file);
g_object_unref (mgr);