4 #include <glib/gstdio.h>
6 #include <gconf/gconf.h>
7 #include <gconf/gconf-client.h>
8 #include <telepathy-glib/util.h>
11 #include "check-helpers.h"
12 #include "check-libempathy.h"
13 #include "check-empathy-helpers.h"
15 #include <libempathy/empathy-chatroom-manager.h>
17 #define CHATROOM_SAMPLE "chatrooms-sample.xml"
18 #define CHATROOM_FILE "chatrooms.xml"
21 check_chatroom (EmpathyChatroom *chatroom,
24 gboolean auto_connect,
29 fail_if (tp_strdiff (empathy_chatroom_get_name (chatroom), name));
30 fail_if (tp_strdiff (empathy_chatroom_get_room (chatroom), room));
31 fail_if (empathy_chatroom_get_auto_connect (chatroom) != auto_connect);
32 g_object_get (chatroom, "favorite", &_favorite, NULL);
33 fail_if (favorite != _favorite);
36 START_TEST (test_empathy_chatroom_manager_new)
38 EmpathyChatroomManager *mgr;
43 gboolean room1_found, room2_found;
45 account = create_test_account ();
47 copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
49 file = get_user_xml_file (CHATROOM_FILE);
50 /* change the chatrooms XML file to use the account we just created */
51 cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
52 mc_account_get_unique_name (account), file);
56 mgr = empathy_chatroom_manager_new (file);
58 fail_if (empathy_chatroom_manager_get_count (mgr, account) != 2);
60 chatrooms = empathy_chatroom_manager_get_chatrooms (mgr, account);
61 fail_if (g_list_length (chatrooms) != 2);
63 room1_found = room2_found = FALSE;
64 for (l = chatrooms; l != NULL; l = g_list_next (l))
66 EmpathyChatroom *chatroom = l->data;
68 if (!tp_strdiff (empathy_chatroom_get_room (chatroom), "room1"))
71 check_chatroom (chatroom, "name1", "room1", TRUE, TRUE);
73 else if (!tp_strdiff (empathy_chatroom_get_room (chatroom), "room2"))
76 check_chatroom (chatroom, "name2", "room2", FALSE, TRUE);
80 g_assert_not_reached ();
84 fail_if (!room1_found || !room2_found);
88 destroy_test_account (account);
93 make_empathy_chatroom_manager_tcase (void)
95 TCase *tc = tcase_create ("empathy-chatroom-manager");
96 tcase_add_test (tc, test_empathy_chatroom_manager_new);