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);
40 gboolean auto_connect;
45 check_chatrooms_list (EmpathyChatroomManager *mgr,
47 struct chatroom_t *_chatrooms,
53 fail_if (empathy_chatroom_manager_get_count (mgr, account) != nb_chatrooms);
55 chatrooms = empathy_chatroom_manager_get_chatrooms (mgr, account);
56 fail_if (g_list_length (chatrooms) != nb_chatrooms);
58 for (l = chatrooms, i = 0; l != NULL; l = g_list_next (l), i++)
60 EmpathyChatroom *chatroom = l->data;
62 check_chatroom (chatroom, _chatrooms[i].name, _chatrooms[i].room,
63 _chatrooms[i].auto_connect, _chatrooms[i].favorite);
67 START_TEST (test_empathy_chatroom_manager_new)
69 EmpathyChatroomManager *mgr;
73 struct chatroom_t chatrooms[] = {
74 { "name2", "room2", FALSE, TRUE },
75 { "name1", "room1", TRUE, TRUE }};
77 account = create_test_account ();
79 copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
81 file = get_user_xml_file (CHATROOM_FILE);
82 /* change the chatrooms XML file to use the account we just created */
83 cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
84 mc_account_get_unique_name (account), file);
88 mgr = empathy_chatroom_manager_new (file);
89 check_chatrooms_list (mgr, account, chatrooms, 2);
93 destroy_test_account (account);
98 make_empathy_chatroom_manager_tcase (void)
100 TCase *tc = tcase_create ("empathy-chatroom-manager");
101 tcase_add_test (tc, test_empathy_chatroom_manager_new);