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