]> git.0d.be Git - empathy.git/commitdiff
copy chatrooms xml file instead of using the sample one for tests
authorXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Oct 2008 07:53:59 +0000 (07:53 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Oct 2008 07:53:59 +0000 (07:53 +0000)
svn path=/trunk/; revision=1547

tests/check-empathy-chatroom-manager.c

index 82cfa6df0fbf61d2589259138eb1d64bdbb5b901..25014da1fc9e7dfefc5c3fd94b3f599300fba202 100644 (file)
@@ -19,12 +19,41 @@ get_xml_file (const gchar *filename)
       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;
 
-  file = get_xml_file (CHATROOM_SAMPLE);
+  copy_chatroom_file ();
+  file = get_xml_file (CHATROOM_FILE);
   mgr = empathy_chatroom_manager_new (file);
 
   g_free (file);