summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-02-27 18:35:15 +0100
committerBastien Nocera <hadess@hadess.net>2020-02-27 18:44:35 +0100
commit23b5b3fe0c8fd55aea1593b476f3de4156af5af2 (patch)
tree8d546fc0de2e68bfe28776f3718ce614404b2368
parente273d9077504ff4340dc5a55516f961a324b4ab1 (diff)
downloadtotem-pl-parser-23b5b3fe0c8fd55aea1593b476f3de4156af5af2.tar.gz
tests: Add a sync saving test
-rw-r--r--plparse/tests/parser.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 611093d..e628744 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -1089,6 +1089,54 @@ test_async_parsing_signal_order (void)
g_main_loop_unref (data.mainloop);
}
+static void
+add_pl_iter_metadata (TotemPlPlaylist *playlist,
+ TotemPlPlaylistIter *pl_iter)
+{
+ totem_pl_playlist_set (playlist, pl_iter,
+ TOTEM_PL_PARSER_FIELD_URI, "file:///fake/uri.mp4",
+ TOTEM_PL_PARSER_FIELD_TITLE, "custom title",
+ TOTEM_PL_PARSER_FIELD_SUBTITLE_URI, "file:///fake/uri.srt",
+ TOTEM_PL_PARSER_FIELD_PLAYING, "true",
+ TOTEM_PL_PARSER_FIELD_CONTENT_TYPE, "video/mp4",
+ TOTEM_PL_PARSER_FIELD_STARTTIME, "1",
+ NULL);
+}
+
+static void
+test_saving_sync (void)
+{
+ g_autoptr(TotemPlParser) parser = NULL;
+ g_autoptr(TotemPlPlaylist) playlist = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GFile) output = NULL;
+ TotemPlPlaylistIter pl_iter;
+ g_autofree char *path = NULL;
+ int fd;
+
+ parser = totem_pl_parser_new ();
+ playlist = totem_pl_playlist_new ();
+ fd = g_file_open_tmp (NULL, &path, &error);
+ g_assert_no_error (error);
+ close (fd);
+ output = g_file_new_for_path (path);
+
+ totem_pl_parser_save (parser,
+ playlist,
+ output,
+ NULL, TOTEM_PL_PARSER_XSPF, &error);
+ g_assert_error (error, TOTEM_PL_PARSER_ERROR, TOTEM_PL_PARSER_ERROR_EMPTY_PLAYLIST);
+ g_clear_error (&error);
+
+ totem_pl_playlist_append (playlist, &pl_iter);
+ add_pl_iter_metadata (playlist, &pl_iter);
+ totem_pl_parser_save (parser,
+ playlist,
+ output,
+ NULL, TOTEM_PL_PARSER_XSPF, &error);
+ g_assert_no_error (error);
+}
+
#define MAX_DESCRIPTION_LEN 128
#define DATE_BUFSIZE 512
#define PRINT_DATE_FORMAT "%Y-%m-%dT%H:%M:%SZ"
@@ -1359,6 +1407,7 @@ main (int argc, char *argv[])
g_test_add_func ("/parser/parsing/dir_recurse", test_directory_recurse);
g_test_add_func ("/parser/parsing/async_signal_order", test_async_parsing_signal_order);
g_test_add_func ("/parser/parsing/wma_asf", test_parsing_wma_asf);
+ g_test_add_func ("/parser/saving/sync", test_saving_sync);
return g_test_run ();
}