summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2012-11-27 15:08:54 +0100
committerJens Georg <mail@jensge.org>2012-11-28 17:40:19 +0100
commit14337ba553f303e1df16910e39635b83a8ddf786 (patch)
tree4dddcb69bc34a3ccb54e508d44afaba40495a305
parent00be47d7ce2640a88896aec2f04032fb9c77e7fc (diff)
downloadgupnp-av-14337ba553f303e1df16910e39635b83a8ddf786.tar.gz
Test for DIDL_S parsing fails
-rw-r--r--tests/gtest/test-media-collection.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/gtest/test-media-collection.c b/tests/gtest/test-media-collection.c
index 8d00dcf..e9abfd1 100644
--- a/tests/gtest/test-media-collection.c
+++ b/tests/gtest/test-media-collection.c
@@ -162,6 +162,7 @@
"</container>" \
"</DIDL-Lite>"
+#define TEST_PARSE_NO_XML "This is just some random text"
void
test_didl_collection_construction ()
@@ -271,6 +272,37 @@ test_didl_collection_parse_full ()
g_list_free_full (items, (GDestroyNotify) g_object_unref);
}
+#define ERROR_MESSAGE "Failed to parse DIDL-Lite: No 'DIDL-Lite' node in the DIDL-Lite XML:"
+
+static gboolean
+ignore_xml_parse_error (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ if (strncmp (message,
+ ERROR_MESSAGE,
+ g_utf8_strlen (ERROR_MESSAGE, -1) - 1) == 0) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void
+test_didl_collection_parse_invalid ()
+{
+ GUPnPMediaCollection *collection;
+ GList *items;
+
+ g_test_log_set_fatal_handler (ignore_xml_parse_error, NULL);
+ collection = gupnp_media_collection_new_from_string (TEST_PARSE_NO_XML);
+ items = gupnp_media_collection_get_items (collection);
+
+ g_assert (items == NULL);
+ g_object_unref (collection);
+}
+
void
test_didl_collection_create_flat ()
{
@@ -445,6 +477,8 @@ int main (int argc, char *argv[])
test_didl_collection_parse_flat);
g_test_add_func ("/didl/collection/parse_full",
test_didl_collection_parse_full);
+ g_test_add_func ("/didl/collection/parse_invalid",
+ test_didl_collection_parse_invalid);
g_test_add_func ("/didl/collection/create_flat",
test_didl_collection_create_flat);
@@ -454,4 +488,4 @@ int main (int argc, char *argv[])
test_didl_collection_create_reparent);
return g_test_run ();
-} \ No newline at end of file
+}