diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-10-13 15:54:02 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-10-13 15:54:02 +0800 |
commit | f0762d3d556c168c9ec1d85d69cf10cdf2fef97a (patch) | |
tree | 6aabff5ab9b31bc0885b3b8c6e0b530313f6c833 /tests/check-helpers.c | |
parent | 70730f587cae7c323d2c6d58384b8c628c62c5ad (diff) | |
download | gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.tar gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.tar.gz gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.tar.bz2 gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.tar.lz gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.tar.xz gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.tar.zst gsoc2013-empathy-f0762d3d556c168c9ec1d85d69cf10cdf2fef97a.zip |
factor out get_xml_file, get_user_xml_file and copy_xml_file
svn path=/trunk/; revision=1548
Diffstat (limited to 'tests/check-helpers.c')
-rw-r--r-- | tests/check-helpers.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/check-helpers.c b/tests/check-helpers.c index 7a7663fce..8cd46388c 100644 --- a/tests/check-helpers.c +++ b/tests/check-helpers.c @@ -61,3 +61,39 @@ check_helpers_init (void) g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, check_helper_log_critical_func, NULL); } + +gchar * +get_xml_file (const gchar *filename) +{ + return g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "tests", "xml", + filename, NULL); +} + +gchar * +get_user_xml_file (const gchar *filename) +{ + return g_build_filename (g_get_tmp_dir (), filename, NULL); +} + +void +copy_xml_file (const gchar *orig, + const gchar *dest) +{ + gboolean result; + gchar *buffer; + gsize length; + gchar *sample; + gchar *file; + + sample = get_xml_file (orig); + result = g_file_get_contents (sample, &buffer, &length, NULL); + fail_if (!result); + + file = get_user_xml_file (dest); + result = g_file_set_contents (file, buffer, length, NULL); + fail_if (!result); + + g_free (sample); + g_free (file); + g_free (buffer); +} |