1 /* GStreamer unit test for libvisual plugin
3 * Copyright (C) 2007 Tim-Philipp Müller <tim at 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.
21 #include <gst/check/gstcheck.h>
24 filter_func (GstPluginFeature * feature, gpointer user_data)
26 return (g_str_has_prefix (GST_PLUGIN_FEATURE_NAME (feature), "libvisual_"));
30 test_shutdown_for_factory (const gchar * factory_name)
32 GstElement *pipeline, *src, *q, *ac, *vis, *cf, *q2, *sink;
36 pipeline = gst_pipeline_new (NULL);
38 src = gst_check_setup_element ("audiotestsrc");
39 q = gst_check_setup_element ("queue");
40 ac = gst_check_setup_element ("audioconvert");
42 GST_INFO ("Using %s", factory_name);
43 vis = gst_check_setup_element (factory_name);
45 cf = gst_check_setup_element ("capsfilter");
46 caps = gst_caps_new_simple ("video/x-raw-rgb", "width", G_TYPE_INT, 320,
47 "height", G_TYPE_INT, 240, "framerate", GST_TYPE_FRACTION, 15, 1, NULL);
48 g_object_set (cf, "caps", caps, NULL);
49 gst_caps_unref (caps);
51 q2 = gst_check_setup_element ("queue");
52 gst_object_set_name (GST_OBJECT (q2), "queue2");
53 sink = gst_check_setup_element ("fakesink");
55 /* don't want to sync against the clock, the more throughput the better */
56 g_object_set (src, "is-live", FALSE, NULL);
57 g_object_set (sink, "sync", FALSE, NULL);
59 gst_bin_add_many (GST_BIN (pipeline), src, q, ac, vis, cf, q2, sink, NULL);
60 fail_if (!gst_element_link_many (src, q, ac, vis, cf, q2, sink, NULL));
62 /* now, wait until pipeline is running and then shut it down again; repeat;
63 * this makes sure we can shut down cleanly while stuff is going on in the
65 for (i = 0; i < 50; ++i) {
66 gst_element_set_state (pipeline, GST_STATE_PAUSED);
67 gst_element_get_state (pipeline, NULL, NULL, -1);
68 gst_element_set_state (pipeline, GST_STATE_PLAYING);
70 gst_element_set_state (pipeline, GST_STATE_NULL);
73 gst_object_unref (pipeline);
76 GST_START_TEST (test_shutdown)
78 const gchar *factory_to_test;
80 factory_to_test = g_getenv ("LIBVISUAL_UNIT_TEST_FACTORY");
82 if (factory_to_test == NULL) {
85 list = gst_default_registry_feature_filter (filter_func, FALSE, NULL);
87 g_print ("No libvisual plugins installed.\n");
90 for (l = list; l != NULL; l = l->next) {
91 test_shutdown_for_factory (GST_PLUGIN_FEATURE_NAME (l->data));
93 gst_plugin_feature_list_free (list);
95 test_shutdown_for_factory (factory_to_test);
102 libvisual_suite (void)
104 Suite *s = suite_create ("libvisual");
105 TCase *tc_chain = tcase_create ("general");
107 suite_add_tcase (s, tc_chain);
109 /* set one manually, since we're currently built as uninst program with
110 * the default timeout of 3 seconds, which is way too short */
111 tcase_set_timeout (tc_chain, 30);
113 tcase_add_test (tc_chain, test_shutdown);
118 GST_CHECK_MAIN (libvisual);