tests: filesrc: fix for windows

Location paths have backslashes on windows when converted from URI.
This commit is contained in:
Tim-Philipp Müller 2018-01-11 14:56:42 +00:00
parent 88dfd9ee48
commit 4a5aa8dba0

View file

@ -367,26 +367,45 @@ GST_START_TEST (test_uri_interface)
fail_unless_equals_string (location, "file:///i/do/not/exist"); fail_unless_equals_string (location, "file:///i/do/not/exist");
g_free (location); g_free (location);
#define DSEP G_DIR_SEPARATOR_S
/* should accept file:///foo/bar URIs */ /* should accept file:///foo/bar URIs */
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src), fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src),
"file:///foo/bar", NULL)); "file:///foo/bar", NULL));
location = gst_uri_handler_get_uri (GST_URI_HANDLER (src)); location = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
fail_unless_equals_string (location, "file:///foo/bar"); fail_unless_equals_string (location, "file:///foo/bar");
g_free (location); g_free (location);
location = NULL;
g_object_get (G_OBJECT (src), "location", &location, NULL); g_object_get (G_OBJECT (src), "location", &location, NULL);
fail_unless_equals_string (location, "/foo/bar"); fail_unless_equals_string (location, DSEP "foo" DSEP "bar");
g_free (location); g_free (location);
#ifdef G_OS_WIN32
/* should accept file:///c:/foo/bar.txt URIs */
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src),
"file://c:/foo/bar", NULL));
location = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
fail_unless_equals_string (location, "file://c:/foo/bar");
g_free (location);
location = NULL;
g_object_get (G_OBJECT (src), "location", &location, NULL);
fail_unless_equals_string (location, "c:" DSEP "foo" DSEP "bar");
g_free (location);
#endif
/* should accept file://localhost/foo/bar URIs */ /* should accept file://localhost/foo/bar URIs */
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src), fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src),
"file://localhost/foo/baz", NULL)); "file://localhost/foo/baz", NULL));
location = gst_uri_handler_get_uri (GST_URI_HANDLER (src)); location = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
fail_unless_equals_string (location, "file:///foo/baz"); fail_unless_equals_string (location, "file:///foo/baz");
g_free (location); g_free (location);
location = NULL;
g_object_get (G_OBJECT (src), "location", &location, NULL); g_object_get (G_OBJECT (src), "location", &location, NULL);
fail_unless_equals_string (location, "/foo/baz"); fail_unless_equals_string (location, DSEP "foo" DSEP "baz");
g_free (location); g_free (location);
#undef DSEP
/* should escape non-uri characters for the URI but not for the location */ /* should escape non-uri characters for the URI but not for the location */
g_object_set (G_OBJECT (src), "location", "/foo/b?r", NULL); g_object_set (G_OBJECT (src), "location", "/foo/b?r", NULL);
g_object_get (G_OBJECT (src), "location", &location, NULL); g_object_get (G_OBJECT (src), "location", &location, NULL);