[PATCH 4/7] ddraw/tests: Add tests for invalid render states.
Józef Kucia
jkucia at codeweavers.com
Wed Jan 27 17:17:49 CST 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
Tested on Windows 7 and 10.
A similar test crashes in ddraw1.
I'm also not sure if this test is safe for ddraw7 as it seems to crash
with higher values.
---
dlls/ddraw/tests/ddraw2.c | 36 ++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 32 ++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 31 +++++++++++++++++++++++++++++++
3 files changed, 99 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 62f1974..0a41d06 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -9307,6 +9307,41 @@ done:
DestroyWindow(window);
}
+static void test_set_render_state(void)
+{
+ IDirect3DDevice2 *device;
+ IDirectDraw2 *ddraw;
+ ULONG refcount;
+ HWND window;
+ DWORD state;
+ HRESULT hr;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device.\n");
+ goto done;
+ }
+
+ for (state = D3DRENDERSTATE_CLIPPLANEENABLE + 1; state <= D3DRENDERSTATE_CLIPPLANEENABLE + 1000; ++state)
+ {
+ HRESULT expected_hr = state >= D3DSTATE_OVERRIDE_BIAS ? DDERR_INVALIDPARAMS : DD_OK;
+ hr = IDirect3DDevice2_SetRenderState(device, state, 0);
+ ok(hr == expected_hr, "Got unexpected hr %#x, state %#x, value 0.\n", hr, state);
+ hr = IDirect3DDevice2_SetRenderState(device, state, 1);
+ ok(hr == expected_hr, "Got unexpected hr %#x, state %#x, value 1.\n", hr, state);
+ }
+
+ refcount = IDirect3DDevice2_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+done:
+ IDirectDraw_Release(ddraw);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
@@ -9387,4 +9422,5 @@ START_TEST(ddraw2)
test_range_colorkey();
test_shademode();
test_lockrect_invalid();
+ test_set_render_state();
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 9239930..650fb5d 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -10482,6 +10482,37 @@ done:
DestroyWindow(window);
}
+static void test_set_render_state(void)
+{
+ IDirect3DDevice3 *device;
+ ULONG refcount;
+ HWND window;
+ DWORD state;
+ HRESULT hr;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ for (state = D3DRENDERSTATE_CLIPPLANEENABLE + 1; state <= D3DRENDERSTATE_CLIPPLANEENABLE + 1000; ++state)
+ {
+ HRESULT expected_hr = state >= D3DSTATE_OVERRIDE_BIAS ? DDERR_INVALIDPARAMS : DD_OK;
+ hr = IDirect3DDevice3_SetRenderState(device, state, 0);
+ ok(hr == expected_hr, "Got unexpected hr %#x, state %#x, value 0.\n", hr, state);
+ hr = IDirect3DDevice3_SetRenderState(device, state, 1);
+ ok(hr == expected_hr, "Got unexpected hr %#x, state %#x, value 1.\n", hr, state);
+ }
+
+ refcount = IDirect3DDevice3_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
@@ -10569,4 +10600,5 @@ START_TEST(ddraw4)
test_range_colorkey();
test_shademode();
test_lockrect_invalid();
+ test_set_render_state();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 34167c1..73b88ec 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -10761,6 +10761,36 @@ done:
DestroyWindow(window);
}
+static void test_set_render_state(void)
+{
+ IDirect3DDevice7 *device;
+ ULONG refcount;
+ HWND window;
+ DWORD state;
+ HRESULT hr;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ for (state = D3DRENDERSTATE_CLIPPLANEENABLE + 1; state <= D3DRENDERSTATE_CLIPPLANEENABLE + 300; ++state)
+ {
+ hr = IDirect3DDevice7_SetRenderState(device, state, 0);
+ ok(SUCCEEDED(hr), "Got unexpected hr %#x, state %#x, value 0.\n", hr, state);
+ hr = IDirect3DDevice7_SetRenderState(device, state, 1);
+ ok(SUCCEEDED(hr), "Got unexpected hr %#x, state %#x, value 1.\n", hr, state);
+ }
+
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -10859,4 +10889,5 @@ START_TEST(ddraw7)
test_range_colorkey();
test_shademode();
test_lockrect_invalid();
+ test_set_render_state();
}
--
2.4.10
More information about the wine-patches
mailing list