1 /* GStreamer unit tests for GstURI
3 * Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include <gst/check/gstcheck.h>
23 GST_START_TEST (test_protocol_case)
27 element = gst_element_make_from_uri (GST_URI_SRC, "file:///foo/bar", NULL);
29 /* no element? probably no registry, bail out */
33 gst_object_unref (element);
34 element = gst_element_make_from_uri (GST_URI_SRC, "FILE:///foo/bar", NULL);
35 fail_unless (element != NULL,
36 "Got source for 'file://' URI but not for 'FILE://' URI");
37 gst_object_unref (element);
42 GST_START_TEST (test_uri_get_location)
46 /* URI with no location should return empty string */
47 l = gst_uri_get_location ("dvd://");
48 fail_unless (l != NULL);
49 fail_unless_equals_string (l, "");
52 /* URI with hostname */
53 l = gst_uri_get_location ("smb://supercomputer/path/to/file");
54 fail_unless (l != NULL);
55 fail_unless_equals_string (l, "supercomputer/path/to/file");
59 l = gst_uri_get_location ("file:///path/to/file");
60 fail_unless (l != NULL);
61 fail_unless_equals_string (l, "/path/to/file");
65 l = gst_uri_get_location ("file:///path/to/some%20file");
66 fail_unless (l != NULL);
67 fail_unless_equals_string (l, "/path/to/some file");
75 GST_START_TEST (test_win32_uri)
79 uri = g_strdup ("file:///c:/my%20music/foo.ogg");
80 l = gst_uri_get_location (uri);
81 fail_unless (l != NULL);
82 /* fail_unless_equals_string will screw up here in the failure case
83 * because the string constant will be appended to the printf format
84 * message string and contains a '%', that's why we use fail_unless here */
85 fail_unless (g_str_equal (l, "c:/my music/foo.ogg"),
86 "wrong location '%s' returned for URI '%s'", l, uri);
90 /* make sure the other variant with two slashes before the C: (which was
91 * needed before because of a bug in _get_location()) still works */
92 uri = g_strdup ("file://c:/my%20music/foo.ogg");
93 l = gst_uri_get_location (uri);
94 fail_unless (l != NULL);
95 /* fail_unless_equals_string will screw up here in the failure case
96 * because the string constant will be appended to the printf format
97 * message string and contains a '%', that's why we use fail_unless here */
98 fail_unless (g_str_equal (l, "c:/my music/foo.ogg"),
99 "wrong location '%s' returned for URI '%s'", l, uri);
106 #endif /* G_OS_WIN32 */
111 Suite *s = suite_create ("GstURI");
112 TCase *tc_chain = tcase_create ("uri");
114 tcase_set_timeout (tc_chain, 20);
116 suite_add_tcase (s, tc_chain);
117 tcase_add_test (tc_chain, test_protocol_case);
118 tcase_add_test (tc_chain, test_uri_get_location);
120 tcase_add_test (tc_chain, test_win32_uri);
126 GST_CHECK_MAIN (gst_uri);