Ziqing Hui : windowscodecs/tests: Add tests for DdsFrameDecode_Dds_GetFormatInfo().

Alexandre Julliard julliard at winehq.org
Mon Jun 1 15:14:56 CDT 2020


Module: wine
Branch: master
Commit: febf29ba9d1590042631c408c786e2c4823fe3f3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=febf29ba9d1590042631c408c786e2c4823fe3f3

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Mon Jun  1 12:59:07 2020 +0800

windowscodecs/tests: Add tests for DdsFrameDecode_Dds_GetFormatInfo().

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Esme Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windowscodecs/tests/ddsformat.c | 55 +++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)

diff --git a/dlls/windowscodecs/tests/ddsformat.c b/dlls/windowscodecs/tests/ddsformat.c
index be7bb0a0e6..32ea1e2774 100644
--- a/dlls/windowscodecs/tests/ddsformat.c
+++ b/dlls/windowscodecs/tests/ddsformat.c
@@ -192,6 +192,26 @@ static HRESULT init_decoder(IWICBitmapDecoder *decoder, IWICStream *stream, HRES
     return hr;
 }
 
+static UINT get_bytes_per_block(DXGI_FORMAT format)
+{
+    switch(format)
+    {
+    case DXGI_FORMAT_BC1_UNORM:
+    case DXGI_FORMAT_BC1_TYPELESS:
+    case DXGI_FORMAT_BC1_UNORM_SRGB:
+        return 8;
+    case DXGI_FORMAT_BC2_UNORM:
+    case DXGI_FORMAT_BC2_TYPELESS:
+    case DXGI_FORMAT_BC2_UNORM_SRGB:
+    case DXGI_FORMAT_BC3_UNORM:
+    case DXGI_FORMAT_BC3_TYPELESS:
+    case DXGI_FORMAT_BC3_UNORM_SRGB:
+        return 16;
+    default:
+        return 0;
+    }
+}
+
 static void test_dds_decoder_initialize(void)
 {
     static BYTE test_dds_bad_magic[sizeof(test_dds_image)];
@@ -367,21 +387,28 @@ static void test_dds_decoder_image_parameters(void)
     }
 }
 
-static void test_dds_decoder_frame_size(IWICBitmapDecoder *decoder, IWICBitmapFrameDecode *frame_decode,
-                                        UINT frame_count, int i, int frame_index)
+static void test_dds_decoder_frame_properties(IWICBitmapDecoder *decoder, IWICBitmapFrameDecode *frame_decode,
+                                              UINT frame_count, int i, int frame_index)
 {
     HRESULT hr;
     WICDdsParameters params;
-    IWICDdsDecoder *dds_decoder;
+    IWICDdsDecoder *dds_decoder = NULL;
+    IWICDdsFrameDecode *dds_frame = NULL;
     UINT width, height ,expected_width, expected_height, slice_index, depth;
+    WICDdsFormatInfo format_info;
 
     hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICDdsDecoder, (void **)&dds_decoder);
     ok(hr == S_OK, "%d: QueryInterface failed, hr=%x\n", i, hr);
     if (hr != S_OK) goto end;
+    hr = IWICBitmapFrameDecode_QueryInterface(frame_decode, &IID_IWICDdsFrameDecode, (void **)&dds_frame);
+    ok(hr == S_OK, "%d: [frame %d] QueryInterface failed, hr=%x\n", i, frame_index, hr);
+    if (hr != S_OK) goto end;
     hr = IWICDdsDecoder_GetParameters(dds_decoder, &params);
     ok (hr == S_OK, "%d: GetParameters failed, hr=%x\n", i, hr);
     if (hr != S_OK) goto end;
 
+    /* frame size tests */
+
     hr = IWICBitmapFrameDecode_GetSize(frame_decode, NULL, NULL);
     ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
     hr = IWICBitmapFrameDecode_GetSize(frame_decode, NULL, &height);
@@ -406,8 +433,28 @@ static void test_dds_decoder_frame_size(IWICBitmapDecoder *decoder, IWICBitmapFr
     ok (width == expected_width, "%d: Expected width %d for frame %d, got %d\n", i, expected_width, frame_index, width);
     ok (height == expected_height, "%d: Expected height %d for frame %d, got %d\n", i, expected_height, frame_index, height);
 
+    /* frame format information tests */
+
+    hr = IWICDdsFrameDecode_GetFormatInfo(dds_frame, NULL);
+    todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
+    hr = IWICDdsFrameDecode_GetFormatInfo(dds_frame, &format_info);
+    todo_wine ok (hr == S_OK, "%d: [frame %d] GetFormatInfo failed, hr=%x\n", i, frame_index, hr);
+    if (hr != S_OK) goto end;
+
+    ok (format_info.DxgiFormat == test_data[i].expected_parameters.DxgiFormat,
+        "%d: [frame %d] Expected DXGI format 0x%x, got 0x%x\n",
+        i, frame_index, test_data[i].expected_parameters.DxgiFormat, format_info.DxgiFormat);
+    ok (format_info.BytesPerBlock == get_bytes_per_block(format_info.DxgiFormat),
+        "%d: [frame %d] Expected bytes per block %d, got %d\n",
+        i, frame_index, get_bytes_per_block(format_info.DxgiFormat), format_info.BytesPerBlock);
+    ok (format_info.BlockWidth == 4 || format_info.BlockWidth == 1,
+        "%d: [frame %d] Got unexpected block width %d\n", i, frame_index, format_info.BlockWidth);
+    ok (format_info.BlockHeight == 4 || format_info.BlockHeight == 1,
+        "%d: [frame %d] Got unexpected block height %d\n", i, frame_index, format_info.BlockHeight);
+
 end:
     if (dds_decoder) IWICDdsDecoder_Release(dds_decoder);
+    if (dds_frame) IWICDdsFrameDecode_Release(dds_frame);
 }
 
 static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)
@@ -430,7 +477,7 @@ static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)
             continue;
         }
 
-        test_dds_decoder_frame_size(decoder, frame_decode, frame_count, i, j);
+        test_dds_decoder_frame_properties(decoder, frame_decode, frame_count, i, j);
     }
 }
 




More information about the wine-cvs mailing list