2008-05-24 Tim-Philipp Müller <tim.muller at collabora co uk>
+ * tests/check/Makefile.am:
+ * tests/check/pipelines/parse-launch.c:
+ Add some unit tests for the new gst_parse_launch*_full() API.
+ (Exposes a previously-existing memory leak in the error code
+ path, so adding to VALGRIND_TO_FIX for now).
+
+2008-05-24 Tim-Philipp Müller <tim.muller at collabora co uk>
+
* docs/gst/gstreamer-sections.txt:
* gst/gst.c: (init_post):
* gst/gst_private.h: (_GstParseContext):
-/* GStreamer
+/* GStreamer gst_parse_launch unit tests
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * cleanup.c: Unit test for cleanup of pipelines
+ * Copyright (C) <2008> Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
}
+GST_START_TEST (test_missing_elements)
+{
+ GstParseContext *ctx;
+ GstElement *element;
+ GError *err = NULL;
+ gchar **arr;
+
+ /* avoid misleading 'no such element' error debug messages when using cvs */
+ if (!g_getenv ("GST_DEBUG"))
+ gst_debug_set_default_threshold (GST_LEVEL_NONE);
+
+ ctx = gst_parse_context_new ();
+ element = gst_parse_launch_full ("fakesrc ! coffeesink", ctx,
+ GST_PARSE_FLAG_FATAL_ERRORS, &err);
+ fail_unless (err != NULL, "expected error");
+ fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT);
+ fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS");
+ arr = gst_parse_context_get_missing_elements (ctx);
+ fail_unless (arr != NULL, "expected missing elements");
+ fail_unless_equals_string (arr[0], "coffeesink");
+ fail_unless (arr[1] == NULL);
+ g_strfreev (arr);
+ gst_parse_context_free (ctx);
+ g_error_free (err);
+ err = NULL;
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_flags)
+{
+ GstElement *element;
+ GError *err = NULL;
+
+ /* avoid misleading 'no such element' error debug messages when using cvs */
+ if (!g_getenv ("GST_DEBUG"))
+ gst_debug_set_default_threshold (GST_LEVEL_NONE);
+
+ /* default behaviour is to return any already constructed bins/elements */
+ element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, 0, &err);
+ fail_unless (err != NULL, "expected error");
+ fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT);
+ fail_unless (element != NULL, "expected partial pipeline/element");
+ g_error_free (err);
+ err = NULL;
+ gst_object_unref (element);
+
+ /* test GST_PARSE_FLAG_FATAL_ERRORS */
+ element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL,
+ GST_PARSE_FLAG_FATAL_ERRORS, &err);
+ fail_unless (err != NULL, "expected error");
+ fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT);
+ fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS");
+ g_error_free (err);
+ err = NULL;
+}
+
+GST_END_TEST;
+
static Suite *
parse_suite (void)
{
tcase_add_test (tc_chain, expected_to_fail_pipes);
tcase_add_test (tc_chain, leaking_fail_pipes);
tcase_add_test (tc_chain, delayed_link);
+ tcase_add_test (tc_chain, test_flags);
+ tcase_add_test (tc_chain, test_missing_elements);
return s;
}