[PATCH 4/4] ddraw/tests: Rewrite SetRenderState() tests.
Józef Kucia
jkucia at codeweavers.com
Thu Jan 11 08:33:33 CST 2018
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/ddraw/tests/d3d.c | 30 ------------------------------
dlls/ddraw/tests/ddraw2.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 39 +++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 41 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 124 insertions(+), 30 deletions(-)
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index 205a4c6994c6..77836fd627ef 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -411,18 +411,6 @@ static void LightTest(void)
}
}
-static void StateTest( void )
-{
- HRESULT rc;
-
- /* The msdn says it's undocumented, does it return an error too? */
- rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, TRUE);
- ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, TRUE) returned %08x\n", rc);
- rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, FALSE);
- ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, FALSE) returned %08x\n", rc);
-}
-
-
static void SceneTest(void)
{
HRESULT hr;
@@ -1416,22 +1404,6 @@ out:
IDirect3DVertexBuffer7_Release(lpVBufSrc);
}
-static void D3D7_OldRenderStateTest(void)
-{
- HRESULT hr;
- DWORD val;
-
- /* Test reaction to some deprecated states in D3D7. */
- hr = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREHANDLE, 0);
- ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_SetRenderState returned %#x.\n", hr);
- hr = IDirect3DDevice7_GetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREHANDLE, &val);
- ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_GetRenderState returned %#x.\n", hr);
- hr = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
- ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_SetRenderState returned %#x.\n", hr);
- hr = IDirect3DDevice7_GetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, &val);
- ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_GetRenderState returned %#x.\n", hr);
-}
-
#define IS_VALUE_NEAR(a, b) ( ((a) == (b)) || ((a) == (b) - 1) || ((a) == (b) + 1) )
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -3444,14 +3416,12 @@ START_TEST(d3d)
skip("Skipping d3d7 tests\n");
} else {
LightTest();
- StateTest();
SceneTest();
D3D7EnumTest();
D3D7EnumLifetimeTest();
SetMaterialTest();
CapsTest();
VertexBufferDescTest();
- D3D7_OldRenderStateTest();
DeviceLoadTest();
SetRenderTargetTest();
VertexBufferLockRest();
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 21b2905e07bb..df1318b59d15 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -12153,6 +12153,49 @@ done:
DestroyWindow(window);
}
+static void test_set_render_state(void)
+{
+ IDirect3DDevice2 *device;
+ IDirectDraw2 *ddraw;
+ ULONG refcount;
+ HWND window;
+ DWORD state;
+ HRESULT hr;
+
+ window = create_window();
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create 3D device.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ state = 0xdeadbeef;
+ hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(!state, "Got unexpected render state %#x.\n", state);
+ hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state);
+
+ refcount = IDirect3DDevice2_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ refcount = IDirectDraw2_Release(ddraw);
+ ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_depth_readback(void)
{
DWORD depth, expected_depth, max_diff;
@@ -12684,6 +12727,7 @@ START_TEST(ddraw2)
test_display_mode_surface_pixel_format();
test_surface_desc_size();
test_ck_operation();
+ test_set_render_state();
test_depth_readback();
test_clear();
test_enum_surfaces();
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 1e4a55cbe27b..6d2f96eac7b1 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -14064,6 +14064,44 @@ static void test_texture_stages_limits(void)
DestroyWindow(window);
}
+static void test_set_render_state(void)
+{
+ IDirect3DDevice3 *device;
+ ULONG refcount;
+ HWND window;
+ DWORD state;
+ HRESULT hr;
+
+ window = create_window();
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create 3D device.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ state = 0xdeadbeef;
+ hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(!state, "Got unexpected render state %#x.\n", state);
+ hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state);
+
+ refcount = IDirect3DDevice3_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_map_synchronisation(void)
{
LARGE_INTEGER frequency, diff, ts[3];
@@ -14806,6 +14844,7 @@ START_TEST(ddraw4)
test_vb_refcount();
test_compute_sphere_visibility();
test_texture_stages_limits();
+ test_set_render_state();
test_map_synchronisation();
test_depth_readback();
test_clear();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index e1b387fc574e..745245a7e418 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -13436,6 +13436,46 @@ static void test_texture_stages_limits(void)
DestroyWindow(window);
}
+static void test_set_render_state(void)
+{
+ IDirect3DDevice7 *device;
+ ULONG refcount;
+ HWND window;
+ DWORD state;
+ HRESULT hr;
+
+ window = create_window();
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create 3D device.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ /* States deprecated in D3D7 */
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ state = 0xdeadbeef;
+ hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ state = 0xdeadbeef;
+ hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state);
+
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_map_synchronisation(void)
{
LARGE_INTEGER frequency, diff, ts[3];
@@ -14144,6 +14184,7 @@ START_TEST(ddraw7)
test_compute_sphere_visibility();
test_clip_planes_limits();
test_texture_stages_limits();
+ test_set_render_state();
test_map_synchronisation();
test_depth_readback();
test_clear();
--
2.13.6
More information about the wine-devel
mailing list