2 * unit test for index setting on all elements
3 * Copyright (C) 2005 Thomas Vander Stichele <thomas at apestaart dot org>
4 * Copyright (C) 2011 Tim-Philipp Müller <tim centricular net>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #include <gst/check/gstcheck.h>
28 static GList *elements = NULL;
35 gchar **ignorelist = NULL;
36 const gchar *INDEX_IGNORE_ELEMENTS = NULL;
38 GST_DEBUG ("getting elements for package %s", PACKAGE);
39 INDEX_IGNORE_ELEMENTS = g_getenv ("GST_INDEX_IGNORE_ELEMENTS");
40 if (!g_getenv ("GST_NO_INDEX_IGNORE_ELEMENTS") && INDEX_IGNORE_ELEMENTS) {
41 GST_DEBUG ("Will ignore element factories: '%s'", INDEX_IGNORE_ELEMENTS);
42 ignorelist = g_strsplit (INDEX_IGNORE_ELEMENTS, " ", 0);
45 plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
47 for (p = plugins; p; p = p->next) {
48 GstPlugin *plugin = p->data;
50 if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
54 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
55 gst_plugin_get_name (plugin));
57 for (f = features; f; f = f->next) {
58 GstPluginFeature *feature = f->data;
59 const gchar *name = gst_plugin_feature_get_name (feature);
60 gboolean ignore = FALSE;
62 if (!GST_IS_ELEMENT_FACTORY (feature))
68 for (s = ignorelist; s && *s; ++s) {
69 if (g_str_has_prefix (name, *s)) {
70 GST_DEBUG ("ignoring element %s", name);
78 GST_DEBUG ("adding element %s", name);
79 elements = g_list_prepend (elements, (gpointer) g_strdup (name));
81 gst_plugin_feature_list_free (features);
83 gst_plugin_list_free (plugins);
84 g_strfreev (ignorelist);
92 for (e = elements; e; e = e->next) {
95 g_list_free (elements);
99 GST_START_TEST (test_set_index)
105 idx = gst_index_factory_make ("memindex");
109 gst_object_ref_sink (idx);
111 for (e = elements; e; e = e->next) {
112 const gchar *name = e->data;
114 GST_INFO ("testing element %s", name);
115 element = gst_element_factory_make (name, name);
116 fail_if (element == NULL, "Could not make element from factory %s", name);
118 gst_element_set_index (element, idx);
119 gst_object_unref (element);
122 gst_object_unref (idx);
130 Suite *s = suite_create ("index");
131 TCase *tc_chain = tcase_create ("general");
133 suite_add_tcase (s, tc_chain);
134 tcase_add_checked_fixture (tc_chain, setup, teardown);
135 tcase_add_test (tc_chain, test_set_index);
140 GST_CHECK_MAIN (index);