[farsight2/master] Add first unit tests for the transmitters

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:19:30 PST 2008


---
 .gitignore                        |    5 ++-
 tests/check/Makefile.am           |   21 +++++++++-
 tests/check/base/fstransmitter.c  |   61 ++++++++++++++++++++++++++++++
 tests/check/transmitter/generic.c |   74 +++++++++++++++++++++++++++++++++++++
 tests/check/transmitter/generic.h |   32 ++++++++++++++++
 tests/check/transmitter/rawudp.c  |   74 +++++++++++++++++++++++++++++++++++++
 6 files changed, 264 insertions(+), 3 deletions(-)
 create mode 100644 tests/check/base/fstransmitter.c
 create mode 100644 tests/check/transmitter/generic.c
 create mode 100644 tests/check/transmitter/generic.h
 create mode 100644 tests/check/transmitter/rawudp.c

diff --git a/.gitignore b/.gitignore
index fa63017..77aeadb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,9 +30,12 @@ docs/libs/html
 docs/libs/tmpl
 docs/libs/xml
 
+tests/check/test-registry.xml
 tests/check/base/.dirstamp
 tests/check/base/fscodec
-tests/check/test-registry.xml
+tests/check/base/fstransmitter
+tests/check/transmitter/.dirstamp
+tests/check/transmitter/rawudp
 
 aclocal.m4
 autom4te.cache
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 3355b4d..dc26237 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -10,7 +10,8 @@ TESTS_ENVIRONMENT = \
 	STATE_IGNORE_ELEMENTS="$(STATE_IGNORE_ELEMENTS)"	\
 	$(REGISTRY_ENVIRONMENT)					\
 	GST_PLUGIN_SYSTEM_PATH=					\
-	GST_PLUGIN_PATH=$(top_builddir)/gst
+	GST_PLUGIN_PATH=$(top_builddir)/gst:${GST_PLUGIN_PATH}	\
+	FS_PLUGIN_PATH=$(top_builddir)/transmitters/rawudp/.libs
 
 
 # ths core dumps of some machines have PIDs appended
@@ -31,7 +32,9 @@ SUPPRESSIONS = $(top_srcdir)/common/gst.supp
 # From here.. Its a list of our tests and their sub stuff
 #
 check_PROGRAMS = \
-	base/fscodec
+	base/fscodec \
+	base/fstransmitter \
+	transmitter/rawudp
 
 
 AM_CFLAGS = $(GST_CFLAGS) $(GST_CHECK_CFLAGS)
