[PATCH 1/2] d3dx9_36/tests: Add D3DXSaveSurfaceToFileInMemory D3DXIFF_DDS tests (try 3)

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Dec 8 22:35:25 CST 2015


Also updates the structure dds_header to be the same as d3dx9_36/surface.c.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/d3dx9_36/tests/surface.c | 45 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 1697a03..eaab0f74 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -211,7 +211,9 @@ struct dds_header
     struct dds_pixel_format pixel_format;
     DWORD caps;
     DWORD caps2;
-    DWORD reserved2[3];
+    DWORD caps3;
+    DWORD caps4;
+    DWORD reserved2;
 };
 
 /* fills dds_header with reasonable default values */
@@ -1231,6 +1233,8 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
     RECT rect;
     ID3DXBuffer *buffer;
     IDirect3DSurface9 *surface;
+    struct dds_header *header;
+#define BROKEN_CAPS (DDS_CAPS_TEXTURE | 0x02)
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
     if (FAILED(hr)) {
@@ -1248,6 +1252,45 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
         ID3DXBuffer_Release(buffer);
     }
 
+    SetRectEmpty(&rect);
+    hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_DDS, surface, NULL, &rect);
+    todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x\n", hr);
+    if (SUCCEEDED(hr))
+    {
+        header = ID3DXBuffer_GetBufferPointer(buffer);
+
+        ok(header->magic == MAKEFOURCC('D','D','S',' '), "Invalid DDS signature.\n");
+        ok(header->size == 124, "Invalid DDS size %u.\n", header->size);
+        ok(!header->height, "Got unexpected height %u.\n", header->height);
+        ok(!header->width, "Got unexpected width %u.\n", header->width);
+        ok(!header->depth, "Got unexpected depth %u.\n", header->depth);
+        ok(!header->miplevels, "Got unexpected miplevels %u.\n", header->miplevels);
+        ok(!header->pitch_or_linear_size, "Got unexpected pitch_or_linear_size %u.\n", header->pitch_or_linear_size);
+        ok(header->caps == DDS_CAPS_TEXTURE || broken(header->caps == BROKEN_CAPS),
+            "Got unexpected caps %x.\n", header->caps);
+        ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
+                "Got unexpected flags %x.\n", header->flags);
+        ID3DXBuffer_Release(buffer);
+    }
+
+    hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_DDS, surface, NULL, NULL);
+    ok(hr == D3D_OK, "Got unexpected hr %#x\n", hr);
+    header = ID3DXBuffer_GetBufferPointer(buffer);
+
+    ok(header->magic == MAKEFOURCC('D','D','S',' '), "Invalid DDS signature.\n");
+    todo_wine ok(header->size == 124, "Invalid DDS size %u.\n", header->size);
+    ok(header->height == 4, "Got unexpected height %u.\n", header->height);
+    ok(header->width == 4, "Got unexpected width %u.\n", header->width);
+    todo_wine ok(!header->depth, "Got unexpected depth %u.\n", header->depth);
+    todo_wine ok(!header->miplevels, "Got unexpected miplevels %u.\n", header->miplevels);
+    todo_wine ok(!header->pitch_or_linear_size, "Got unexpected pitch_or_linear_size %u.\n", header->pitch_or_linear_size);
+    ok(header->caps == DDS_CAPS_TEXTURE || broken(header->caps == BROKEN_CAPS),
+            "Got unexpected caps %x.\n", header->caps);
+    todo_wine ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
+            "Got unexpected flags %x.\n", header->flags);
+    ID3DXBuffer_Release(buffer);
+
+#undef BROKEN_CAPS
     IDirect3DSurface9_Release(surface);
 }
 
-- 
2.6.2




More information about the wine-patches mailing list