summaryrefslogtreecommitdiff
authorEdward Hervey <bilboed@bilboed.com>2011-02-08 11:59:10 (GMT)
committer Edward Hervey <bilboed@bilboed.com>2011-02-09 10:02:22 (GMT)
commit83d10f27bce7f9d68126032711aaddd85f3eb196 (patch) (side-by-side diff)
tree08e376ef3498bc85935460cd1ce18714218e3c00
parent158a35a9e0e9b79b8d4399b42f501676f5d1a1e4 (diff)
downloadgnonlin-83d10f27bce7f9d68126032711aaddd85f3eb196.zip
gnonlin-83d10f27bce7f9d68126032711aaddd85f3eb196.tar.gz
check: refactor 'gnloperation' tests
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--tests/check/gnl/gnloperation.c926
1 files changed, 131 insertions, 795 deletions
diff --git a/tests/check/gnl/gnloperation.c b/tests/check/gnl/gnloperation.c
index 25d25cd..74a2dd7 100644
--- a/tests/check/gnl/gnloperation.c
+++ b/tests/check/gnl/gnloperation.c
@@ -1,86 +1,20 @@
#include "common.h"
-GST_START_TEST (test_simple_operation)
+static void
+fill_pipeline_and_check (GstElement * comp, GList * segments)
{
- GstElement *pipeline;
- guint64 start, stop;
- gint64 duration;
- GstElement *comp, *oper, *source, *sink;
+ GstElement *pipeline, *sink;
CollectStructure *collect;
GstBus *bus;
GstMessage *message;
gboolean carry_on = TRUE;
GstPad *sinkpad;
+ GList *listcopy = copy_segment_list (segments);
pipeline = gst_pipeline_new ("test_pipeline");
- comp =
- gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
-
- /* TOPOLOGY
- *
- * 0 1 2 3 4 5 | Priority
- * ----------------------------------------------------------------------------
- * [-- oper --] | 0
- * [------------- source -------------] | 1
- * */
-
- /*
- source
- Start : 0s
- Duration : 3s
- Priority : 1
- */
-
- source = videotest_gnl_src ("source", 0, 3 * GST_SECOND, 2, 1);
- fail_if (source == NULL);
- check_start_stop_duration (source, 0, 3 * GST_SECOND, 3 * GST_SECOND);
-
- /*
- operation
- Start : 1s
- Duration : 1s
- Priority : 0
- */
-
- oper = new_operation ("oper", "identity", 1 * GST_SECOND, 1 * GST_SECOND, 0);
- fail_if (oper == NULL);
- check_start_stop_duration (oper, 1 * GST_SECOND, 2 * GST_SECOND,
- 1 * GST_SECOND);
-
- /* Add source */
- ASSERT_OBJECT_REFCOUNT (source, "source", 1);
- ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
-
- gst_bin_add (GST_BIN (comp), source);
- check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
-
- ASSERT_OBJECT_REFCOUNT (source, "source", 1);
-
- /* Add operaton */
-
- gst_bin_add (GST_BIN (comp), oper);
- check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
-
- ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
-
- /* remove source */
-
- gst_object_ref (source);
- gst_bin_remove (GST_BIN (comp), source);
- check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
- 1 * GST_SECOND);
-
- ASSERT_OBJECT_REFCOUNT (source, "source", 1);
-
- /* re-add source */
- gst_bin_add (GST_BIN (comp), source);
- check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
- gst_object_unref (source);
-
- ASSERT_OBJECT_REFCOUNT (source, "source", 1);
-
-
sink = gst_element_factory_make_or_warn ("fakesink", "sink");
+ fail_if (sink == NULL);
+
gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
/* Shared data */
@@ -89,14 +23,7 @@ GST_START_TEST (test_simple_operation)
collect->sink = sink;
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
+ collect->expected_segments = segments;
g_signal_connect (G_OBJECT (comp), "pad-added",
G_CALLBACK (composition_pad_added_cb), collect);
@@ -109,13 +36,11 @@ GST_START_TEST (test_simple_operation)
bus = gst_element_get_bus (GST_ELEMENT (pipeline));
GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source, "source", 1);
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
GST_DEBUG ("Let's poll the bus");
-
while (carry_on) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
if (message) {
@@ -141,7 +66,7 @@ GST_START_TEST (test_simple_operation)
}
}
- GST_DEBUG ("Setting pipeline to NULL");
+ GST_DEBUG ("Setting pipeline to READY");
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
@@ -150,18 +75,9 @@ GST_START_TEST (test_simple_operation)
GST_DEBUG ("Resetted pipeline to READY");
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
+ collect->expected_segments = listcopy;
collect->gotsegment = FALSE;
-
GST_DEBUG ("Setting pipeline to PLAYING again");
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
@@ -211,21 +127,101 @@ GST_START_TEST (test_simple_operation)
g_free (collect);
}
+GST_START_TEST (test_simple_operation)
+{
+ guint64 start, stop;
+ gint64 duration;
+ GstElement *comp, *oper, *source;
+ GList *segments = NULL;
+
+ comp =
+ gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
+
+ /* TOPOLOGY
+ *
+ * 0 1 2 3 4 5 | Priority
+ * ----------------------------------------------------------------------------
+ * [-- oper --] | 0
+ * [------------- source -------------] | 1
+ * */
+
+ /*
+ source
+ Start : 0s
+ Duration : 3s
+ Priority : 1
+ */
+
+ source = videotest_gnl_src ("source", 0, 3 * GST_SECOND, 2, 1);
+ fail_if (source == NULL);
+ check_start_stop_duration (source, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+
+ /*
+ operation
+ Start : 1s
+ Duration : 1s
+ Priority : 0
+ */
+
+ oper = new_operation ("oper", "identity", 1 * GST_SECOND, 1 * GST_SECOND, 0);
+ fail_if (oper == NULL);
+ check_start_stop_duration (oper, 1 * GST_SECOND, 2 * GST_SECOND,
+ 1 * GST_SECOND);
+
+ /* Add source */
+ ASSERT_OBJECT_REFCOUNT (source, "source", 1);
+ ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
+
+ gst_bin_add (GST_BIN (comp), source);
+ check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+
+ ASSERT_OBJECT_REFCOUNT (source, "source", 1);
+
+ /* Add operaton */
+
+ gst_bin_add (GST_BIN (comp), oper);
+ check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+
+ ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
+
+ /* remove source */
+
+ gst_object_ref (source);
+ gst_bin_remove (GST_BIN (comp), source);
+ check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
+ 1 * GST_SECOND);
+
+ ASSERT_OBJECT_REFCOUNT (source, "source", 1);
+
+ /* re-add source */
+ gst_bin_add (GST_BIN (comp), source);
+ check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
+ gst_object_unref (source);
+
+ ASSERT_OBJECT_REFCOUNT (source, "source", 1);
+
+ /* Expected segments */
+ segments = g_list_append (segments,
+ segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
+ segments = g_list_append (segments,
+ segment_new (1.0, GST_FORMAT_TIME,
+ 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
+ segments = g_list_append (segments,
+ segment_new (1.0, GST_FORMAT_TIME,
+ 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
+
+ fill_pipeline_and_check (comp, segments);
+}
+
GST_END_TEST;
GST_START_TEST (test_pyramid_operations)
{
- GstElement *pipeline;
guint64 start, stop;
gint64 duration;
- GstElement *comp, *oper1, *oper2, *source, *sink;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
- GstPad *sinkpad;
+ GstElement *comp, *oper1, *oper2, *source;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -287,166 +283,34 @@ GST_START_TEST (test_pyramid_operations)
ASSERT_OBJECT_REFCOUNT (oper1, "oper2", 1);
-
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 4 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 4 * GST_SECOND, 6 * GST_SECOND, 4 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 6 * GST_SECOND, 8 * GST_SECOND, 6 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 8 * GST_SECOND, 10 * GST_SECOND, 8 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source, "source", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to NULL");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY");
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 4 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
4 * GST_SECOND, 6 * GST_SECOND, 4 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
6 * GST_SECOND, 8 * GST_SECOND, 6 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
8 * GST_SECOND, 10 * GST_SECOND, 8 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
GST_START_TEST (test_pyramid_operations2)
{
- GstElement *pipeline;
guint64 start, stop;
gint64 duration;
- GstElement *comp, *oper, *source1, *source2, *def, *sink;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
- GstPad *sinkpad;
+ GstElement *comp, *oper, *source1, *source2, *def;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -516,166 +380,34 @@ GST_START_TEST (test_pyramid_operations2)
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 4 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 5 * GST_SECOND, 6 * GST_SECOND, 5 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to NULL");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY");
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 4 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
4 * GST_SECOND, 5 * GST_SECOND, 4 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
5 * GST_SECOND, 6 * GST_SECOND, 5 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
-
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
GST_START_TEST (test_pyramid_operations_expandable)
{
- GstElement *pipeline;
guint64 start, stop;
gint64 duration;
- GstElement *comp, *oper, *source1, *source2, *def, *sink;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
- GstPad *sinkpad;
+ GstElement *comp, *oper, *source1, *source2, *def;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -745,159 +477,29 @@ GST_START_TEST (test_pyramid_operations_expandable)
gst_bin_add (GST_BIN (comp), def);
check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND);
-
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 2 * GST_SECOND, 4 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 4 * GST_SECOND, 6 * GST_SECOND, 4 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to NULL");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY");
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
2 * GST_SECOND, 4 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
4 * GST_SECOND, 6 * GST_SECOND, 4 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
-
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
-
-
-
GST_START_TEST (test_complex_operations)
{
- GstElement *pipeline;
guint64 start, stop;
gint64 duration;
- GstElement *comp, *oper, *source1, *source2, *sink;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
- GstPad *sinkpad;
+ GstElement *comp, *oper, *source1, *source2;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -909,11 +511,7 @@ GST_START_TEST (test_complex_operations)
*/
source1 = videotest_in_bin_gnl_src ("source1", 0, 4 * GST_SECOND, 2, 3);
- if (source1 == NULL) {
- gst_object_unref (pipeline);
- gst_object_unref (comp);
- return;
- }
+ fail_if (source1 == NULL);
check_start_stop_duration (source1, 0, 4 * GST_SECOND, 4 * GST_SECOND);
/*
@@ -966,143 +564,17 @@ GST_START_TEST (test_complex_operations)
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 0 * GST_SECOND, 2 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 4 * GST_SECOND, 6 * GST_SECOND, 4 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
- ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
- ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to READY");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY");
-
- /* Elements should all be in the READY state */
- check_state_simple (source1, GST_STATE_READY);
- check_state_simple (source2, GST_STATE_READY);
- check_state_simple (oper, GST_STATE_READY);
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
0 * GST_SECOND, 2 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
4 * GST_SECOND, 6 * GST_SECOND, 4 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;
@@ -1110,17 +582,11 @@ GST_END_TEST;
GST_START_TEST (test_complex_operations_bis)
{
- GstElement *pipeline;
guint64 start, stop;
gint64 duration;
- GstElement *comp, *oper, *source1, *source2, *sink;
- CollectStructure *collect;
- GstBus *bus;
- GstMessage *message;
- gboolean carry_on = TRUE;
- GstPad *sinkpad;
+ GstElement *comp, *oper, *source1, *source2;
+ GList *segments = NULL;
- pipeline = gst_pipeline_new ("test_pipeline");
comp =
gst_element_factory_make_or_warn ("gnlcomposition", "test_composition");
@@ -1142,11 +608,7 @@ GST_START_TEST (test_complex_operations_bis)
*/
source1 = videotest_in_bin_gnl_src ("source1", 0, 4 * GST_SECOND, 3, 2);
- if (source1 == NULL) {
- gst_object_unref (pipeline);
- gst_object_unref (comp);
- return;
- }
+ fail_if (source1 == NULL);
check_start_stop_duration (source1, 0, 4 * GST_SECOND, 4 * GST_SECOND);
/*
@@ -1204,143 +666,17 @@ GST_START_TEST (test_complex_operations_bis)
ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
-
- sink = gst_element_factory_make_or_warn ("fakesink", "sink");
- gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
-
- /* Shared data */
- collect = g_new0 (CollectStructure, 1);
- collect->comp = comp;
- collect->sink = sink;
-
- /* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 0 * GST_SECOND, 2 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
- segment_new (1.0, GST_FORMAT_TIME,
- 0 * GST_SECOND, 2 * GST_SECOND, 4 * GST_SECOND));
-
- g_signal_connect (G_OBJECT (comp), "pad-added",
- G_CALLBACK (composition_pad_added_cb), collect);
-
- sinkpad = gst_element_get_pad (sink, "sink");
- gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect);
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe),
- collect);
-
- bus = gst_element_get_bus (GST_ELEMENT (pipeline));
-
- GST_DEBUG ("Setting pipeline to PLAYING");
- ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
- ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
- ASSERT_OBJECT_REFCOUNT (oper, "oper", 1);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- GST_WARNING ("Got an EOS");
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_WARNING ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- }
- }
-
- GST_DEBUG ("Setting pipeline to READY");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
-
- fail_if (collect->expected_segments != NULL);
-
- GST_DEBUG ("Resetted pipeline to READY, checking state of elements");
-
- /* Elements should all be in the READY state */
- check_state_simple (source1, GST_STATE_READY);
- check_state_simple (source2, GST_STATE_READY);
- check_state_simple (oper, GST_STATE_READY);
-
/* Expected segments */
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 2 * GST_SECOND, 0));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
0 * GST_SECOND, 2 * GST_SECOND, 2 * GST_SECOND));
- collect->expected_segments = g_list_append (collect->expected_segments,
+ segments = g_list_append (segments,
segment_new (1.0, GST_FORMAT_TIME,
0 * GST_SECOND, 2 * GST_SECOND, 4 * GST_SECOND));
- collect->gotsegment = FALSE;
-
-
- GST_DEBUG ("Setting pipeline to PLAYING again");
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
-
- carry_on = TRUE;
-
- GST_DEBUG ("Let's poll the bus");
-
- while (carry_on) {
- message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
- if (message) {
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- /* we should check if we really finished here */
- carry_on = FALSE;
- break;
- case GST_MESSAGE_SEGMENT_START:
- case GST_MESSAGE_SEGMENT_DONE:
- /* We shouldn't see any segement messages, since we didn't do a segment seek */
- GST_WARNING ("Saw a Segment start/stop");
- fail_if (TRUE);
- break;
- case GST_MESSAGE_ERROR:
- GST_ERROR ("Saw an ERROR");
- fail_if (TRUE);
- default:
- break;
- }
- gst_mini_object_unref (GST_MINI_OBJECT (message));
- } else {
- GST_DEBUG ("bus_poll responded, but there wasn't any message...");
- }
- }
- fail_if (collect->expected_segments != NULL);
-
- fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
- GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
-
- gst_object_unref (GST_OBJECT (sinkpad));
- ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
- gst_object_unref (pipeline);
- ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
- gst_object_unref (bus);
-
- g_free (collect);
+ fill_pipeline_and_check (comp, segments);
}
GST_END_TEST;