Module: wine Branch: master Commit: e51a70748797726f91368f817673be8ea8f01d4e URL: https://source.winehq.org/git/wine.git/?a=commit;h=e51a70748797726f91368f817...
Author: Ziqing Hui zhui@codeweavers.com Date: Tue Jun 9 12:28:41 2020 +0800
windowscodecs/tests: Add more tests for DdsFrameDecode_Dds_CopyBlocks() when "boundsInBlocks" is NULL.
The added tests shows that when boundsInBlocks parameter is NULL, stride parameter will be checked to ensure it is bigger or equal to frame stride, but it will be ignored in the call. This can be proved by:
* CopyBlocks(NULL, frame_stride - 1, sizeof(buffer), buffer) return error.
* CopyBlocks(NULL, frame_stride, sizeof(buffer), buffer) and CopyBlocks(NULL, frame_stride * 2, sizeof(buffer), buffer) works fine and result in same buffer content.
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Esme Povirk vincent@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/windowscodecs/tests/ddsformat.c | 37 +++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
diff --git a/dlls/windowscodecs/tests/ddsformat.c b/dlls/windowscodecs/tests/ddsformat.c index a7fd8c1973..d718a07f96 100644 --- a/dlls/windowscodecs/tests/ddsformat.c +++ b/dlls/windowscodecs/tests/ddsformat.c @@ -521,7 +521,7 @@ static void test_dds_decoder_frame_data(IWICDdsFrameDecode *dds_frame, UINT fram WICRect rect = { 0, 0, 1, 1 }, rect_test_a = { 0, 0, 0, 0 }, rect_test_b = { 0, 0, 0xdeadbeaf, 0xdeadbeaf }; WICRect rect_test_c = { -0xdeadbeaf, -0xdeadbeaf, 1, 1 }, rect_test_d = { 0xdeadbeaf, 0xdeadbeaf, 1, 1 }; BYTE buffer[256]; - UINT stride, frame_stride, width_in_blocks, height_in_blocks; + UINT stride, frame_stride, frame_size, width_in_blocks, height_in_blocks; UINT width, height, depth, array_index; UINT block_offset; int slice_index; @@ -534,6 +534,10 @@ static void test_dds_decoder_frame_data(IWICDdsFrameDecode *dds_frame, UINT fram if (hr != S_OK) return; stride = rect.Width * format_info.BytesPerBlock; frame_stride = width_in_blocks * format_info.BytesPerBlock; + frame_size = frame_stride * height_in_blocks; + + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, 0, 0, NULL); + todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, &rect_test_a, stride, sizeof(buffer), buffer); todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); @@ -543,8 +547,17 @@ static void test_dds_decoder_frame_data(IWICDdsFrameDecode *dds_frame, UINT fram todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, &rect_test_d, stride, sizeof(buffer), buffer); todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); + + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride - 1, sizeof(buffer), buffer); + todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride * 2, sizeof(buffer), buffer); + todo_wine ok (hr == S_OK, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride, sizeof(buffer), buffer); todo_wine ok (hr == S_OK, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride, frame_stride * height_in_blocks - 1, buffer); + todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride, frame_stride * height_in_blocks, buffer); + todo_wine ok (hr == S_OK, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, &rect, 0, sizeof(buffer), buffer); todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); @@ -565,12 +578,6 @@ static void test_dds_decoder_frame_data(IWICDdsFrameDecode *dds_frame, UINT fram hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, &rect, stride, sizeof(buffer), NULL); todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
- hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, 0, 0, NULL); - todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr); - hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, &rect, stride, sizeof(buffer), buffer); - todo_wine ok (hr == S_OK, "%d: [frame %d] CopyBlocks failed, hr=%x\n", i, frame_index, hr); - if (hr != S_OK) return; - block_offset = 128; /* DDS magic and header */ if (has_extended_header(test_data[i].data)) block_offset += 20; /* DDS extended header */ width = params->Width; @@ -591,8 +598,24 @@ static void test_dds_decoder_frame_data(IWICDdsFrameDecode *dds_frame, UINT fram slice_index -= depth; if (depth > 1) depth /= 2; } + + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, &rect, stride, sizeof(buffer), buffer); + todo_wine ok (hr == S_OK, "%d: [frame %d] CopyBlocks failed, hr=%x\n", i, frame_index, hr); + if (hr != S_OK) return; ok (!strncmp((const char *)test_data[i].data + block_offset, (const char *)buffer, format_info.BytesPerBlock), "%d: [frame %d] Block data mismatch\n", i, frame_index); + + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride, sizeof(buffer), buffer); + todo_wine ok (hr == S_OK, "%d: [frame %d] CopyBlocks failed, hr=%x\n", i, frame_index, hr); + if (hr != S_OK) return; + ok (!strncmp((const char *)test_data[i].data + block_offset, (const char *)buffer, frame_size), + "%d: [frame %d] Block data mismatch\n", i, frame_index); + + hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, frame_stride * 2, sizeof(buffer), buffer); + todo_wine ok (hr == S_OK, "%d: [frame %d] CopyBlocks failed, hr=%x\n", i, frame_index, hr); + if (hr != S_OK) return; + ok (!strncmp((const char *)test_data[i].data + block_offset, (const char *)buffer, frame_size), + "%d: [frame %d] Block data mismatch\n", i, frame_index); }
static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)