[PATCH 3/4] ddraw/tests: Add some tests for material state and stateblock interaction.

Zebediah Figura z.figura12 at gmail.com
Tue May 7 12:28:31 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ddraw/tests/ddraw7.c | 182 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 182 insertions(+)

diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index eccaf86190..3dca4dc2da 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -16374,6 +16374,187 @@ static void test_viewport_state(void)
     DestroyWindow(window);
 }
 
+static void test_material_state(void)
+{
+    D3DMATERIAL7 material1, material2, material;
+    static const D3DCOLORVALUE null_color;
+    IDirect3DDevice7 *device;
+    DWORD stateblock;
+    ULONG refcount;
+    HWND window;
+    HRESULT hr;
+
+    window = create_window();
+    if (!(device = create_device(window, DDSCL_NORMAL)))
+    {
+        skip("Failed to create 3D device.\n");
+        DestroyWindow(window);
+        return;
+    }
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(SUCCEEDED(hr), "Failed to get material, hr %#x.\n", hr);
+    ok(!memcmp(&U(material).diffuse, &null_color, sizeof(null_color)),
+            "Got unexpected diffuse color {%.8e, %.8e, %.8e, %.8e}.\n",
+            U1(U(material).diffuse).r, U2(U(material).diffuse).g,
+            U3(U(material).diffuse).b, U4(U(material).diffuse).a);
+    ok(!memcmp(&U1(material).ambient, &null_color, sizeof(null_color)),
+            "Got unexpected ambient color {%.8e, %.8e, %.8e, %.8e}.\n",
+            U1(U1(material).ambient).r, U2(U1(material).ambient).g,
+            U3(U1(material).ambient).b, U4(U1(material).ambient).a);
+    ok(!memcmp(&U2(material).specular, &null_color, sizeof(null_color)),
+            "Got unexpected specular color {%.8e, %.8e, %.8e, %.8e}.\n",
+            U1(U2(material).specular).r, U2(U2(material).specular).g,
+            U3(U2(material).specular).b, U4(U2(material).specular).a);
+    ok(!memcmp(&U3(material).emissive, &null_color, sizeof(null_color)),
+            "Got unexpected emissive color {%.8e, %.8e, %.8e, %.8e}.\n",
+            U1(U3(material).emissive).r, U2(U3(material).emissive).g,
+            U3(U3(material).emissive).b, U4(U3(material).emissive).a);
+    ok(U4(material).power == 0.0f, "Got unexpected power %.8e.\n", U4(material).power);
+
+    memset(&material1, 0x11, sizeof(material1));
+    memset(&material2, 0x22, sizeof(material2));
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material1);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n");
+
+    /* Recorded stateblock. */
+
+    hr = IDirect3DDevice7_BeginStateBlock(device);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material2);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_EndStateBlock(device, &stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n");
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n");
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material1);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material2);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n");
+
+    /* Predefined stateblock, D3DSBT_ALL. */
+
+    hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material2);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n");
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material2);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material1);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n");
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material1);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    /* Predefined stateblock, D3DSBT_VERTEXSTATE. */
+
+    hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material2);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n");
+
+    hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material1);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n");
+
+    /* Predefined stateblock, D3DSBT_VERTEXSTATE. */
+
+    hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material2);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material2, sizeof(material2)), "Got unexpected material.\n");
+
+    hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_SetMaterial(device, &material1);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice7_GetMaterial(device, &material);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(&material, &material1, sizeof(material1)), "Got unexpected material.\n");
+
+    refcount = IDirect3DDevice7_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+    DestroyWindow(window);
+}
+
 START_TEST(ddraw7)
 {
     DDDEVICEIDENTIFIER2 identifier;
@@ -16521,4 +16702,5 @@ START_TEST(ddraw7)
     test_begin_end_state_block();
     test_transform_state();
     test_viewport_state();
+    test_material_state();
 }
-- 
2.21.0




More information about the wine-devel mailing list