tests: filesrc: fix for windows
authorTim-Philipp Müller <tim@centricular.com>
Thu, 11 Jan 2018 14:56:42 +0000 (14:56 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 11 Jan 2018 14:56:42 +0000 (14:56 +0000)
Location paths have backslashes on windows when converted from URI.

tests/check/elements/filesrc.c

index fd42284..ead87aa 100644 (file)
@@ -367,26 +367,45 @@ GST_START_TEST (test_uri_interface)
   fail_unless_equals_string (location, "file:///i/do/not/exist");
   g_free (location);
 
+#define DSEP G_DIR_SEPARATOR_S
+
   /* should accept file:///foo/bar URIs */
   fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src),
           "file:///foo/bar", NULL));
   location = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
   fail_unless_equals_string (location, "file:///foo/bar");
   g_free (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);
 
+#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 */
   fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (src),
           "file://localhost/foo/baz", NULL));
   location = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
   fail_unless_equals_string (location, "file:///foo/baz");
   g_free (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);
 
+#undef DSEP
+
   /* 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_get (G_OBJECT (src), "location", &location, NULL);