From: Sebastian Dröge Date: Wed, 19 Jun 2013 08:45:45 +0000 (+0200) Subject: buffer: Add unit test for map_range() X-Git-Tag: 1.1.2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4fc1ba1e603a9bb1522cf97a6466dbbc1673c9e9;p=platform%2Fupstream%2Fgstreamer.git buffer: Add unit test for map_range() https://bugzilla.gnome.org/show_bug.cgi?id=702617 --- diff --git a/tests/check/gst/gstbuffer.c b/tests/check/gst/gstbuffer.c index ec67be8..e3da42c 100644 --- a/tests/check/gst/gstbuffer.c +++ b/tests/check/gst/gstbuffer.c @@ -659,6 +659,55 @@ GST_START_TEST (test_map) GST_END_TEST; +GST_START_TEST (test_map_range) +{ + GstBuffer *buf; + GstMapInfo map; + gsize maxalloc; + gsize size, offset; + + buf = gst_buffer_new (); + gst_buffer_insert_memory (buf, -1, gst_allocator_alloc (NULL, 50, NULL)); + gst_buffer_insert_memory (buf, -1, gst_allocator_alloc (NULL, 50, NULL)); + gst_buffer_insert_memory (buf, -1, gst_allocator_alloc (NULL, 50, NULL)); + + size = gst_buffer_get_sizes (buf, &offset, &maxalloc); + fail_unless (size == 150); + fail_unless (offset == 0); + fail_unless (maxalloc >= 150); + fail_unless (gst_buffer_n_memory (buf) == 3); + + gst_buffer_ref (buf); + /* map should merge */ + gst_buffer_map_range (buf, 1, 2, &map, GST_MAP_READ); + /* merged memory is not stored */ + fail_unless (gst_buffer_n_memory (buf) == 3); + fail_unless (map.size == 100); + gst_buffer_unmap (buf, &map); + + fail_unless (gst_buffer_n_memory (buf) == 3); + + gst_buffer_unref (buf); + + /* map should merge */ + gst_buffer_map_range (buf, 1, 2, &map, GST_MAP_READ); + /* merged memory is stored */ + fail_unless (gst_buffer_n_memory (buf) == 2); + fail_unless (map.size == 100); + gst_buffer_unmap (buf, &map); + + fail_unless (gst_buffer_n_memory (buf) == 2); + + /* should merge and store */ + gst_buffer_map (buf, &map, GST_MAP_READ); + fail_unless (gst_buffer_n_memory (buf) == 1); + gst_buffer_unmap (buf, &map); + + gst_buffer_unref (buf); +} + +GST_END_TEST; + GST_START_TEST (test_find) { GstBuffer *buf; @@ -798,6 +847,7 @@ gst_buffer_suite (void) tcase_add_test (tc_chain, test_size); tcase_add_test (tc_chain, test_resize); tcase_add_test (tc_chain, test_map); + tcase_add_test (tc_chain, test_map_range); tcase_add_test (tc_chain, test_find); tcase_add_test (tc_chain, test_fill);