3 * unit test for videotestsrc
5 * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 #include <gst/check/gstcheck.h>
27 GList *buffers = NULL;
28 gboolean have_eos = FALSE;
30 /* For ease of programming we use globals to keep refs for our floating
31 * src and sink pads we create; otherwise we always have to do get_pad,
32 * get_peer, and then remove references in every test function */
36 #define CAPS_TEMPLATE_STRING \
38 "format = (fourcc) Y422, " \
39 "width = (int) [ 1, MAX ], " \
40 "height = (int) [ 1, MAX ], " \
41 "framerate = (fraction) [ 0/1, MAX ]"
43 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
46 GST_STATIC_CAPS (CAPS_TEMPLATE_STRING)
52 GstElement *videotestsrc;
54 GST_DEBUG ("setup_videotestsrc");
55 videotestsrc = gst_check_setup_element ("videotestsrc");
56 mysinkpad = gst_check_setup_sink_pad (videotestsrc, &sinktemplate, NULL);
57 gst_pad_set_active (mysinkpad, TRUE);
63 cleanup_videotestsrc (GstElement * videotestsrc)
65 GST_DEBUG ("cleanup_videotestsrc");
67 g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
68 g_list_free (buffers);
71 gst_check_teardown_sink_pad (videotestsrc);
72 gst_check_teardown_element (videotestsrc);
75 GST_START_TEST (test_all_patterns)
77 GstElement *videotestsrc;
83 videotestsrc = setup_videotestsrc ();
84 oclass = G_OBJECT_GET_CLASS (videotestsrc);
85 property = g_object_class_find_property (oclass, "pattern");
86 fail_unless (G_IS_PARAM_SPEC_ENUM (property));
87 values = G_ENUM_CLASS (g_type_class_ref (property->value_type))->values;
90 while (values[j].value_name) {
91 GST_DEBUG_OBJECT (videotestsrc, "testing pattern %s", values[j].value_name);
93 fail_unless (gst_element_set_state (videotestsrc,
94 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
95 "could not set to playing");
97 while (g_list_length (buffers) < 10);
99 gst_element_set_state (videotestsrc, GST_STATE_READY);
101 g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
102 g_list_free (buffers);
108 cleanup_videotestsrc (videotestsrc);
114 * add tests for every colorspace */
117 videotestsrc_suite (void)
119 Suite *s = suite_create ("videotestsrc");
120 TCase *tc_chain = tcase_create ("general");
122 suite_add_tcase (s, tc_chain);
123 tcase_add_test (tc_chain, test_all_patterns);
129 main (int argc, char **argv)
133 Suite *s = videotestsrc_suite ();
134 SRunner *sr = srunner_create (s);
136 gst_check_init (&argc, &argv);
138 srunner_run_all (sr, CK_NORMAL);
139 nf = srunner_ntests_failed (sr);