summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2017-10-14 18:18:44 +0200
committerTim-Philipp Müller <tim@centricular.com>2017-12-02 15:10:27 +0000
commit00d6f46ff896424d7743bb3832518da36f8a9b20 (patch)
tree0b82b1c31b30db81c0055c20034be43a3ca69dc6
parentfbe82b7fa1c4f2036626f4a38d70714bfb20c571 (diff)
aggregator: add two more tests for a sequence of data
This verifies that we handle events and queries at the head of the queue and then buffers.
-rw-r--r--tests/check/libs/aggregator.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/check/libs/aggregator.c b/tests/check/libs/aggregator.c
index 24d7a9594..28a0c46fe 100644
--- a/tests/check/libs/aggregator.c
+++ b/tests/check/libs/aggregator.c
@@ -317,6 +317,7 @@ _quit (GMainLoop * ml)
static GstPadProbeReturn
_aggregated_cb (GstPad * pad, GstPadProbeInfo * info, GMainLoop * ml)
{
+ GST_DEBUG ("Received data %" GST_PTR_FORMAT, info->data);
GST_DEBUG ("Should quit ML");
g_idle_add ((GSourceFunc) _quit, ml);
@@ -538,6 +539,69 @@ GST_START_TEST (test_aggregate_gap)
GST_END_TEST;
+GST_START_TEST (test_aggregate_handle_events)
+{
+ GThread *thread1, *thread2;
+ ChainData data1 = { 0, };
+ ChainData data2 = { 0, };
+ TestData test = { 0, };
+
+ _test_data_init (&test, FALSE);
+ _chain_data_init (&data1, test.aggregator,
+ gst_event_new_tag (gst_tag_list_new_empty ()), gst_buffer_new (), NULL);
+ _chain_data_init (&data2, test.aggregator, gst_buffer_new (), NULL);
+
+ thread1 = g_thread_try_new ("gst-check", push_data, &data1, NULL);
+ thread2 = g_thread_try_new ("gst-check", push_data, &data2, NULL);
+
+ g_main_loop_run (test.ml);
+ g_source_remove (test.timeout_id);
+
+ /* these will return immediately as when the data is popped the threads are
+ * unlocked and will terminate */
+ g_thread_join (thread1);
+ g_thread_join (thread2);
+
+ _chain_data_clear (&data1);
+ _chain_data_clear (&data2);
+ _test_data_clear (&test);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_aggregate_handle_queries)
+{
+ GThread *thread1, *thread2;
+ ChainData data1 = { 0, };
+ ChainData data2 = { 0, };
+ TestData test = { 0, };
+
+ _test_data_init (&test, FALSE);
+ _chain_data_init (&data1, test.aggregator,
+ gst_query_new_allocation (gst_caps_new_empty_simple ("foo/x-bar"), FALSE),
+ gst_buffer_new (), NULL);
+ _chain_data_init (&data2, test.aggregator, gst_buffer_new (), NULL);
+
+ thread1 = g_thread_try_new ("gst-check", push_data, &data1, NULL);
+ thread2 = g_thread_try_new ("gst-check", push_data, &data2, NULL);
+
+ g_main_loop_run (test.ml);
+ g_source_remove (test.timeout_id);
+
+ /* these will return immediately as when the data is popped the threads are
+ * unlocked and will terminate */
+ g_thread_join (thread1);
+ g_thread_join (thread2);
+
+ // FIXME: need to make sure all data was aggregated
+
+ _chain_data_clear (&data1);
+ _chain_data_clear (&data2);
+ _test_data_clear (&test);
+}
+
+GST_END_TEST;
+
#define NUM_BUFFERS 3
static void
handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
@@ -1190,6 +1254,8 @@ gst_aggregator_suite (void)
tcase_add_test (general, test_aggregate);
tcase_add_test (general, test_aggregate_eos);
tcase_add_test (general, test_aggregate_gap);
+ tcase_add_test (general, test_aggregate_handle_events);
+ tcase_add_test (general, test_aggregate_handle_queries);
tcase_add_test (general, test_flushing_seek);
tcase_add_test (general, test_infinite_seek);
tcase_add_test (general, test_infinite_seek_50_src);