Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / tests / check / libs / rtsp.c
1 /* GStreamer unit tests for the RTSP support library
2  *
3  * Copyright (C) 2010 Andy Wingo <wingo@oblong.com>
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <gst/check/gstcheck.h>
26
27 #include <gst/rtsp/gstrtspurl.h>
28 #include <string.h>
29
30 GST_START_TEST (test_rtsp_url_basic)
31 {
32   GstRTSPUrl *url = NULL;
33   GstRTSPResult res;
34
35   res = gst_rtsp_url_parse ("rtsp://localhost/foo/bar", &url);
36   fail_unless (res == GST_RTSP_OK);
37   fail_unless (url != NULL);
38   fail_unless (url->transports & GST_RTSP_LOWER_TRANS_TCP);
39   fail_unless (url->transports & GST_RTSP_LOWER_TRANS_UDP);
40   fail_unless (url->transports & GST_RTSP_LOWER_TRANS_UDP_MCAST);
41   fail_unless (url->family == GST_RTSP_FAM_INET);
42   fail_unless (!url->user);
43   fail_unless (!url->passwd);
44   fail_unless (!strcmp (url->host, "localhost"));
45   /* fail_unless (url->port == GST_RTSP_DEFAULT_PORT); */
46   fail_unless (!strcmp (url->abspath, "/foo/bar"));
47   fail_unless (!url->query);
48
49   gst_rtsp_url_free (url);
50 }
51
52 GST_END_TEST;
53
54 GST_START_TEST (test_rtsp_url_components_1)
55 {
56   GstRTSPUrl *url = NULL;
57   GstRTSPResult res;
58   gchar **comps = NULL;
59
60   res = gst_rtsp_url_parse ("rtsp://localhost/foo/bar", &url);
61   fail_unless (res == GST_RTSP_OK);
62   fail_unless (url != NULL);
63
64   comps = gst_rtsp_url_decode_path_components (url);
65   fail_unless (comps != NULL);
66   fail_unless (g_strv_length (comps) == 3);
67   fail_unless (!strcmp (comps[0], ""));
68   fail_unless (!strcmp (comps[1], "foo"));
69   fail_unless (!strcmp (comps[2], "bar"));
70
71   g_strfreev (comps);
72   gst_rtsp_url_free (url);
73 }
74
75 GST_END_TEST;
76
77 GST_START_TEST (test_rtsp_url_components_2)
78 {
79   GstRTSPUrl *url = NULL;
80   GstRTSPResult res;
81   gchar **comps = NULL;
82
83   res = gst_rtsp_url_parse ("rtsp://localhost/foo%2Fbar/qux%20baz", &url);
84   fail_unless (res == GST_RTSP_OK);
85   fail_unless (url != NULL);
86
87   comps = gst_rtsp_url_decode_path_components (url);
88   fail_unless (comps != NULL);
89   fail_unless (g_strv_length (comps) == 3);
90   fail_unless (!strcmp (comps[0], ""));
91   fail_unless (!strcmp (comps[1], "foo/bar"));
92   fail_unless (!strcmp (comps[2], "qux baz"));
93
94   g_strfreev (comps);
95   gst_rtsp_url_free (url);
96 }
97
98 GST_END_TEST;
99
100 GST_START_TEST (test_rtsp_url_components_3)
101 {
102   GstRTSPUrl *url = NULL;
103   GstRTSPResult res;
104   gchar **comps = NULL;
105
106   res = gst_rtsp_url_parse ("rtsp://localhost/foo%00bar/qux%20baz", &url);
107   fail_unless (res == GST_RTSP_OK);
108   fail_unless (url != NULL);
109
110   comps = gst_rtsp_url_decode_path_components (url);
111   fail_unless (comps != NULL);
112   fail_unless (g_strv_length (comps) == 3);
113   fail_unless (!strcmp (comps[0], ""));
114   fail_unless (!strcmp (comps[1], "foo%00bar"));
115   fail_unless (!strcmp (comps[2], "qux baz"));
116
117   g_strfreev (comps);
118   gst_rtsp_url_free (url);
119 }
120
121 GST_END_TEST;
122
123 static Suite *
124 rtsp_suite (void)
125 {
126   Suite *s = suite_create ("rtsp support library");
127   TCase *tc_chain = tcase_create ("general");
128
129   suite_add_tcase (s, tc_chain);
130   tcase_add_test (tc_chain, test_rtsp_url_basic);
131   tcase_add_test (tc_chain, test_rtsp_url_components_1);
132   tcase_add_test (tc_chain, test_rtsp_url_components_2);
133   tcase_add_test (tc_chain, test_rtsp_url_components_3);
134
135   return s;
136 }
137
138 int
139 main (int argc, char **argv)
140 {
141   int nf;
142
143   Suite *s = rtsp_suite ();
144   SRunner *sr = srunner_create (s);
145
146   gst_check_init (&argc, &argv);
147
148   srunner_run_all (sr, CK_NORMAL);
149   nf = srunner_ntests_failed (sr);
150   srunner_free (sr);
151
152   return nf;
153 }