1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <glib/gstdio.h>
#include <check.h>
#include "check-helpers.h"
#include "check-libempathy.h"
#include <libempathy/empathy-chatroom-manager.h>
#define CHATROOM_SAMPLE "chatrooms-sample.xml"
#define CHATROOM_FILE "chatrooms.xml"
static gchar *
get_xml_file (const gchar *filename)
{
return g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "tests", "xml",
filename, NULL);
}
static gchar *
get_user_xml_file (const gchar *filename)
{
return g_build_filename (g_get_tmp_dir (), filename, NULL);
}
static void
copy_chatroom_file (void)
{
gboolean result;
gchar *buffer;
gsize length;
gchar *sample;
gchar *file;
sample = get_xml_file (CHATROOM_SAMPLE);
result = g_file_get_contents (sample, &buffer, &length, NULL);
fail_if (!result);
file = get_user_xml_file (CHATROOM_FILE);
result = g_file_set_contents (file, buffer, length, NULL);
fail_if (!result);
g_free (sample);
g_free (file);
g_free (buffer);
}
START_TEST (test_empathy_chatroom_manager_new)
{
EmpathyChatroomManager *mgr;
gchar *file;
copy_chatroom_file ();
file = get_xml_file (CHATROOM_FILE);
mgr = empathy_chatroom_manager_new (file);
g_free (file);
g_object_unref (mgr);
}
END_TEST
TCase *
make_empathy_chatroom_manager_tcase (void)
{
TCase *tc = tcase_create ("empathy-chatroom-manager");
tcase_add_test (tc, test_empathy_chatroom_manager_new);
return tc;
}
|