[glib/bookmark-visited] Add a GBookmarkFile serialization test case



commit 9f7f2b4d55e4dbd54bbabb235f5bef8297bb8d65
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat May 30 17:40:52 2020 +0100

    Add a GBookmarkFile serialization test case
    
    We're roundtripping from a valid file, but we should also roundtrip from
    a newly created GBookmarkFile, to ensure that we set all the necessary
    fields.

 glib/tests/bookmarkfile.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/bookmarkfile.c b/glib/tests/bookmarkfile.c
index 2722ebe48..bc1a7a213 100644
--- a/glib/tests/bookmarkfile.c
+++ b/glib/tests/bookmarkfile.c
@@ -43,10 +43,36 @@ test_to_file (void)
   const gchar *filename;
   gboolean res;
   GError *error = NULL;
-  gchar *in, *out;
+  char *in, *out;
 
   bookmark = g_bookmark_file_new ();
 
+  g_test_message ("Roundtrip from newly created bookmark file");
+  g_bookmark_file_set_title (bookmark, "file:///tmp/schedule.ps", "schedule.ps");
+  g_bookmark_file_set_mime_type (bookmark, "file:///tmp/schedule.ps", "application/postscript");
+  g_bookmark_file_add_application (bookmark, "file:///tmp/schedule.ps", "ghostscript", "ghostscript %F");
+
+  res = g_bookmark_file_to_file (bookmark, "out.xbel", &error);
+  g_assert_no_error (error);
+  g_assert_true (res);
+
+  res = g_bookmark_file_load_from_file (bookmark, "out.xbel", &error);
+  g_assert_no_error (error);
+  g_assert_true (res);
+
+  out = g_bookmark_file_get_title (bookmark, "file:///tmp/schedule.ps", &error);
+  g_assert_no_error (error);
+  g_assert_cmpstr (out, ==, "schedule.ps");
+  g_free (out);
+
+  out = g_bookmark_file_get_mime_type (bookmark, "file:///tmp/schedule.ps", &error);
+  g_assert_no_error (error);
+  g_assert_cmpstr (out, ==, "application/postscript");
+  g_free (out);
+
+  remove ("out.xbel");
+
+  g_test_message ("Roundtrip from a valid bookmark file");
   filename = g_test_get_filename (G_TEST_DIST, "bookmarks", "valid-01.xbel", NULL);
   res = g_bookmark_file_load_from_file (bookmark, filename, &error);
   g_assert_no_error (error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]