tests/check/generic/states.c: Copy the current generic/states example from -base and adapt so we can use the exact sa...

Original commit message from CVS:
* tests/check/generic/states.c: (GST_START_TEST), (states_suite):
Copy the current generic/states example from -base and adapt so
we can use the exact same code everywhere.
Check a STATES_IGNORE_ELEMENTS env var which can be used
to ignore certain element factories for this test, which is
what is being done in -base
* tests/check/Makefile.am:
Mention this environment variable.
This commit is contained in:
Thomas Vander Stichele 2007-02-28 12:40:45 +00:00
parent 7553c996a4
commit 155fa0066d
3 changed files with 99 additions and 46 deletions

View file

@ -1,3 +1,14 @@
2007-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
* tests/check/generic/states.c: (GST_START_TEST), (states_suite):
Copy the current generic/states example from -base and adapt so
we can use the exact same code everywhere.
Check a STATES_IGNORE_ELEMENTS env var which can be used
to ignore certain element factories for this test, which is
what is being done in -base
* tests/check/Makefile.am:
Mention this environment variable.
2007-02-27 Wim Taymans <wim@fluendo.com>
* docs/gst/gstreamer-sections.txt:

View file

@ -99,6 +99,9 @@ noinst_PROGRAMS = \
libs/collectpads \
elements/queue
# elements to ignore for the state tests
# STATE_IGNORE_ELEMENTS =
#
TESTS = $(check_PROGRAMS)
noinst_HEADERS = \

View file

@ -20,6 +20,10 @@
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <unistd.h>
#include <gst/check/gstcheck.h>
@ -28,21 +32,61 @@ GST_START_TEST (test_state_changes)
{
GstElement *element;
GList *features, *f;
GList *plugins, *p;
gchar **ignorelist = NULL;
const gchar *STATE_IGNORE_ELEMENTS = NULL;
features = gst_registry_get_feature_list (gst_registry_get_default (),
GST_TYPE_ELEMENT_FACTORY);
GST_DEBUG ("testing elements from source %s", PACKAGE);
STATE_IGNORE_ELEMENTS = g_getenv ("STATE_IGNORE_ELEMENTS");
if (STATE_IGNORE_ELEMENTS) {
GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS);
ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0);
}
plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
for (p = plugins; p; p = p->next) {
GstPlugin *plugin = p->data;
if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
continue;
features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
gst_plugin_get_name (plugin));
for (f = features; f; f = f->next) {
GstPluginFeature *feature = f->data;
const gchar *name = gst_plugin_feature_get_name (feature);
gboolean ignore = FALSE;
if (!GST_IS_ELEMENT_FACTORY (feature))
continue;
if (ignorelist) {
gchar **s;
for (s = ignorelist; s && *s; ++s) {
if (g_str_has_prefix (name, *s)) {
GST_DEBUG ("ignoring element %s", name);
ignore = TRUE;
}
}
if (ignore)
continue;
}
GST_DEBUG ("testing element %s", name);
element = gst_element_factory_make (name, name);
fail_if (element == NULL, "Could not make element from factory %s", name);
if (GST_IS_PIPELINE (element)) {
GST_DEBUG ("element %s is a pipeline", name);
}
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_NULL);
@ -51,11 +95,10 @@ GST_START_TEST (test_state_changes)
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (element));
}
gst_plugin_feature_list_free (features);
gst_task_cleanup_all ();
}
g_strfreev (ignorelist);
}
GST_END_TEST;
@ -66,10 +109,6 @@ states_suite (void)
Suite *s = suite_create ("states");
TCase *tc_chain = tcase_create ("general");
/* Use a long timeout, as we test all elements and take
* at least 0.2 seconds each */
tcase_set_timeout (tc_chain, 120);
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_state_changes);