[gupnp-av] Test for DIDL_S parsing fails
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-av] Test for DIDL_S parsing fails
- Date: Wed, 28 Nov 2012 16:40:51 +0000 (UTC)
commit 14337ba553f303e1df16910e39635b83a8ddf786
Author: Jens Georg <mail jensge org>
Date: Tue Nov 27 15:08:54 2012 +0100
Test for DIDL_S parsing fails
tests/gtest/test-media-collection.c | 36 ++++++++++++++++++++++++++++++++++-
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
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]