@@ -40,3 +43,17 @@ LDADD = $(GST_LIBS) $(GST_CHECK_LIBS)
 base_fscodec_LDADD = $(LDADD) \
 	$(top_builddir)/gst-libs/gst/farsight/libgstfarsight-0.10.la
 base_fscodec_CFLAGS = $(FS2_INTERNAL_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+
+base_fstransmitter_LDADD = $(LDADD) \
+	$(top_builddir)/gst-libs/gst/farsight/libgstfarsight-0.10.la
+base_fstransmitter_CFLAGS = $(FS2_INTERNAL_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+
+transmitter_rawudp_LDADD = $(LDADD) \
+	$(top_builddir)/gst-libs/gst/farsight/libgstfarsight-0.10.la
+transmitter_rawudp_CFLAGS = $(FS2_INTERNAL_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+transmitter_rawudp_SOURCES = \
+	transmitter/generic.c \
+	transmitter/generic.h \
+	transmitter/rawudp.c
+
+
diff --git a/tests/check/base/fstransmitter.c b/tests/check/base/fstransmitter.c
new file mode 100644
index 0000000..db1a145
--- /dev/null
+++ b/tests/check/base/fstransmitter.c
@@ -0,0 +1,61 @@
+/* Farsigh2 unit tests for FsTransmitter
+ *
+ * Copyright (C) 2007 Collabora, Nokia
+ * @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/check/gstcheck.h>
+#include <gst/farsight/fs-transmitter.h>
+#include <gst/farsight/fs-conference-iface.h>
+
+
+GST_START_TEST (test_fstransmitter_new_fail)
+{
+  GError *error = NULL;
+  FsTransmitter *transmitter = NULL;
+
+  transmitter = fs_transmitter_new ("invalidname", &error);
+
+  fail_if (transmitter);
+
+  fail_unless (error);
+
+  fail_unless (error->domain == FS_ERROR);
+}
+GST_END_TEST;
+
+
+static Suite *
+fstransmitter_suite (void)
+{
+  Suite *s = suite_create ("fstransmitter");
+  TCase *tc_chain = tcase_create ("fstransmitter");
+
+  suite_add_tcase (s, tc_chain);
+
+  tcase_add_test (tc_chain, test_fstransmitter_new_fail);
+
+  return s;
+}
+
+
+GST_CHECK_MAIN (fstransmitter);
diff --git a/tests/check/transmitter/generic.c b/tests/check/transmitter/generic.c
new file mode 100644
index 0000000..abfa6b1
--- /dev/null
+++ b/tests/check/transmitter/generic.c
@@ -0,0 +1,74 @@
+/* Farsigh2 generic unit tests for transmitters
+ *
+ * Copyright (C) 2007 Collabora, Nokia
+ * @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "generic.h"
+
+#include <gst/check/gstcheck.h>
+#include <gst/farsight/fs-transmitter.h>
+#include <gst/farsight/fs-stream-transmitter.h>
+
+
+static void
+_transmitter_error (FsTransmitter *transmitter, gint errorno, gchar *error_msg,
+  gchar *debug_msg, gpointer user_data)
+{
+  fail ("Transmitter(%x) error(%d) msg:%s debug:%s", transmitter, errorno,
+    error_msg, debug_msg);
+}
+
+GstElement *
+setup_pipeline (FsTransmitter *trans)
+{
+  GstElement *pipeline;
+  GstElement *fakesrc;
+  GstElement *fakesink;
+  GstElement *trans_sink, *trans_src;
+
+  fail_unless (g_signal_connect (trans, "error",
+      G_CALLBACK (_transmitter_error), NULL), "Could not connect signal");
+
+  pipeline = gst_pipeline_new ("pipeline");
+  fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
+  fakesink = gst_element_factory_make ("fakesink", "fakesink");
+
+  g_object_get (trans, "gst-sink", &trans_sink, "gst-src", &trans_src, NULL);
+
+  fail_if (trans_sink == NULL, "No transmitter sink");
+  fail_if (trans_src == NULL, "No transmitter src");
+
+  gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink,
+    trans_sink, trans_src, NULL);
+
+  fail_unless (gst_element_link (fakesrc, trans_sink),
+    "Coult not link fakesrc and transmitter sink");
+
+  fail_unless (gst_element_link (trans_src, fakesink),
+    "Coult not link transmitter src and fakesink");
+
+  g_object_unref (trans_src);
+  g_object_unref (trans_sink);
+
+  return pipeline;
+}
diff --git a/tests/check/transmitter/generic.h b/tests/check/transmitter/generic.h
new file mode 100644
index 0000000..e3d5bd7
--- /dev/null
+++ b/tests/check/transmitter/generic.h
@@ -0,0 +1,32 @@
+/* Farsigh2 generic unit tests for transmitters
+ *
+ * Copyright (C) 2007 Collabora, Nokia
+ * @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#include <gst/gst.h>
+#include <gst/farsight/fs-transmitter.h>
+
+#ifndef __GENERIC_H__
+#define  __GENERIC_H__
+
+GstElement * setup_pipeline (FsTransmitter *trans);
+
+
+#endif /* __GENERIC_H__ */
diff --git a/tests/check/transmitter/rawudp.c b/tests/check/transmitter/rawudp.c
new file mode 100644
index 0000000..bc76a13
--- /dev/null
+++ b/tests/check/transmitter/rawudp.c
@@ -0,0 +1,74 @@
+/* Farsigh2 unit tests for FsRawUdpTransmitter
+ *
+ * Copyright (C) 2007 Collabora, Nokia
+ * @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/check/gstcheck.h>
+#include <gst/farsight/fs-transmitter.h>
+
+#include "generic.h"
+
+
+GST_START_TEST (test_rawudptransmitter_new)
+{
+  GError *error = NULL;
+  FsTransmitter *trans;
+  GstElement *pipeline;
+  GstElement *trans_sink, *trans_src;
+
+  trans = fs_transmitter_new ("rawudp", &error);
+
+  if (error) {
+    fail("Error creating transmitter: %s", error->message);
+  }
+
+  fail_if (trans == NULL, "No transmitter create, yet error is still NULL");
+
+  pipeline = setup_pipeline (trans);
+
+  g_object_get (trans, "gst-sink", &trans_sink, "gst-src", &trans_src, NULL);
+
+  g_object_unref (trans);
+
+  gst_object_unref (pipeline);
+
+}
+GST_END_TEST;
+
+
+
+static Suite *
+rawudptransmitter_suite (void)
+{
+  Suite *s = suite_create ("rawudptransmitter");
+  TCase *tc_chain = tcase_create ("rawudptransmitter");
+
+  suite_add_tcase (s, tc_chain);
+
+  tcase_add_test (tc_chain, test_rawudptransmitter_new);
+
+  return s;
+}
+
+
+GST_CHECK_MAIN (rawudptransmitter);
-- 
1.5.6.5




More information about the farsight-commits mailing list