1 /* GStreamer unit test for capsfilter
2 * Copyright (C) <2008> Tim-Philipp Müller <tim centricular net>
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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <gst/check/gstcheck.h>
22 #define CAPS_TEMPLATE_STRING \
24 "channels = (int) [ 1, 2], " \
25 "rate = (int) [ 1, MAX ]"
27 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
30 GST_STATIC_CAPS (CAPS_TEMPLATE_STRING)
33 GST_START_TEST (test_unfixed_downstream_caps)
35 GstElement *pipe, *src, *filter;
40 pipe = gst_check_setup_element ("pipeline");
42 src = gst_check_setup_element ("fakesrc");
43 g_object_set (src, "sizetype", 2, "sizemax", 1024, "num-buffers", 1, NULL);
45 filter = gst_check_setup_element ("capsfilter");
46 filter_caps = gst_caps_from_string ("audio/x-raw-int, rate=(int)44100");
47 fail_unless (filter_caps != NULL);
48 g_object_set (filter, "caps", filter_caps, NULL);
50 gst_bin_add_many (GST_BIN (pipe), src, filter, NULL);
51 fail_unless (gst_element_link (src, filter));
53 mysinkpad = gst_check_setup_sink_pad (filter, &sinktemplate, NULL);
54 gst_pad_set_active (mysinkpad, TRUE);
56 fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PLAYING),
57 GST_STATE_CHANGE_SUCCESS);
59 /* wait for error on bus */
60 msg = gst_bus_poll (GST_ELEMENT_BUS (pipe),
61 GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
63 fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ERROR,
64 "Expected ERROR message, got EOS message");
65 gst_message_unref (msg);
67 /* We don't expect any output buffers unless the check fails */
68 fail_unless (buffers == NULL);
71 GST_DEBUG ("cleanup");
73 gst_pad_set_active (mysinkpad, FALSE);
74 gst_check_teardown_sink_pad (filter);
75 gst_check_teardown_element (pipe);
76 gst_caps_unref (filter_caps);
82 capsfilter_suite (void)
84 Suite *s = suite_create ("capsfilter");
85 TCase *tc_chain = tcase_create ("general");
87 suite_add_tcase (s, tc_chain);
88 tcase_add_test (tc_chain, test_unfixed_downstream_caps);
93 GST_CHECK_MAIN (capsfilter)