From: Stefan Sauer Date: Mon, 16 Jul 2012 06:37:33 +0000 (+0200) Subject: adder: cleanup test X-Git-Tag: 1.19.3~511^2~6200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff120f6aa957e7c43e4b65df3a65e47542b3a4cf;p=platform%2Fupstream%2Fgstreamer.git adder: cleanup test Use right type for StateChangeReturn and avoid needless G_OBJECT casts. --- diff --git a/tests/check/elements/adder.c b/tests/check/elements/adder.c index 727ed0d..9fd3a35 100644 --- a/tests/check/elements/adder.c +++ b/tests/check/elements/adder.c @@ -100,6 +100,7 @@ GST_START_TEST (test_event) GstElement *bin, *src1, *src2, *adder, *sink; GstBus *bus; GstEvent *seek_event; + GstStateChangeReturn state_res; gboolean res; GstPad *srcpad, *sinkpad; GstStreamConsistency *chk_1, *chk_2, *chk_3; @@ -163,25 +164,25 @@ GST_START_TEST (test_event) GST_INFO ("starting test"); /* prepare playing */ - res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion */ - res = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); res = gst_element_send_event (bin, seek_event); fail_unless (res == TRUE, NULL); /* run pipeline */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); GST_INFO ("running main loop"); g_main_loop_run (main_loop); - res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); 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_2); gst_consistency_checker_free (chk_3); - gst_object_unref (G_OBJECT (bus)); - gst_object_unref (G_OBJECT (bin)); + gst_object_unref (bus); + gst_object_unref (bin); } GST_END_TEST; @@ -204,6 +205,7 @@ test_play_twice_message_received (GstBus * bus, GstMessage * message, GstPipeline * bin) { gboolean res; + GstStateChangeReturn state_res; GST_INFO ("bus message from \"%" GST_PTR_FORMAT "\": %" GST_PTR_FORMAT, GST_MESSAGE_SRC (message), message); @@ -212,25 +214,26 @@ test_play_twice_message_received (GstBus * bus, GstMessage * message, case GST_MESSAGE_SEGMENT_DONE: play_count++; if (play_count == 1) { - res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* prepare playing again */ - res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion */ - res = + state_res = gst_element_get_state (GST_ELEMENT (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 (GST_ELEMENT (bin), gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); - res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); } else { g_main_loop_quit (main_loop); } @@ -247,6 +250,7 @@ GST_START_TEST (test_play_twice) GstElement *bin, *src1, *src2, *adder, *sink; GstBus *bus; gboolean res; + GstStateChangeReturn state_res; GstPad *srcpad; GstStreamConsistency *consist; @@ -293,14 +297,14 @@ GST_START_TEST (test_play_twice) GST_INFO ("starting test"); /* prepare playing */ - res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion */ - res = + state_res = gst_element_get_state (GST_ELEMENT (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, gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); @@ -308,13 +312,13 @@ GST_START_TEST (test_play_twice) GST_INFO ("seeked"); /* run pipeline */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); g_main_loop_run (main_loop); - res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); ck_assert_int_eq (play_count, 2); @@ -322,8 +326,8 @@ GST_START_TEST (test_play_twice) g_main_loop_unref (main_loop); gst_consistency_checker_free (consist); gst_event_ref (play_seek_event); - gst_object_unref (G_OBJECT (bus)); - gst_object_unref (G_OBJECT (bin)); + gst_object_unref (bus); + gst_object_unref (bin); } 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; GstBus *bus; gboolean res; + GstStateChangeReturn state_res; gint i; GstPad *srcpad; GstStreamConsistency *consist; @@ -382,14 +387,14 @@ GST_START_TEST (test_play_twice_then_add_and_play_again) GST_INFO ("starting test-loop %d", i); /* prepare playing */ - res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion */ - res = + state_res = gst_element_get_state (GST_ELEMENT (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, gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); @@ -397,13 +402,13 @@ GST_START_TEST (test_play_twice_then_add_and_play_again) GST_INFO ("seeked"); /* run pipeline */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); g_main_loop_run (main_loop); - res = gst_element_set_state (bin, GST_STATE_READY); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_READY); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); 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); } - res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* cleanup */ g_main_loop_unref (main_loop); gst_event_ref (play_seek_event); gst_consistency_checker_free (consist); - gst_object_unref (G_OBJECT (bus)); - gst_object_unref (G_OBJECT (bin)); + gst_object_unref (bus); + gst_object_unref (bin); } GST_END_TEST; @@ -458,6 +463,7 @@ GST_START_TEST (test_live_seeking) GstElement *bin, *src1, *src2, *ac1, *ac2, *adder, *sink; GstBus *bus; gboolean res; + GstStateChangeReturn state_res; GstPad *srcpad; gint i; GstStreamConsistency *consist; @@ -482,11 +488,11 @@ GST_START_TEST (test_live_seeking) goto cleanup; } /* 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); gst_object_unref (src1); - if (res == GST_STATE_CHANGE_FAILURE) + if (state_res == GST_STATE_CHANGE_FAILURE) goto cleanup; src1 = gst_element_factory_make ("alsasrc", "src1"); @@ -536,14 +542,14 @@ GST_START_TEST (test_live_seeking) GST_INFO ("starting test-loop %d", i); /* prepare playing */ - res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion */ - res = + state_res = gst_element_get_state (GST_ELEMENT (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, gst_event_ref (play_seek_event)); #if 1 @@ -556,15 +562,15 @@ GST_START_TEST (test_live_seeking) GST_INFO ("seeked"); /* run pipeline */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); GST_INFO ("playing"); g_main_loop_run (main_loop); - res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); gst_consistency_checker_reset (consist); } @@ -576,8 +582,8 @@ cleanup: g_main_loop_unref (main_loop); if (play_seek_event) gst_event_unref (play_seek_event); - gst_object_unref (G_OBJECT (bus)); - gst_object_unref (G_OBJECT (bin)); + gst_object_unref (bus); + gst_object_unref (bin); } GST_END_TEST; @@ -589,6 +595,7 @@ GST_START_TEST (test_add_pad) GstBus *bus; GstPad *srcpad; gboolean res; + GstStateChangeReturn state_res; GST_INFO ("preparing test"); @@ -626,14 +633,14 @@ GST_START_TEST (test_add_pad) GST_INFO ("starting test"); /* prepare playing */ - res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion */ - res = + state_res = gst_element_get_state (GST_ELEMENT (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); /* add other element */ gst_bin_add_many (GST_BIN (bin), src2, NULL); @@ -643,21 +650,22 @@ GST_START_TEST (test_add_pad) fail_unless (res == TRUE, NULL); /* 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 */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); g_main_loop_run (main_loop); - res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* cleanup */ g_main_loop_unref (main_loop); - gst_object_unref (G_OBJECT (bus)); - gst_object_unref (G_OBJECT (bin)); + gst_object_unref (bus); + gst_object_unref (bin); } GST_END_TEST; @@ -669,6 +677,7 @@ GST_START_TEST (test_remove_pad) GstBus *bus; GstPad *pad, *srcpad; gboolean res; + GstStateChangeReturn state_res; GST_INFO ("preparing test"); @@ -707,12 +716,12 @@ GST_START_TEST (test_remove_pad) /* prepare playing, this will not preroll as adder is waiting * on the unconnected sinkpad. */ - res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PAUSED); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for completion for one second, will return ASYNC */ - res = gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, GST_SECOND); - ck_assert_int_eq (res, GST_STATE_CHANGE_ASYNC); + state_res = gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, GST_SECOND); + ck_assert_int_eq (state_res, GST_STATE_CHANGE_ASYNC); /* get rid of the pad now, adder should stop waiting on it and * continue the preroll */ @@ -720,19 +729,19 @@ GST_START_TEST (test_remove_pad) gst_object_unref (pad); /* wait for completion, should work now */ - res = + state_res = gst_element_get_state (GST_ELEMENT (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); /* now play all */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); g_main_loop_run (main_loop); - res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* cleanup */ g_main_loop_unref (main_loop); @@ -760,6 +769,7 @@ GST_START_TEST (test_clip) GstBus *bus; GstPad *sinkpad; gboolean res; + GstStateChangeReturn state_res; GstFlowReturn ret; GstEvent *event; GstBuffer *buffer; @@ -787,8 +797,8 @@ GST_START_TEST (test_clip) fail_unless (res == TRUE, NULL); /* set to playing */ - res = gst_element_set_state (bin, GST_STATE_PLAYING); - ck_assert_int_ne (res, GST_STATE_CHANGE_FAILURE); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* create an unconnected sinkpad in adder, should also automatically activate * the pad */ @@ -852,7 +862,6 @@ GST_START_TEST (test_clip) ret = gst_pad_chain (sinkpad, buffer); ck_assert_int_eq (ret, GST_FLOW_OK); fail_unless (handoff_buffer == NULL); - } GST_END_TEST;