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"
20 START_TEST (test_empathy_chatroom_manager_new)
22 EmpathyChatroomManager *mgr;
27 gboolean room1_found, room2_found;
29 account = create_test_account ();
31 copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
33 file = get_user_xml_file (CHATROOM_FILE);
34 /* change the chatrooms XML file to use the account we just created */
35 cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
36 mc_account_get_unique_name (account), file);
40 mgr = empathy_chatroom_manager_new (file);
42 fail_if (empathy_chatroom_manager_get_count (mgr, account) != 2);
44 chatrooms = empathy_chatroom_manager_get_chatrooms (mgr, account);
45 fail_if (g_list_length (chatrooms) != 2);
47 room1_found = room2_found = FALSE;
48 for (l = chatrooms; l != NULL; l = g_list_next (l))
50 EmpathyChatroom *chatroom = l->data;
53 if (!tp_strdiff (empathy_chatroom_get_room (chatroom), "room1"))
56 fail_if (tp_strdiff (empathy_chatroom_get_name (chatroom), "name1"));
57 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
58 g_object_get (chatroom, "favorite", &favorite, NULL);
61 else if (!tp_strdiff (empathy_chatroom_get_room (chatroom), "room2"))
64 fail_if (tp_strdiff (empathy_chatroom_get_name (chatroom), "name2"));
65 fail_if (empathy_chatroom_get_auto_connect (chatroom));
66 g_object_get (chatroom, "favorite", &favorite, NULL);
71 g_assert_not_reached ();
75 fail_if (!room1_found || !room2_found);
79 destroy_test_account (account);
84 make_empathy_chatroom_manager_tcase (void)
86 TCase *tc = tcase_create ("empathy-chatroom-manager");
87 tcase_add_test (tc, test_empathy_chatroom_manager_new);