summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon.ko@samsung.com>2015-07-08 20:06:27 +0900
committerSebastian Dröge <sebastian@centricular.com>2015-07-08 18:58:52 +0300
commit9338f93494c96f810c3abe1b478b59066397275a (patch)
tree82b054ebaff08cf69c2e61f9571911c0689c693b
parentea8cabe084e9f287ebe808c16ba4761c086391c6 (diff)
adapter: unit test for new get_(buffer_)list
-rw-r--r--tests/check/libs/adapter.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/check/libs/adapter.c b/tests/check/libs/adapter.c
index 5794aa8a7..95d295280 100644
--- a/tests/check/libs/adapter.c
+++ b/tests/check/libs/adapter.c
@@ -807,6 +807,53 @@ GST_START_TEST (test_take_list)
GST_END_TEST;
+/* Fill a buffer with a sequence of 32 bit ints and read a couple of front
+ * buffers using get_buffer, checking that they're still in the right order */
+GST_START_TEST (test_get_list)
+{
+ GstAdapter *adapter;
+ int i = 0;
+ gsize size = 0;
+ GList *list, *walk;
+ GstBuffer *buf;
+ gsize left;
+ GstMapInfo info;
+ guint8 *ptr;
+
+ adapter = create_and_fill_adapter ();
+ size = gst_adapter_available (adapter);
+
+ list = gst_adapter_get_list (adapter, sizeof (guint32) * 5);
+ fail_unless (list != NULL);
+
+ for (walk = list; walk; walk = g_list_next (walk)) {
+ buf = walk->data;
+
+ fail_unless (gst_buffer_map (buf, &info, GST_MAP_READ));
+
+ ptr = info.data;
+ left = info.size;
+
+ while (left > 0) {
+ fail_unless (GST_READ_UINT32_LE (ptr) == i);
+ i++;
+ ptr += sizeof (guint32);
+ left -= sizeof (guint32);
+ }
+ gst_buffer_unmap (buf, &info);
+
+ gst_buffer_unref (buf);
+ }
+ g_list_free (list);
+
+ fail_unless (gst_adapter_available (adapter) == size,
+ "All data should remain in the adapter");
+
+ g_object_unref (adapter);
+}
+
+GST_END_TEST;
+
/* Fill a buffer with a sequence of 32 bit ints and read them back out
* using take_buffer, checking that they're still in the right order */
GST_START_TEST (test_take_buffer_list)
@@ -854,6 +901,55 @@ GST_START_TEST (test_take_buffer_list)
GST_END_TEST;
+/* Fill a buffer with a sequence of 32 bit ints and read a couple of front
+ * buffers using get_buffer, checking that they're still in the right order */
+GST_START_TEST (test_get_buffer_list)
+{
+ GstAdapter *adapter;
+ int i = 0;
+ gsize size = 0;
+ GstBufferList *buffer_list;
+ GstBuffer *buf;
+ gsize left;
+ GstMapInfo info;
+ guint8 *ptr;
+ guint n, num;
+
+ adapter = create_and_fill_adapter ();
+ size = gst_adapter_available (adapter);
+
+ buffer_list = gst_adapter_get_buffer_list (adapter, sizeof (guint32) * 5);
+ fail_unless (buffer_list != NULL);
+
+ num = gst_buffer_list_length (buffer_list);
+ fail_unless (num > 0);
+
+ for (n = 0; n < num; ++n) {
+ buf = gst_buffer_list_get (buffer_list, n);
+
+ fail_unless (gst_buffer_map (buf, &info, GST_MAP_READ));
+
+ ptr = info.data;
+ left = info.size;
+
+ while (left > 0) {
+ fail_unless (GST_READ_UINT32_LE (ptr) == i);
+ i++;
+ ptr += sizeof (guint32);
+ left -= sizeof (guint32);
+ }
+ gst_buffer_unmap (buf, &info);
+ }
+ gst_buffer_list_unref (buffer_list);
+
+ fail_unless (gst_adapter_available (adapter) == size,
+ "All data should remain in the adapter");
+
+ g_object_unref (adapter);
+}
+
+GST_END_TEST;
+
GST_START_TEST (test_merge)
{
GstAdapter *adapter;
@@ -963,7 +1059,9 @@ gst_adapter_suite (void)
tcase_add_test (tc_chain, test_timestamp);
tcase_add_test (tc_chain, test_scan);
tcase_add_test (tc_chain, test_take_list);
+ tcase_add_test (tc_chain, test_get_list);
tcase_add_test (tc_chain, test_take_buffer_list);
+ tcase_add_test (tc_chain, test_get_buffer_list);
tcase_add_test (tc_chain, test_merge);
tcase_add_test (tc_chain, test_take_buffer_fast);