2 * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include <gst/check/gstcheck.h>
22 #include <rtsp-mount-points.h>
24 GST_START_TEST (test_create)
26 GstRTSPMountPoints *mounts;
27 GstRTSPUrl *url, *url2;
28 GstRTSPMediaFactory *factory;
30 mounts = gst_rtsp_mount_points_new ();
32 fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test",
33 &url) == GST_RTSP_OK);
34 fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test2",
35 &url2) == GST_RTSP_OK);
37 fail_unless (gst_rtsp_mount_points_match (mounts, url->abspath,
40 factory = gst_rtsp_media_factory_new ();
41 gst_rtsp_mount_points_add_factory (mounts, "/test", factory);
43 fail_unless (gst_rtsp_mount_points_match (mounts, url->abspath,
45 g_object_unref (factory);
46 fail_unless (gst_rtsp_mount_points_match (mounts, url2->abspath,
49 gst_rtsp_mount_points_remove_factory (mounts, "/test");
51 fail_unless (gst_rtsp_mount_points_match (mounts, url->abspath,
53 fail_unless (gst_rtsp_mount_points_match (mounts, url2->abspath,
56 gst_rtsp_url_free (url);
57 gst_rtsp_url_free (url2);
59 g_object_unref (mounts);
64 static const gchar *paths[] = {
74 GST_START_TEST (test_match)
76 GstRTSPMountPoints *mounts;
77 GstRTSPMediaFactory *f[G_N_ELEMENTS (paths)], *tmp;
80 mounts = gst_rtsp_mount_points_new ();
82 for (i = 0; i < G_N_ELEMENTS (paths); i++) {
83 f[i] = gst_rtsp_media_factory_new ();
84 gst_rtsp_mount_points_add_factory (mounts, paths[i], f[i]);
87 tmp = gst_rtsp_mount_points_match (mounts, "/test", &matched);
88 fail_unless (tmp == f[0]);
89 fail_unless (matched == 5);
91 tmp = gst_rtsp_mount_points_match (mounts, "/test/stream=1", &matched);
92 fail_unless (tmp == f[0]);
93 fail_unless (matched == 5);
95 tmp = gst_rtsp_mount_points_match (mounts, "/booz", &matched);
96 fail_unless (tmp == NULL);
97 tmp = gst_rtsp_mount_points_match (mounts, "/booz/foo", &matched);
98 fail_unless (tmp == NULL);
99 tmp = gst_rtsp_mount_points_match (mounts, "/booz/fooz", &matched);
100 fail_unless (tmp == f[1]);
101 fail_unless (matched == 10);
102 g_object_unref (tmp);
103 tmp = gst_rtsp_mount_points_match (mounts, "/booz/fooz/zoo", &matched);
104 fail_unless (tmp == f[1]);
105 fail_unless (matched == 10);
106 g_object_unref (tmp);
107 tmp = gst_rtsp_mount_points_match (mounts, "/booz/foo/zoop", &matched);
108 fail_unless (tmp == f[2]);
109 fail_unless (matched == 14);
110 g_object_unref (tmp);
111 tmp = gst_rtsp_mount_points_match (mounts, "/tark/bar", &matched);
112 fail_unless (tmp == f[3]);
113 fail_unless (matched == 9);
114 g_object_unref (tmp);
115 tmp = gst_rtsp_mount_points_match (mounts, "/tark/bar/boo", &matched);
116 fail_unless (tmp == f[3]);
117 fail_unless (matched == 9);
118 g_object_unref (tmp);
119 tmp = gst_rtsp_mount_points_match (mounts, "/tark/bar/ba", &matched);
120 fail_unless (tmp == f[3]);
121 fail_unless (matched == 9);
122 g_object_unref (tmp);
123 tmp = gst_rtsp_mount_points_match (mounts, "/tark/bar/baz", &matched);
124 fail_unless (tmp == f[4]);
125 fail_unless (matched == 13);
126 g_object_unref (tmp);
128 g_object_unref (mounts);
134 rtspmountpoints_suite (void)
136 Suite *s = suite_create ("rtspmountpoints");
137 TCase *tc = tcase_create ("general");
139 suite_add_tcase (s, tc);
140 tcase_set_timeout (tc, 20);
141 tcase_add_test (tc, test_create);
142 tcase_add_test (tc, test_match);
147 GST_CHECK_MAIN (rtspmountpoints);