tests: add test for mountpoints
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 28 Nov 2012 10:07:57 +0000 (11:07 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 28 Nov 2012 10:07:57 +0000 (11:07 +0100)
tests/check/Makefile.am
tests/check/gst/mountpoints.c [new file with mode: 0644]

index 8c23c8c..1a1a259 100644 (file)
@@ -28,6 +28,7 @@ TESTS = $(check_PROGRAMS)
 check_PROGRAMS = \
        gst/rtspserver \
        gst/client \
+       gst/mountpoints \
        gst/addresspool
 
 # these tests don't even pass
diff --git a/tests/check/gst/mountpoints.c b/tests/check/gst/mountpoints.c
new file mode 100644 (file)
index 0000000..209975d
--- /dev/null
@@ -0,0 +1,72 @@
+/* GStreamer
+ * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gst/check/gstcheck.h>
+
+#include <rtsp-mount-points.h>
+
+GST_START_TEST (test_create)
+{
+  GstRTSPMountPoints *mounts;
+  GstRTSPUrl *url, *url2;
+  GstRTSPMediaFactory *factory;
+
+  mounts = gst_rtsp_mount_points_new ();
+
+  fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test",
+          &url) == GST_RTSP_OK);
+  fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test2",
+          &url2) == GST_RTSP_OK);
+
+  fail_unless (gst_rtsp_mount_points_find_factory (mounts, url) == NULL);
+
+  factory = gst_rtsp_media_factory_new ();
+  gst_rtsp_mount_points_add_factory (mounts, "/test", factory);
+
+  fail_unless (gst_rtsp_mount_points_find_factory (mounts, url) == factory);
+  g_object_unref (factory);
+  fail_unless (gst_rtsp_mount_points_find_factory (mounts, url2) == NULL);
+
+  gst_rtsp_mount_points_remove_factory (mounts, "/test");
+
+  fail_unless (gst_rtsp_mount_points_find_factory (mounts, url) == NULL);
+  fail_unless (gst_rtsp_mount_points_find_factory (mounts, url2) == NULL);
+
+  gst_rtsp_url_free (url);
+  gst_rtsp_url_free (url2);
+
+  g_object_unref (mounts);
+}
+
+GST_END_TEST;
+
+static Suite *
+rtspmountpoints_suite (void)
+{
+  Suite *s = suite_create ("rtspmountpoints");
+  TCase *tc = tcase_create ("general");
+
+  suite_add_tcase (s, tc);
+  tcase_set_timeout (tc, 20);
+  tcase_add_test (tc, test_create);
+
+  return s;
+}
+
+GST_CHECK_MAIN (rtspmountpoints);