summaryrefslogtreecommitdiff
path: root/testsuite/states
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2005-11-30 16:08:31 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2005-11-30 16:08:31 +0000
commit7533cf8523a5f1188fe25ac8a9dbc763b39ccfe6 (patch)
treedf99a371f2c1bbbfe42ab2f7953f6d23870a5cc5 /testsuite/states
parentb0f15be3c19cee7caa3f9fd6253c5bf0118b5a58 (diff)
move all of these under tests
Original commit message from CVS: move all of these under tests
Diffstat (limited to 'testsuite/states')
-rw-r--r--testsuite/states/.gitignore11
-rw-r--r--testsuite/states/Makefile.am5
-rw-r--r--testsuite/states/bin.c158
-rw-r--r--testsuite/states/locked.c105
-rw-r--r--testsuite/states/parent.c111
5 files changed, 0 insertions, 390 deletions
diff --git a/testsuite/states/.gitignore b/testsuite/states/.gitignore
deleted file mode 100644
index 9d274cca4..000000000
--- a/testsuite/states/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-Makefile
-Makefile.in
-*.o
-*.lo
-*.la
-.deps
-.libs
-
-bin
-locked
-parent
diff --git a/testsuite/states/Makefile.am b/testsuite/states/Makefile.am
deleted file mode 100644
index 2a01e7553..000000000
--- a/testsuite/states/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-include ../Rules
-
-tests_pass = locked parent
-tests_fail =
-tests_ignore = bin
diff --git a/testsuite/states/bin.c b/testsuite/states/bin.c
deleted file mode 100644
index a62b0a78f..000000000
--- a/testsuite/states/bin.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* GStreamer
- * Copyright (C) <2004> Benjamin Otte <otte@gnome.org>
- *
- * bin.c:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gst/gst.h>
-
-#define RETURN_NAME(x) ((x) == GST_STATE_CHANGE_SUCCESS ? "GST_STATE_CHANGE_SUCCESS" : \
- (x) == GST_STATE_CHANGE_ASYNC ? "GST_STATE_CHANGE_ASYNC" : "GST_STATE_CHANGE_FAILURE")
-static void
-assert_state (GstElement * element, GstState state)
-{
- GstState current, pending;
-
- gst_element_get_state (element, &current, &pending, NULL);
- if (current != state) {
- g_printerr ("%s: state is %s instead of %s",
- GST_OBJECT_NAME (element),
- gst_element_state_get_name (GST_STATE (element)),
- gst_element_state_get_name (state));
- g_assert_not_reached ();
- }
-}
-
-static void
-assert_state_change (GstElement * element, GstState new_state,
- GstStateChangeReturn result, GstState result_state)
-{
- GstStateChangeReturn ret = gst_element_set_state (element, new_state);
-
- if (ret != result) {
- g_printerr ("%s: change state to %s returned %s instead of %s",
- GST_OBJECT_NAME (element), gst_element_state_get_name (new_state),
- RETURN_NAME (ret), RETURN_NAME (result));
- g_assert_not_reached ();
- }
- assert_state (element, result_state);
-}
-
-static void
-empty_bin (gchar * bin_name)
-{
- /* Test the behaviour of empty bins. Since a bin's state is always the state
- * of its highest child, nothing should change in here
- * Return values when no error occured but the state didn't change should be
- * GST_STATE_CHANGE_ASYNC */
- GstElement *bin = gst_element_factory_make (bin_name, NULL);
-
- g_assert (bin);
- /* obvious */
- assert_state (bin, GST_STATE_NULL);
- /* see above */
- assert_state_change (bin, GST_STATE_READY, GST_STATE_CHANGE_SUCCESS,
- GST_STATE_READY);
- assert_state_change (bin, GST_STATE_PAUSED, GST_STATE_CHANGE_SUCCESS,
- GST_STATE_PAUSED);
- assert_state_change (bin, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS,
- GST_STATE_PLAYING);
-}
-
-static void
-test_adding_one_element (GstElement * bin)
-{
- /* Tests behaviour of adding/removing elements to/from bins. It makes sure the
- * state of the bin is always the highest of all contained children. */
- GstState test_states[] = { GST_STATE_READY, GST_STATE_PAUSED,
- GST_STATE_PLAYING, GST_STATE_PAUSED, GST_STATE_READY, GST_STATE_NULL
- };
- GstElement *test = gst_element_factory_make ("identity", NULL);
- GstState bin_state;
- gint i;
-
- gst_element_get_state (bin, &bin_state, NULL, NULL);
- g_assert (test);
- gst_object_ref (test);
- assert_state (test, GST_STATE_NULL);
- gst_bin_add (GST_BIN (bin), test);
- assert_state (bin, MAX (bin_state, GST_STATE_NULL));
- for (i = 0; i < G_N_ELEMENTS (test_states); i++) {
- GstState test_state = test_states[i];
-
- assert_state_change (test, test_state, GST_STATE_CHANGE_SUCCESS,
- test_state);
- assert_state (test, test_state);
- assert_state (bin, MAX (bin_state, test_state));
- gst_bin_remove (GST_BIN (bin), test);
- assert_state (bin, bin_state);
- gst_bin_add (GST_BIN (bin), test);
- assert_state (test, test_state);
- assert_state (bin, MAX (bin_state, test_state));
- }
- gst_bin_remove (GST_BIN (bin), test);
- gst_object_unref (test);
- assert_state (bin, bin_state);
-}
-
-static void
-test_element_in_bin (gchar * bin_name)
-{
- gint i;
- GstState test_states[] = { GST_STATE_NULL, GST_STATE_READY,
- GST_STATE_PAUSED, GST_STATE_PLAYING
- };
- GstElement *id, *bin = gst_element_factory_make (bin_name, NULL);
-
- g_assert (bin);
-
- /* test correct behaviour in empty bins */
- test_adding_one_element (bin);
-
- id = gst_element_factory_make ("identity", NULL);
- g_assert (id);
- assert_state (id, GST_STATE_NULL);
- gst_bin_add (GST_BIN (bin), id);
- /* test correct behaviour in bins which contain elements in various states */
- for (i = 0; i < G_N_ELEMENTS (test_states); i++) {
- GstState test_state = test_states[i];
-
- assert_state_change (bin, test_state, GST_STATE_CHANGE_SUCCESS, test_state);
- assert_state (id, test_state);
- test_adding_one_element (bin);
- }
-
- gst_object_unref (bin);
-}
-
-gint
-main (gint argc, gchar * argv[])
-{
- gst_init (&argc, &argv);
-
- /* test behaviour of empty bins */
- empty_bin ("bin");
- empty_bin ("pipeline");
-
- g_print ("how far\n");
- /* test behaviour of adding/removing elements to/from all core bin types */
- test_element_in_bin ("bin");
- test_element_in_bin ("pipeline");
-
- return 0;
-}
diff --git a/testsuite/states/locked.c b/testsuite/states/locked.c
deleted file mode 100644
index aa4a7a719..000000000
--- a/testsuite/states/locked.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "unistd.h"
-
-#include <gst/gst.h>
-
-static GMainLoop *loop;
-
-static gboolean
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- g_print ("message %p\n", message);
-
- if (message->type == GST_MESSAGE_EOS) {
- g_print ("EOS!!\n");
- if (g_main_loop_is_running (loop))
- g_main_loop_quit (loop);
- }
- gst_message_unref (message);
-
- return TRUE;
-}
-
-gint
-main (gint argc, gchar * argv[])
-{
- GstElement *pipeline;
- GstElement *fakesrc1, *fakesink1;
- GstElement *fakesrc2, *fakesink2;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- pipeline = gst_pipeline_new ("pipeline");
-
- loop = g_main_loop_new (NULL, FALSE);
- bus = gst_element_get_bus (pipeline);
- gst_bus_add_watch (bus, GST_MESSAGE_EOS, (GstBusFunc) message_received,
- (gpointer) pipeline);
- gst_object_unref (bus);
-
- fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
- g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
- fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
-
- gst_bin_add (GST_BIN (pipeline), fakesrc1);
- gst_bin_add (GST_BIN (pipeline), fakesink1);
- gst_pad_link (gst_element_get_pad (fakesrc1, "src"),
- gst_element_get_pad (fakesink1, "sink"));
-
- fakesrc2 = gst_element_factory_make ("fakesrc", "fakesrc2");
- g_object_set (G_OBJECT (fakesrc2), "num_buffers", 5, NULL);
- fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
-
- gst_bin_add (GST_BIN (pipeline), fakesrc2);
- gst_bin_add (GST_BIN (pipeline), fakesink2);
- gst_pad_link (gst_element_get_pad (fakesrc2, "src"),
- gst_element_get_pad (fakesink2, "sink"));
-
- g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (gst_object_default_deep_notify), NULL);
-
- GST_OBJECT_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
- GST_OBJECT_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
-
- g_print ("play..\n");
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- g_main_loop_run (loop);
-
- g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
-
- gst_element_set_state (pipeline, GST_STATE_READY);
-
- GST_OBJECT_FLAG_UNSET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
- GST_OBJECT_FLAG_UNSET (fakesink2, GST_ELEMENT_LOCKED_STATE);
-
- g_print ("play..\n");
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- g_main_loop_run (loop);
-
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/testsuite/states/parent.c b/testsuite/states/parent.c
deleted file mode 100644
index fe8b2441c..000000000
--- a/testsuite/states/parent.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* GStreamer
- *
- * parent.c: test to check that setting state on a parent sets same state
- * recursively on children
- *
- * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gst/gst.h>
-
-gint
-main (gint argc, gchar * argv[])
-{
- GstElement *pipeline;
- GstElement *bin1, *bin2;
- GstElement *fakesrc, *identity, *fakesink;
-
- gst_init (&argc, &argv);
-
- /*
- * +-pipeline----------------------------------------+
- * | +-bin2----------------------------------------+ |
- * | | +-bin1-----------------------+ | |
- * | | | +---------+ +----------+ | +----------+ | |
- * | | | | fakesrc |---| identity |---| fakesink | | |
- * | | | +---------+ +----------- | +----------+ | |
- * | | +----------------------------+ | |
- * | +---------------------------------------------+ |
- * +-------------------------------------------------+
- */
-
- pipeline = gst_pipeline_new ("pipeline");
- g_assert (pipeline);
- bin1 = gst_bin_new ("bin1");
- g_assert (bin1);
- bin2 = gst_bin_new ("bin2");
- g_assert (bin2);
-
- fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
- g_assert (fakesrc);
- g_object_set (G_OBJECT (fakesrc), "num_buffers", 5, NULL);
- identity = gst_element_factory_make ("identity", "identity");
- g_assert (identity);
- fakesink = gst_element_factory_make ("fakesink", "fakesink");
- g_assert (fakesink);
-
- gst_bin_add_many (GST_BIN (bin1), fakesrc, identity, NULL);
- g_assert (gst_element_link (fakesrc, identity));
-
- gst_bin_add_many (GST_BIN (bin2), bin1, fakesink, NULL);
- g_assert (gst_element_link (identity, fakesink));
-
- gst_bin_add (GST_BIN (pipeline), bin2);
- g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (gst_object_default_deep_notify), NULL);
-
- /* setting pipeline to READY should bring in all children to READY */
- gst_element_set_state (pipeline, GST_STATE_READY);
- g_assert (GST_STATE (bin1) == GST_STATE_READY);
- g_assert (GST_STATE (bin2) == GST_STATE_READY);
- g_assert (GST_STATE (fakesrc) == GST_STATE_READY);
- g_assert (GST_STATE (identity) == GST_STATE_READY);
- g_assert (GST_STATE (fakesink) == GST_STATE_READY);
-
- /* setting fakesink to PAUSED should not affect pipeline and bin2 */
- gst_element_set_state (fakesink, GST_STATE_PAUSED);
- g_assert (GST_STATE (bin1) == GST_STATE_READY);
- g_assert (GST_STATE (bin2) == GST_STATE_READY);
- g_assert (GST_STATE (fakesrc) == GST_STATE_READY);
- g_assert (GST_STATE (identity) == GST_STATE_READY);
- g_assert (GST_STATE (fakesink) == GST_STATE_READY);
-
- /* setting fakesrc to PAUSED should not affect bin1 */
- gst_element_set_state (fakesrc, GST_STATE_PAUSED);
- g_assert (GST_STATE (bin1) == GST_STATE_READY);
- g_assert (GST_STATE (bin2) == GST_STATE_READY);
- g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
- g_assert (GST_STATE (identity) == GST_STATE_READY);
- g_assert (GST_STATE (fakesink) == GST_STATE_READY);
-
- /* setting bin1 to PAUSED, even though it is already, should set
- * identity to PAUSED as well */
- gst_element_set_state (bin1, GST_STATE_PAUSED);
- gst_element_get_state (bin2, NULL, NULL, NULL);
- g_assert (GST_STATE (bin1) == GST_STATE_PAUSED);
- g_assert (GST_STATE (bin2) == GST_STATE_READY);
- g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
- g_assert (GST_STATE (identity) == GST_STATE_PAUSED);
- g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
-
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- g_usleep (1000000);
-
- g_print ("passed.\n");
- return 0;
-}