Help: Use stable 'if' namespace instead of experimental
[nijm-empathy.git] / tests / test-helper.c
blobefe3e3fd6a023d3b9b4f90057dcaeb9745813e47
1 /*
2 * test-helper.c - Source for some test helper functions
3 * Copyright (C) 2007-2009 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "config.h"
21 #include "test-helper.h"
23 #include "empathy-ui-utils.h"
25 void
26 test_init (int argc,
27 char **argv)
29 g_test_init (&argc, &argv, NULL);
30 gtk_init (&argc, &argv);
31 empathy_gtk_init ();
34 void
35 test_deinit (void)
40 gchar *
41 get_xml_file (const gchar *filename)
43 return g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "tests", "xml",
44 filename, NULL);
47 gchar *
48 get_user_xml_file (const gchar *filename)
50 return g_build_filename (g_get_tmp_dir (), filename, NULL);
53 void
54 copy_xml_file (const gchar *orig,
55 const gchar *dest)
57 gboolean result;
58 gchar *buffer;
59 gsize length;
60 gchar *sample;
61 gchar *file;
63 sample = get_xml_file (orig);
64 result = g_file_get_contents (sample, &buffer, &length, NULL);
65 g_assert (result);
67 file = get_user_xml_file (dest);
68 result = g_file_set_contents (file, buffer, length, NULL);
69 g_assert (result);
71 g_free (sample);
72 g_free (file);
73 g_free (buffer);