1 /* GStreamer unit test for the autodetect elements
3 * Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include <gst/check/gstcheck.h>
27 GST_START_TEST (test_autovideosink_ghostpad_error_case)
29 GstStateChangeReturn state_ret;
30 GstElement *pipeline, *src, *filter, *sink;
33 /* check that there's a usable video sink (think of build bot case) */
34 sink = gst_element_factory_make ("autovideosink", NULL);
35 state_ret = gst_element_set_state (sink, GST_STATE_READY);
37 /* need to set state back to NULL, or our test won't work since we
38 * already have detected the real caps in ready and then linking fails */
39 gst_element_set_state (sink, GST_STATE_NULL);
41 if (state_ret != GST_STATE_CHANGE_SUCCESS) {
42 GST_WARNING ("No usable video sink, skipping test");
43 gst_object_unref (sink);
47 pipeline = gst_pipeline_new ("pipeline");
48 src = gst_element_factory_make ("fakesrc", NULL);
49 filter = gst_element_factory_make ("capsfilter", NULL);
51 caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
52 GST_MAKE_FOURCC ('A', 'C', 'D', 'C'), NULL);
54 g_object_set (filter, "caps", caps, NULL);
55 gst_caps_unref (caps);
57 gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL);
59 fail_unless (gst_element_link (src, filter), "Failed to link src to filter");
60 fail_unless (gst_element_link (filter, sink),
61 "Failed to link filter to sink");
63 /* this should fail, there's no such format */
64 state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
65 fail_unless (state_ret == GST_STATE_CHANGE_FAILURE,
66 "pipeline _set_state() to PAUSED succeeded but should have failed");
68 /* so, we hit an error and try to shut down the pipeline; this shouldn't
69 * deadlock or block anywhere when autovideosink resets the ghostpad
71 state_ret = gst_element_set_state (pipeline, GST_STATE_NULL);
72 fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS,
73 "State change on pipeline failed");
76 gst_object_unref (pipeline);
81 /* disable this for now, too many valgrind suppressions needed for libasound */
83 GST_START_TEST (test_autoaudiosink_ghostpad_error_case)
85 GstStateChangeReturn state_ret;
86 GstElement *pipeline, *src, *filter, *sink;
89 /* check that there's a usable audio sink (think of build bot case) */
90 sink = gst_element_factory_make ("autoaudiosink", NULL);
91 state_ret = gst_element_set_state (sink, GST_STATE_READY);
93 /* need to set state back to NULL, or our test won't work since we
94 * already have detected the real caps in ready and then linking fails */
95 gst_element_set_state (sink, GST_STATE_NULL);
97 if (state_ret != GST_STATE_CHANGE_SUCCESS) {
98 GST_WARNING ("No usable audio sink, skipping test");
99 gst_object_unref (sink);
103 pipeline = gst_pipeline_new ("pipeline");
104 src = gst_element_factory_make ("fakesrc", NULL);
105 filter = gst_element_factory_make ("capsfilter", NULL);
107 caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 42, NULL);
109 g_object_set (filter, "caps", caps, NULL);
110 gst_caps_unref (caps);
112 gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL);
114 fail_unless (gst_element_link (src, filter));
115 fail_unless (gst_element_link (filter, sink));
117 /* this should fail, there's no such width (hopefully) */
118 state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
119 fail_unless (state_ret == GST_STATE_CHANGE_FAILURE,
120 "pipeline _set_state() to PAUSED succeeded but should have failed");
122 /* so, we hit an error and try to shut down the pipeline; this shouldn't
123 * deadlock or block anywhere when autoaudiosink resets the ghostpad
125 state_ret = gst_element_set_state (pipeline, GST_STATE_NULL);
126 fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS);
129 gst_object_unref (pipeline);
136 autodetect_suite (void)
138 guint maj, min, mic, nano;
140 Suite *s = suite_create ("autodetect");
141 TCase *tc_chain = tcase_create ("general");
143 suite_add_tcase (s, tc_chain);
145 gst_version (&maj, &min, &mic, &nano);
147 /* requires fixes from 0.10.10.1, but don't want to add a hard dependency
148 * in configure.ac just for this yet */
149 if (maj > 0 || min > 10 || mic > 10 || (mic == 10 && nano > 0)) {
150 tcase_add_test (tc_chain, test_autovideosink_ghostpad_error_case);
151 /* tcase_add_test (tc_chain, test_autoaudiosink_ghostpad_error_case); */
157 GST_CHECK_MAIN (autodetect);