[PATCH 3/5] ddraw/tests: Add some tests for DDSCL_CREATEDEVICEWINDOW.
Henri Verbeet
hverbeet at codeweavers.com
Wed Dec 21 14:34:58 CST 2011
---
dlls/ddraw/tests/Makefile.in | 2 +
dlls/ddraw/tests/ddraw1.c | 130 +++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw2.c | 137 ++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 117 ++++++++++++++++++++++++++++++++++--
dlls/ddraw/tests/ddraw7.c | 110 +++++++++++++++++++++++++++++++++-
5 files changed, 489 insertions(+), 7 deletions(-)
create mode 100644 dlls/ddraw/tests/ddraw1.c
create mode 100644 dlls/ddraw/tests/ddraw2.c
diff --git a/dlls/ddraw/tests/Makefile.in b/dlls/ddraw/tests/Makefile.in
index a78908c..d5d30bb 100644
--- a/dlls/ddraw/tests/Makefile.in
+++ b/dlls/ddraw/tests/Makefile.in
@@ -3,6 +3,8 @@ IMPORTS = ddraw user32 gdi32 ole32
C_SRCS = \
d3d.c \
+ ddraw1.c \
+ ddraw2.c \
ddraw4.c \
ddraw7.c \
ddrawmodes.c \
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
new file mode 100644
index 0000000..f7e4abf
--- /dev/null
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2011 Henri Verbeet for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include "d3d.h"
+
+static IDirectDraw *create_ddraw(void)
+{
+ IDirectDraw *ddraw;
+
+ if (FAILED(DirectDrawCreate(NULL, &ddraw, NULL)))
+ return NULL;
+
+ return ddraw;
+}
+
+static void test_coop_level_create_device_window(void)
+{
+ HWND focus_window, device_window;
+ IDirectDraw *ddraw;
+ HRESULT hr;
+
+ focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
+ if (broken(hr == DDERR_INVALIDPARAMS))
+ {
+ win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
+ IDirectDraw_Release(ddraw);
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ IDirectDraw_Release(ddraw);
+ DestroyWindow(focus_window);
+}
+
+START_TEST(ddraw1)
+{
+ test_coop_level_create_device_window();
+}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
new file mode 100644
index 0000000..8bbdd4d
--- /dev/null
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2011 Henri Verbeet for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include "d3d.h"
+
+static IDirectDraw2 *create_ddraw(void)
+{
+ IDirectDraw2 *ddraw2;
+ IDirectDraw *ddraw1;
+ HRESULT hr;
+
+ if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
+ return NULL;
+
+ hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
+ IDirectDraw_Release(ddraw1);
+ if (FAILED(hr))
+ return NULL;
+
+ return ddraw2;
+}
+
+static void test_coop_level_create_device_window(void)
+{
+ HWND focus_window, device_window;
+ IDirectDraw2 *ddraw;
+ HRESULT hr;
+
+ focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
+ if (broken(hr == DDERR_INVALIDPARAMS))
+ {
+ win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
+ IDirectDraw2_Release(ddraw);
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ IDirectDraw2_Release(ddraw);
+ DestroyWindow(focus_window);
+}
+
+START_TEST(ddraw2)
+{
+ test_coop_level_create_device_window();
+}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 033a82d..6b764cc 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -54,14 +54,10 @@ static BOOL compare_vec4(struct vec4 *vec, float x, float y, float z, float w, u
&& compare_float(vec->w, w, ulps);
}
-static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
+static IDirectDraw4 *create_ddraw(void)
{
- IDirect3DDevice3 *device = NULL;
- IDirectDrawSurface4 *surface;
- DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw4;
IDirectDraw *ddraw1;
- IDirect3D3 *d3d3;
HRESULT hr;
if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
@@ -72,6 +68,21 @@ static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
if (FAILED(hr))
return NULL;
+ return ddraw4;
+}
+
+static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
+{
+ IDirect3DDevice3 *device = NULL;
+ IDirectDrawSurface4 *surface;
+ DDSURFACEDESC2 surface_desc;
+ IDirectDraw4 *ddraw4;
+ IDirect3D3 *d3d3;
+ HRESULT hr;
+
+ if (!(ddraw4 = create_ddraw()))
+ return NULL;
+
hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, coop_level);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
@@ -321,7 +332,103 @@ static void test_process_vertices(void)
DestroyWindow(window);
}
+static void test_coop_level_create_device_window(void)
+{
+ HWND focus_window, device_window;
+ IDirectDraw4 *ddraw;
+ HRESULT hr;
+
+ focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
+ if (broken(hr == DDERR_INVALIDPARAMS))
+ {
+ win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
+ IDirectDraw4_Release(ddraw);
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ IDirectDraw4_Release(ddraw);
+ DestroyWindow(focus_window);
+}
+
START_TEST(ddraw4)
{
test_process_vertices();
+ test_coop_level_create_device_window();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 3ebf58c..b559351 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -64,6 +64,16 @@ static BOOL compare_vec4(struct vec4 *vec, float x, float y, float z, float w, u
&& compare_float(vec->w, w, ulps);
}
+static IDirectDraw7 *create_ddraw(void)
+{
+ IDirectDraw7 *ddraw;
+
+ if (FAILED(pDirectDrawCreateEx(NULL, (void **)&ddraw, &IID_IDirectDraw7, NULL)))
+ return NULL;
+
+ return ddraw;
+}
+
static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
{
IDirect3DDevice7 *device = NULL;
@@ -73,7 +83,7 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
IDirect3D7 *d3d7;
HRESULT hr;
- if (FAILED(pDirectDrawCreateEx(NULL, (void **)&ddraw, &IID_IDirectDraw7, NULL)))
+ if (!(ddraw = create_ddraw()))
return NULL;
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, coop_level);
@@ -158,7 +168,7 @@ static void test_process_vertices(void)
0, 0, 640, 480, 0, 0, 0, 0);
if (!(device = create_device(window, DDSCL_NORMAL)))
{
- skip("Failed to create a 3D device, skipping test.\n");
+ skip("Failed to create a ddraw object, skipping test.\n");
DestroyWindow(window);
return;
}
@@ -315,6 +325,101 @@ static void test_process_vertices(void)
DestroyWindow(window);
}
+static void test_coop_level_create_device_window(void)
+{
+ HWND focus_window, device_window;
+ IDirectDraw7 *ddraw;
+ HRESULT hr;
+
+ focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a 3D device, skipping test.\n");
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
+ if (broken(hr == DDERR_INVALIDPARAMS))
+ {
+ win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
+ IDirectDraw7_Release(ddraw);
+ DestroyWindow(focus_window);
+ return;
+ }
+
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
+ | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ ok(!device_window, "Unexpected device window found.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
+ todo_wine ok(!!device_window, "Device window not found.\n");
+
+ IDirectDraw7_Release(ddraw);
+ DestroyWindow(focus_window);
+}
+
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -326,4 +431,5 @@ START_TEST(ddraw7)
}
test_process_vertices();
+ test_coop_level_create_device_window();
}
--
1.7.3.4
More information about the wine-patches
mailing list