adder: cleanup test

Use right type for StateChangeReturn and avoid needless G_OBJECT casts.
This commit is contained in:
Stefan Sauer 2012-07-16 08:37:33 +02:00
parent 673dafd09d
commit ff120f6aa9

View file

@ -100,6 +100,7 @@ GST_START_TEST (test_event)
GstElement *bin, *src1, *src2, *adder, *sink; GstElement *bin, *src1, *src2, *adder, *sink;
GstBus *bus; GstBus *bus;
GstEvent *seek_event; GstEvent *seek_event;
GstStateChangeReturn state_res;
gboolean res; gboolean res;
GstPad *srcpad, *sinkpad; GstPad *srcpad, *sinkpad;
GstStreamConsistency *chk_1, *chk_2, *chk_3; GstStreamConsistency *chk_1, *chk_2, *chk_3;
@ -163,25 +164,25 @@ GST_START_TEST (test_event)
GST_INFO ("starting test"); GST_INFO ("starting test");
/* prepare playing */ /* prepare playing */
res = gst_element_set_state (bin, GST_STATE_PAUSED); state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion */ /* wait for completion */
res = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE); state_res = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
res = gst_element_send_event (bin, seek_event); res = gst_element_send_event (bin, seek_event);
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
/* run pipeline */ /* run pipeline */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
GST_INFO ("running main loop"); GST_INFO ("running main loop");
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
ck_assert_int_eq (position, 2 * GST_SECOND); ck_assert_int_eq (position, 2 * GST_SECOND);
@ -190,8 +191,8 @@ GST_START_TEST (test_event)
gst_consistency_checker_free (chk_1); gst_consistency_checker_free (chk_1);
gst_consistency_checker_free (chk_2); gst_consistency_checker_free (chk_2);
gst_consistency_checker_free (chk_3); gst_consistency_checker_free (chk_3);
gst_object_unref (G_OBJECT (bus)); gst_object_unref (bus);
gst_object_unref (G_OBJECT (bin)); gst_object_unref (bin);
} }
GST_END_TEST; GST_END_TEST;
@ -204,6 +205,7 @@ test_play_twice_message_received (GstBus * bus, GstMessage * message,
GstPipeline * bin) GstPipeline * bin)
{ {
gboolean res; gboolean res;
GstStateChangeReturn state_res;
GST_INFO ("bus message from \"%" GST_PTR_FORMAT "\": %" GST_PTR_FORMAT, GST_INFO ("bus message from \"%" GST_PTR_FORMAT "\": %" GST_PTR_FORMAT,
GST_MESSAGE_SRC (message), message); GST_MESSAGE_SRC (message), message);
@ -212,25 +214,26 @@ test_play_twice_message_received (GstBus * bus, GstMessage * message,
case GST_MESSAGE_SEGMENT_DONE: case GST_MESSAGE_SEGMENT_DONE:
play_count++; play_count++;
if (play_count == 1) { if (play_count == 1) {
res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); state_res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* prepare playing again */ /* prepare playing again */
res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); state_res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion */ /* wait for completion */
res = state_res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE); GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
res = gst_element_send_event (GST_ELEMENT (bin), res = gst_element_send_event (GST_ELEMENT (bin),
gst_event_ref (play_seek_event)); gst_event_ref (play_seek_event));
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); state_res =
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
} else { } else {
g_main_loop_quit (main_loop); g_main_loop_quit (main_loop);
} }
@ -247,6 +250,7 @@ GST_START_TEST (test_play_twice)
GstElement *bin, *src1, *src2, *adder, *sink; GstElement *bin, *src1, *src2, *adder, *sink;
GstBus *bus; GstBus *bus;
gboolean res; gboolean res;
GstStateChangeReturn state_res;
GstPad *srcpad; GstPad *srcpad;
GstStreamConsistency *consist; GstStreamConsistency *consist;
@ -293,14 +297,14 @@ GST_START_TEST (test_play_twice)
GST_INFO ("starting test"); GST_INFO ("starting test");
/* prepare playing */ /* prepare playing */
res = gst_element_set_state (bin, GST_STATE_PAUSED); state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion */ /* wait for completion */
res = state_res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE); GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); res = gst_element_send_event (bin, gst_event_ref (play_seek_event));
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
@ -308,13 +312,13 @@ GST_START_TEST (test_play_twice)
GST_INFO ("seeked"); GST_INFO ("seeked");
/* run pipeline */ /* run pipeline */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
ck_assert_int_eq (play_count, 2); ck_assert_int_eq (play_count, 2);
@ -322,8 +326,8 @@ GST_START_TEST (test_play_twice)
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
gst_consistency_checker_free (consist); gst_consistency_checker_free (consist);
gst_event_ref (play_seek_event); gst_event_ref (play_seek_event);
gst_object_unref (G_OBJECT (bus)); gst_object_unref (bus);
gst_object_unref (G_OBJECT (bin)); gst_object_unref (bin);
} }
GST_END_TEST; GST_END_TEST;
@ -333,6 +337,7 @@ GST_START_TEST (test_play_twice_then_add_and_play_again)
GstElement *bin, *src1, *src2, *src3, *adder, *sink; GstElement *bin, *src1, *src2, *src3, *adder, *sink;
GstBus *bus; GstBus *bus;
gboolean res; gboolean res;
GstStateChangeReturn state_res;
gint i; gint i;
GstPad *srcpad; GstPad *srcpad;
GstStreamConsistency *consist; GstStreamConsistency *consist;
@ -382,14 +387,14 @@ GST_START_TEST (test_play_twice_then_add_and_play_again)
GST_INFO ("starting test-loop %d", i); GST_INFO ("starting test-loop %d", i);
/* prepare playing */ /* prepare playing */
res = gst_element_set_state (bin, GST_STATE_PAUSED); state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion */ /* wait for completion */
res = state_res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE); GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); res = gst_element_send_event (bin, gst_event_ref (play_seek_event));
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
@ -397,13 +402,13 @@ GST_START_TEST (test_play_twice_then_add_and_play_again)
GST_INFO ("seeked"); GST_INFO ("seeked");
/* run pipeline */ /* run pipeline */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
res = gst_element_set_state (bin, GST_STATE_READY); state_res = gst_element_set_state (bin, GST_STATE_READY);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
ck_assert_int_eq (play_count, 2); ck_assert_int_eq (play_count, 2);
@ -420,15 +425,15 @@ GST_START_TEST (test_play_twice_then_add_and_play_again)
gst_consistency_checker_reset (consist); gst_consistency_checker_reset (consist);
} }
res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* cleanup */ /* cleanup */
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
gst_event_ref (play_seek_event); gst_event_ref (play_seek_event);
gst_consistency_checker_free (consist); gst_consistency_checker_free (consist);
gst_object_unref (G_OBJECT (bus)); gst_object_unref (bus);
gst_object_unref (G_OBJECT (bin)); gst_object_unref (bin);
} }
GST_END_TEST; GST_END_TEST;
@ -458,6 +463,7 @@ GST_START_TEST (test_live_seeking)
GstElement *bin, *src1, *src2, *ac1, *ac2, *adder, *sink; GstElement *bin, *src1, *src2, *ac1, *ac2, *adder, *sink;
GstBus *bus; GstBus *bus;
gboolean res; gboolean res;
GstStateChangeReturn state_res;
GstPad *srcpad; GstPad *srcpad;
gint i; gint i;
GstStreamConsistency *consist; GstStreamConsistency *consist;
@ -482,11 +488,11 @@ GST_START_TEST (test_live_seeking)
goto cleanup; goto cleanup;
} }
/* Test that the audio source can get to paused, else skip */ /* Test that the audio source can get to paused, else skip */
res = gst_element_set_state (src1, GST_STATE_PAUSED); state_res = gst_element_set_state (src1, GST_STATE_PAUSED);
(void) gst_element_set_state (src1, GST_STATE_NULL); (void) gst_element_set_state (src1, GST_STATE_NULL);
gst_object_unref (src1); gst_object_unref (src1);
if (res == GST_STATE_CHANGE_FAILURE) if (state_res == GST_STATE_CHANGE_FAILURE)
goto cleanup; goto cleanup;
src1 = gst_element_factory_make ("alsasrc", "src1"); src1 = gst_element_factory_make ("alsasrc", "src1");
@ -536,14 +542,14 @@ GST_START_TEST (test_live_seeking)
GST_INFO ("starting test-loop %d", i); GST_INFO ("starting test-loop %d", i);
/* prepare playing */ /* prepare playing */
res = gst_element_set_state (bin, GST_STATE_PAUSED); state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion */ /* wait for completion */
res = state_res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE); GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); res = gst_element_send_event (bin, gst_event_ref (play_seek_event));
#if 1 #if 1
@ -556,15 +562,15 @@ GST_START_TEST (test_live_seeking)
GST_INFO ("seeked"); GST_INFO ("seeked");
/* run pipeline */ /* run pipeline */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
GST_INFO ("playing"); GST_INFO ("playing");
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
gst_consistency_checker_reset (consist); gst_consistency_checker_reset (consist);
} }
@ -576,8 +582,8 @@ cleanup:
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
if (play_seek_event) if (play_seek_event)
gst_event_unref (play_seek_event); gst_event_unref (play_seek_event);
gst_object_unref (G_OBJECT (bus)); gst_object_unref (bus);
gst_object_unref (G_OBJECT (bin)); gst_object_unref (bin);
} }
GST_END_TEST; GST_END_TEST;
@ -589,6 +595,7 @@ GST_START_TEST (test_add_pad)
GstBus *bus; GstBus *bus;
GstPad *srcpad; GstPad *srcpad;
gboolean res; gboolean res;
GstStateChangeReturn state_res;
GST_INFO ("preparing test"); GST_INFO ("preparing test");
@ -626,14 +633,14 @@ GST_START_TEST (test_add_pad)
GST_INFO ("starting test"); GST_INFO ("starting test");
/* prepare playing */ /* prepare playing */
res = gst_element_set_state (bin, GST_STATE_PAUSED); state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion */ /* wait for completion */
res = state_res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE); GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* add other element */ /* add other element */
gst_bin_add_many (GST_BIN (bin), src2, NULL); gst_bin_add_many (GST_BIN (bin), src2, NULL);
@ -643,21 +650,22 @@ GST_START_TEST (test_add_pad)
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
/* set to PAUSED as well */ /* set to PAUSED as well */
res = gst_element_set_state (src2, GST_STATE_PAUSED); state_res = gst_element_set_state (src2, GST_STATE_PAUSED);
ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* now play all */ /* now play all */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* cleanup */ /* cleanup */
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
gst_object_unref (G_OBJECT (bus)); gst_object_unref (bus);
gst_object_unref (G_OBJECT (bin)); gst_object_unref (bin);
} }
GST_END_TEST; GST_END_TEST;
@ -669,6 +677,7 @@ GST_START_TEST (test_remove_pad)
GstBus *bus; GstBus *bus;
GstPad *pad, *srcpad; GstPad *pad, *srcpad;
gboolean res; gboolean res;
GstStateChangeReturn state_res;
GST_INFO ("preparing test"); GST_INFO ("preparing test");
@ -707,12 +716,12 @@ GST_START_TEST (test_remove_pad)
/* prepare playing, this will not preroll as adder is waiting /* prepare playing, this will not preroll as adder is waiting
* on the unconnected sinkpad. */ * on the unconnected sinkpad. */
res = gst_element_set_state (bin, GST_STATE_PAUSED); state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* wait for completion for one second, will return ASYNC */ /* wait for completion for one second, will return ASYNC */
res = gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, GST_SECOND); state_res = gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, GST_SECOND);
ck_assert_int_eq (res, GST_STATE_CHANGE_ASYNC); ck_assert_int_eq (state_res, GST_STATE_CHANGE_ASYNC);
/* get rid of the pad now, adder should stop waiting on it and /* get rid of the pad now, adder should stop waiting on it and
* continue the preroll */ * continue the preroll */
@ -720,19 +729,19 @@ GST_START_TEST (test_remove_pad)
gst_object_unref (pad); gst_object_unref (pad);
/* wait for completion, should work now */ /* wait for completion, should work now */
res = state_res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE); GST_CLOCK_TIME_NONE);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* now play all */ /* now play all */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* cleanup */ /* cleanup */
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
@ -760,6 +769,7 @@ GST_START_TEST (test_clip)
GstBus *bus; GstBus *bus;
GstPad *sinkpad; GstPad *sinkpad;
gboolean res; gboolean res;
GstStateChangeReturn state_res;
GstFlowReturn ret; GstFlowReturn ret;
GstEvent *event; GstEvent *event;
GstBuffer *buffer; GstBuffer *buffer;
@ -787,8 +797,8 @@ GST_START_TEST (test_clip)
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
/* set to playing */ /* set to playing */
res = gst_element_set_state (bin, GST_STATE_PLAYING); state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* create an unconnected sinkpad in adder, should also automatically activate /* create an unconnected sinkpad in adder, should also automatically activate
* the pad */ * the pad */
@ -852,7 +862,6 @@ GST_START_TEST (test_clip)
ret = gst_pad_chain (sinkpad, buffer); ret = gst_pad_chain (sinkpad, buffer);
ck_assert_int_eq (ret, GST_FLOW_OK); ck_assert_int_eq (ret, GST_FLOW_OK);
fail_unless (handoff_buffer == NULL); fail_unless (handoff_buffer == NULL);
} }
GST_END_TEST; GST_END_TEST;