Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / tests / check / pipelines / effectv.c
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., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, 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
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
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   gst_object_unref (bus);
76
77   ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
78   fail_unless (ret == GST_STATE_CHANGE_SUCCESS
79       || ret == GST_STATE_CHANGE_ASYNC);
80
81   g_main_loop_run (loop);
82
83   fail_unless (gst_element_set_state (pipeline,
84           GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
85
86   fail_unless (omud.eos == TRUE);
87
88   gst_object_unref (pipeline);
89   g_main_loop_unref (loop);
90 }
91
92 #define CREATE_TEST(element) \
93 GST_START_TEST (test_##element) \
94 { \
95   gchar *pipeline; \
96   \
97   pipeline = g_strdup_printf ("videotestsrc num-buffers=100 ! " \
98       "ffmpegcolorspace ! " \
99       " %s ! " \
100       " fakesink", #element); \
101   \
102   run_test (pipeline); \
103   g_free (pipeline); \
104 } \
105 \
106 GST_END_TEST;
107
108 CREATE_TEST (agingtv);
109 CREATE_TEST (dicetv);
110 CREATE_TEST (edgetv);
111 CREATE_TEST (optv);
112 CREATE_TEST (quarktv);
113 CREATE_TEST (radioactv);
114 CREATE_TEST (revtv);
115 CREATE_TEST (rippletv);
116 CREATE_TEST (shagadelictv);
117 CREATE_TEST (streaktv);
118 CREATE_TEST (vertigotv);
119 CREATE_TEST (warptv);
120
121 static Suite *
122 effectv_suite (void)
123 {
124   Suite *s = suite_create ("effectv");
125   TCase *tc_chain = tcase_create ("general");
126
127   suite_add_tcase (s, tc_chain);
128   tcase_set_timeout (tc_chain, 180);
129
130   tcase_add_test (tc_chain, test_agingtv);
131   tcase_add_test (tc_chain, test_dicetv);
132   tcase_add_test (tc_chain, test_edgetv);
133   tcase_add_test (tc_chain, test_optv);
134   tcase_add_test (tc_chain, test_quarktv);
135   tcase_add_test (tc_chain, test_radioactv);
136   tcase_add_test (tc_chain, test_revtv);
137   tcase_add_test (tc_chain, test_rippletv);
138   tcase_add_test (tc_chain, test_shagadelictv);
139   tcase_add_test (tc_chain, test_streaktv);
140   tcase_add_test (tc_chain, test_vertigotv);
141   tcase_add_test (tc_chain, test_warptv);
142
143   return s;
144 }
145
146 GST_CHECK_MAIN (effectv);