1 /* GStreamer
2 *
3 * Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
4 *
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.
9 *
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.
14 *
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., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #include <gst/check/gstcheck.h>
22 #include <string.h>
23
24 typedef struct
25 {
26 GMainLoop *loop;
27 gboolean eos;
28 } OnMessageUserData;
29
30 static void
on_message_cb(GstBus * bus,GstMessage * message,gpointer user_data)31 on_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
32 {
33 OnMessageUserData *d = user_data;
34
35 switch (GST_MESSAGE_TYPE (message)) {
36 case GST_MESSAGE_ERROR:
37 case GST_MESSAGE_WARNING:
38 g_assert_not_reached ();
39 break;
40 case GST_MESSAGE_EOS:
41 g_main_loop_quit (d->loop);
42 d->eos = TRUE;
43 break;
44 default:
45 break;
46 }
47 }
48
49 static void
run_test(const gchar * pipeline_string)50 run_test (const gchar * pipeline_string)
51 {
52 GstElement *pipeline;
53 GstBus *bus;
54 GMainLoop *loop;
55 OnMessageUserData omud = { NULL, };
56 GstStateChangeReturn ret;
57
58 GST_DEBUG ("Testing pipeline '%s'", pipeline_string);
59
60 pipeline = gst_parse_launch (pipeline_string, NULL);
61 fail_unless (pipeline != NULL);
62 g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
63
64 loop = g_main_loop_new (NULL, FALSE);
65
66 bus = gst_element_get_bus (pipeline);
67 fail_unless (bus != NULL);
68 gst_bus_add_signal_watch (bus);
69
70 omud.loop = loop;
71 omud.eos = FALSE;
72
73 g_signal_connect (bus, "message", (GCallback) on_message_cb, &omud);
74
75
76 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
77 fail_unless (ret == GST_STATE_CHANGE_SUCCESS
78 || ret == GST_STATE_CHANGE_ASYNC);
79
80 g_main_loop_run (loop);
81
82 fail_unless (gst_element_set_state (pipeline,
83 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
84
85 fail_unless (omud.eos == TRUE);
86
87 gst_bus_remove_signal_watch (bus);
88 gst_object_unref (bus);
89 gst_object_unref (pipeline);
90 g_main_loop_unref (loop);
91 }
92
93 #define CREATE_TEST(element) \
94 GST_START_TEST (test_##element) \
95 { \
96 gchar *pipeline; \
97 \
98 pipeline = g_strdup_printf ("videotestsrc num-buffers=100 ! " \
99 "videoconvert ! " \
100 " %s ! " \
101 " fakesink", #element); \
102 \
103 run_test (pipeline); \
104 g_free (pipeline); \
105 } \
106 \
107 GST_END_TEST;
108
109 CREATE_TEST (agingtv);
110 CREATE_TEST (dicetv);
111 CREATE_TEST (edgetv);
112 CREATE_TEST (optv);
113 CREATE_TEST (quarktv);
114 CREATE_TEST (radioactv);
115 CREATE_TEST (revtv);
116 CREATE_TEST (rippletv);
117 CREATE_TEST (shagadelictv);
118 CREATE_TEST (streaktv);
119 CREATE_TEST (vertigotv);
120 CREATE_TEST (warptv);
121
122 static Suite *
effectv_suite(void)123 effectv_suite (void)
124 {
125 Suite *s = suite_create ("effectv");
126 TCase *tc_chain = tcase_create ("general");
127
128 suite_add_tcase (s, tc_chain);
129 tcase_set_timeout (tc_chain, 180);
130
131 tcase_add_test (tc_chain, test_agingtv);
132 tcase_add_test (tc_chain, test_dicetv);
133 tcase_add_test (tc_chain, test_edgetv);
134 tcase_add_test (tc_chain, test_optv);
135 tcase_add_test (tc_chain, test_quarktv);
136 tcase_add_test (tc_chain, test_radioactv);
137 tcase_add_test (tc_chain, test_revtv);
138 tcase_add_test (tc_chain, test_rippletv);
139 tcase_add_test (tc_chain, test_shagadelictv);
140 tcase_add_test (tc_chain, test_streaktv);
141 tcase_add_test (tc_chain, test_vertigotv);
142 tcase_add_test (tc_chain, test_warptv);
143
144 return s;
145 }
146
147 GST_CHECK_MAIN (effectv);
148