[totem-pl-parser] tests: Add test for playlist content-types



commit 994721178141f9812769a00dd7d7a551ae36becb
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 20 12:10:37 2013 +0100

    tests: Add test for playlist content-types

 plparse/tests/parser.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 34ac27a..1e29b4f 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -461,6 +461,40 @@ parser_test_get_playlist_uri (const char *uri)
 }
 
 static void
+playlist_started_field_cb (TotemPlParser *parser,
+                          const char *uri,
+                          GHashTable *metadata,
+                          ParserResult *res)
+{
+       res->ret = g_strdup (g_hash_table_lookup (metadata, res->field));
+}
+
+static char *
+parser_test_get_playlist_field (const char *uri,
+                               const char *field)
+{
+       TotemPlParserResult retval;
+       ParserResult res;
+       TotemPlParser *pl = totem_pl_parser_new ();
+
+       g_object_set (pl, "recurse", !option_no_recurse,
+                         "debug", option_debug,
+                         "force", option_force,
+                         "disable-unsafe", option_disable_unsafe,
+                         NULL);
+       res.field = field;
+       res.ret = NULL;
+       g_signal_connect (G_OBJECT (pl), "playlist-started",
+                         G_CALLBACK (playlist_started_field_cb), &res);
+
+       retval = totem_pl_parser_parse_with_base (pl, uri, option_base_uri, FALSE);
+       g_test_message ("Got retval %d for uri '%s'", retval, uri);
+       g_object_unref (pl);
+
+       return res.ret;
+}
+
+static void
 test_image_link (void)
 {
 #ifdef HAVE_QUVI
@@ -501,6 +535,16 @@ test_itms_parsing (void)
 }
 
 static void
+test_pl_content_type (void)
+{
+       char *uri;
+
+       uri = get_relative_uri (TEST_SRCDIR "old-lastfm-output.xspf");
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE), ==, 
"application/xspf+xml");
+       g_free (uri);
+}
+
+static void
 test_lastfm_parsing (void)
 {
        char *uri;
@@ -1228,6 +1272,7 @@ main (int argc, char *argv[])
                g_test_add_func ("/parser/parsing/xspf_genre", test_parsing_xspf_genre);
                g_test_add_func ("/parser/parsing/xspf_escaping", test_parsing_xspf_escaping);
                g_test_add_func ("/parser/parsing/xspf_xml_base", test_parsing_xspf_xml_base);
+               g_test_add_func ("/parser/parsing/test_pl_content_type", test_pl_content_type);
                g_test_add_func ("/parser/parsing/itms_link", test_itms_parsing);
                g_test_add_func ("/parser/parsing/lastfm-attributes", test_lastfm_parsing);
                g_test_add_func ("/parser/parsing/m3u_separator", test_m3u_separator);


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