]> git.0d.be Git - empathy.git/blob - tests/check-empathy-chatroom-manager.c
load the chatrooms sample XML file
[empathy.git] / tests / check-empathy-chatroom-manager.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <glib/gstdio.h>
5
6 #include <check.h>
7 #include "check-helpers.h"
8 #include "check-libempathy.h"
9
10 #include <libempathy/empathy-chatroom-manager.h>
11
12 #define CHATROOM_SAMPLE "chatrooms-sample.xml"
13 #define CHATROOM_FILE "chatrooms.xml"
14
15 START_TEST (test_empathy_chatroom_manager_new)
16 {
17   EmpathyChatroomManager *mgr;
18   gchar *cmd;
19   gchar *file;
20   McProfile *profile;
21   McAccount *account;
22
23   profile = mc_profile_lookup ("test");
24   account = mc_account_create (profile);
25
26   copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
27
28   file = get_user_xml_file (CHATROOM_FILE);
29   /* change the chatrooms XML file to use the account we just created */
30   cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
31       mc_account_get_unique_name (account), file);
32   system (cmd);
33   g_free (cmd);
34
35   mgr = empathy_chatroom_manager_new (file);
36
37   fail_if (empathy_chatroom_manager_get_count (mgr, account) != 2);
38
39   g_free (file);
40   g_object_unref (mgr);
41   g_object_unref (profile);
42   remove_account_from_gconf (account);
43   mc_account_delete (account);
44   g_object_unref (account);
45 }
46 END_TEST
47
48 TCase *
49 make_empathy_chatroom_manager_tcase (void)
50 {
51     TCase *tc = tcase_create ("empathy-chatroom-manager");
52     tcase_add_test (tc, test_empathy_chatroom_manager_new);
53     return tc;
54 }