3 * unit test for state changes on all elements
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.
29 #include <gst/check/gstcheck.h>
31 GST_START_TEST (test_state_changes)
36 gchar **ignorelist = NULL;
37 const gchar *STATE_IGNORE_ELEMENTS = NULL;
39 GST_DEBUG ("testing elements from source %s", PACKAGE);
40 STATE_IGNORE_ELEMENTS = g_getenv ("STATE_IGNORE_ELEMENTS");
41 if (STATE_IGNORE_ELEMENTS) {
42 GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS);
43 ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0);
46 plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
48 for (p = plugins; p; p = p->next) {
49 GstPlugin *plugin = p->data;
51 if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
55 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
56 gst_plugin_get_name (plugin));
58 for (f = features; f; f = f->next) {
59 GstPluginFeature *feature = f->data;
60 const gchar *name = gst_plugin_feature_get_name (feature);
61 gboolean ignore = FALSE;
63 if (!GST_IS_ELEMENT_FACTORY (feature))
69 for (s = ignorelist; s && *s; ++s) {
70 if (g_str_has_prefix (name, *s)) {
71 GST_DEBUG ("ignoring element %s", name);
79 GST_DEBUG ("testing element %s", name);
80 element = gst_element_factory_make (name, name);
81 fail_if (element == NULL, "Could not make element from factory %s", name);
83 if (GST_IS_PIPELINE (element)) {
84 GST_DEBUG ("element %s is a pipeline", name);
87 gst_element_set_state (element, GST_STATE_READY);
88 gst_element_set_state (element, GST_STATE_PAUSED);
89 gst_element_set_state (element, GST_STATE_PLAYING);
90 gst_element_set_state (element, GST_STATE_PAUSED);
91 gst_element_set_state (element, GST_STATE_READY);
92 gst_element_set_state (element, GST_STATE_NULL);
93 gst_element_set_state (element, GST_STATE_PAUSED);
94 gst_element_set_state (element, GST_STATE_READY);
95 gst_element_set_state (element, GST_STATE_PLAYING);
96 gst_element_set_state (element, GST_STATE_PAUSED);
97 gst_element_set_state (element, GST_STATE_NULL);
98 gst_object_unref (GST_OBJECT (element));
100 gst_plugin_feature_list_free (features);
102 gst_plugin_list_free (plugins);
103 g_strfreev (ignorelist);
111 Suite *s = suite_create ("states");
112 TCase *tc_chain = tcase_create ("general");
114 suite_add_tcase (s, tc_chain);
115 tcase_add_test (tc_chain, test_state_changes);
120 GST_CHECK_MAIN (states);