tests: add unit test for gst_element_make_from_uri()

https://bugzilla.gnome.org/show_bug.cgi?id=645467
This commit is contained in:
Tim-Philipp Müller 2012-06-23 14:41:50 +01:00
parent 2f46207ec7
commit e4b6bcb7b9

View file

@ -23,15 +23,20 @@
GST_START_TEST (test_protocol_case)
{
GstElement *element;
GError *err = NULL;
element = gst_element_make_from_uri (GST_URI_SRC, "file:///foo/bar", NULL);
element = gst_element_make_from_uri (GST_URI_SRC, "file:///foo/bar", NULL,
&err);
/* no element? probably no registry, bail out */
if (element == NULL)
if (element == NULL && err->code == GST_URI_ERROR_UNSUPPORTED_PROTOCOL) {
g_error_free (err);
return;
}
gst_object_unref (element);
element = gst_element_make_from_uri (GST_URI_SRC, "FILE:///foo/bar", NULL);
element = gst_element_make_from_uri (GST_URI_SRC, "FILE:///foo/bar", NULL,
NULL);
fail_unless (element != NULL,
"Got source for 'file://' URI but not for 'FILE://' URI");
gst_object_unref (element);
@ -129,6 +134,35 @@ GST_START_TEST (test_uri_misc)
GST_END_TEST;
GST_START_TEST (test_element_make_from_uri)
{
GstElement *element;
GError *err = NULL;
element = gst_element_make_from_uri (GST_URI_SRC, "foo://", NULL, NULL);
fail_unless (element == NULL);
element = gst_element_make_from_uri (GST_URI_SRC, "foo://", NULL, &err);
fail_unless (element == NULL);
fail_unless (err != NULL);
fail_unless (err->code == GST_URI_ERROR_UNSUPPORTED_PROTOCOL);
g_error_free (err);
err = NULL;
if (gst_registry_check_feature_version (gst_registry_get (), "filesrc",
GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO)) {
element = gst_element_make_from_uri (GST_URI_SRC, "file://host/foo", NULL,
&err);
fail_unless (element == NULL);
fail_unless (err != NULL);
fail_unless (err->code == GST_URI_ERROR_BAD_URI);
g_error_free (err);
err = NULL;
}
}
GST_END_TEST;
static Suite *
gst_uri_suite (void)
{
@ -141,6 +175,7 @@ gst_uri_suite (void)
tcase_add_test (tc_chain, test_protocol_case);
tcase_add_test (tc_chain, test_uri_get_location);
tcase_add_test (tc_chain, test_uri_misc);
tcase_add_test (tc_chain, test_element_make_from_uri);
#ifdef G_OS_WIN32
tcase_add_test (tc_chain, test_win32_uri);
#endif