tests: playsink: add minimal test for playsink element
authorTim-Philipp Müller <tim@centricular.com>
Wed, 30 Sep 2015 16:55:22 +0000 (17:55 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 14 May 2016 15:02:16 +0000 (16:02 +0100)
Attempt to reproduce leak.

https://bugzilla.gnome.org/show_bug.cgi?id=755867

tests/check/Makefile.am
tests/check/elements/playsink.c [new file with mode: 0644]

index ed1d026..c81c664 100644 (file)
@@ -75,7 +75,8 @@ endif
 
 if USE_PLUGIN_PLAYBACK
 check_playback = elements/decodebin elements/playbin \
-    elements/playbin-complex elements/streamsynchronizer
+    elements/playbin-complex elements/streamsynchronizer \
+    elements/playsink
 else
 check_playback =
 endif
diff --git a/tests/check/elements/playsink.c b/tests/check/elements/playsink.c
new file mode 100644 (file)
index 0000000..c0e629c
--- /dev/null
@@ -0,0 +1,88 @@
+/* GStreamer unit tests for playsink
+ * Copyright (C) 2015 Tim-Philipp Müller <tim centricular 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/check/gstcheck.h>
+
+
+GST_START_TEST (test_volume_in_sink)
+{
+  GstElement *pipe, *audiosink, *playsink, *fakesink, *volume, *src;
+  GstPad *sinkpad;
+  GstMessage *msg;
+
+  pipe = gst_pipeline_new (NULL);
+  playsink = gst_element_factory_make ("playsink", NULL);
+
+  audiosink = gst_bin_new ("audiosink");
+  volume = gst_element_factory_make ("volume", NULL);
+  fakesink = gst_element_factory_make ("fakesink", NULL);
+  gst_bin_add_many (GST_BIN (audiosink), volume, fakesink, NULL);
+  gst_element_link_many (volume, fakesink, NULL);
+  sinkpad = gst_element_get_static_pad (volume, "sink");
+  gst_element_add_pad (audiosink, gst_ghost_pad_new ("sink", sinkpad));
+  gst_object_unref (sinkpad);
+
+  g_object_set (playsink, "audio-sink", audiosink, NULL);
+
+  src = gst_element_factory_make ("audiotestsrc", NULL);
+  g_object_set (src, "num-buffers", 5, NULL);
+
+
+  gst_bin_add (GST_BIN (pipe), src);
+  gst_bin_add (GST_BIN (pipe), playsink);
+
+  if (!gst_element_link (src, playsink))
+    g_error ("oops");
+
+  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PLAYING),
+      GST_STATE_CHANGE_ASYNC);
+
+  /* wait for eos */
+  msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe), GST_CLOCK_TIME_NONE,
+      GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
+  fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
+  gst_message_unref (msg);
+
+  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_NULL),
+      GST_STATE_CHANGE_SUCCESS);
+
+  gst_object_unref (pipe);
+}
+
+GST_END_TEST;
+
+
+static Suite *
+playsink_suite (void)
+{
+  Suite *s = suite_create ("playsink");
+  TCase *tc_chain = tcase_create ("general");
+
+  suite_add_tcase (s, tc_chain);
+
+  tcase_add_test (tc_chain, test_volume_in_sink);
+
+  return s;
+}
+
+GST_CHECK_MAIN (playsink);