diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2013-05-31 18:13:02 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2013-06-01 21:34:37 +0200 |
commit | 19b23d3b90c0b5094a0132284130fbe243e87566 (patch) | |
tree | d4ef5edac14205c579a73d6b439616172fed4154 | |
parent | db29522a430e44450415ca3676abd1b77ee923d9 (diff) |
level: add a test for continous timestamps
A test that checks that msg[n].ts + msg[n].dur == msg[n+1].ts.
-rw-r--r-- | tests/check/elements/level.c | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/tests/check/elements/level.c b/tests/check/elements/level.c index 0faa3a179..265ee74de 100644 --- a/tests/check/elements/level.c +++ b/tests/check/elements/level.c @@ -397,7 +397,7 @@ GST_START_TEST (test_message_on_eos) GST_END_TEST; -GST_START_TEST (test_message_interval) +GST_START_TEST (test_message_count) { GstElement *level; GstBuffer *inbuffer, *outbuffer; @@ -445,6 +445,61 @@ GST_START_TEST (test_message_interval) GST_END_TEST; +GST_START_TEST (test_message_timestamps) +{ + GstElement *level; + GstBuffer *inbuffer, *outbuffer; + GstBus *bus; + GstMessage *message; + const GstStructure *structure; + GstClockTime ts1, dur1, ts2; + + level = setup_level (); + g_object_set (level, "message", TRUE, "interval", GST_SECOND / 20, NULL); + + fail_unless (gst_element_set_state (level, + GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, + "could not set to playing"); + + /* create a fake 0.1 sec buffer with a half-amplitude block signal */ + inbuffer = create_buffer (16536, 16536); + + /* create a bus to get the level message on */ + bus = gst_bus_new (); + gst_element_set_bus (level, bus); + + /* pushing gives away my reference ... */ + fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); + /* ... but it ends up being collected on the global buffer list */ + fail_unless_equals_int (g_list_length (buffers), 1); + fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); + fail_unless (inbuffer == outbuffer); + + /* check that timestamp + duration is contigous to the next timestamp */ + message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1); + structure = gst_message_get_structure (message); + gst_structure_get_clock_time (structure, "timestamp", &ts1); + gst_structure_get_clock_time (structure, "duration", &dur1); + gst_message_unref (message); + + message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1); + structure = gst_message_get_structure (message); + gst_structure_get_clock_time (structure, "timestamp", &ts2); + gst_message_unref (message); + + fail_unless_equals_int64 (ts1 + dur1, ts2); + + gst_element_set_bus (level, NULL); + ASSERT_OBJECT_REFCOUNT (bus, "bus", 1); + gst_object_unref (bus); + gst_buffer_unref (outbuffer); + fail_unless (gst_element_set_state (level, + GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); + ASSERT_OBJECT_REFCOUNT (level, "level", 1); + cleanup_level (level); +} + +GST_END_TEST; static Suite * level_suite (void) @@ -456,7 +511,8 @@ level_suite (void) tcase_add_test (tc_chain, test_int16); tcase_add_test (tc_chain, test_int16_panned); tcase_add_test (tc_chain, test_message_on_eos); - tcase_add_test (tc_chain, test_message_interval); + tcase_add_test (tc_chain, test_message_count); + tcase_add_test (tc_chain, test_message_timestamps); return s; } |