ddraw: Handle the special DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW combination.
[wine/multimedia.git] / dlls / ddraw / tests / ddraw4.c
blobead2aa3cc8b38aa4f6da5360e0cdc8a606afde8c
1 /*
2 * Copyright 2011 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wine/test.h"
20 #include <limits.h>
21 #include "d3d.h"
23 struct vec3
25 float x, y, z;
28 struct vec4
30 float x, y, z, w;
33 static BOOL compare_float(float f, float g, unsigned int ulps)
35 int x = *(int *)&f;
36 int y = *(int *)&g;
38 if (x < 0)
39 x = INT_MIN - x;
40 if (y < 0)
41 y = INT_MIN - y;
43 if (abs(x - y) > ulps)
44 return FALSE;
46 return TRUE;
49 static BOOL compare_vec4(struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps)
51 return compare_float(vec->x, x, ulps)
52 && compare_float(vec->y, y, ulps)
53 && compare_float(vec->z, z, ulps)
54 && compare_float(vec->w, w, ulps);
57 static IDirectDraw4 *create_ddraw(void)
59 IDirectDraw4 *ddraw4;
60 IDirectDraw *ddraw1;
61 HRESULT hr;
63 if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
64 return NULL;
66 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw4, (void **)&ddraw4);
67 IDirectDraw_Release(ddraw1);
68 if (FAILED(hr))
69 return NULL;
71 return ddraw4;
74 static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
76 IDirect3DDevice3 *device = NULL;
77 IDirectDrawSurface4 *surface;
78 DDSURFACEDESC2 surface_desc;
79 IDirectDraw4 *ddraw4;
80 IDirect3D3 *d3d3;
81 HRESULT hr;
83 if (!(ddraw4 = create_ddraw()))
84 return NULL;
86 hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, coop_level);
87 ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
89 memset(&surface_desc, 0, sizeof(surface_desc));
90 surface_desc.dwSize = sizeof(surface_desc);
91 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
92 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
93 surface_desc.dwWidth = 640;
94 surface_desc.dwHeight = 480;
96 hr = IDirectDraw4_CreateSurface(ddraw4, &surface_desc, &surface, NULL);
97 ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
99 if (coop_level & DDSCL_NORMAL)
101 IDirectDrawClipper *clipper;
103 hr = IDirectDraw4_CreateClipper(ddraw4, 0, &clipper, NULL);
104 ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
105 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
106 ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
107 hr = IDirectDrawSurface4_SetClipper(surface, clipper);
108 ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#x.\n", hr);
109 IDirectDrawClipper_Release(clipper);
112 hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirect3D3, (void **)&d3d3);
113 IDirectDraw4_Release(ddraw4);
114 if (FAILED(hr))
116 IDirectDrawSurface4_Release(surface);
117 return NULL;
120 hr = IDirect3D3_CreateDevice(d3d3, &IID_IDirect3DHALDevice, surface, &device, NULL);
121 IDirect3D3_Release(d3d3);
122 IDirectDrawSurface4_Release(surface);
123 if (FAILED(hr))
124 return NULL;
126 return device;
129 static void test_process_vertices(void)
131 IDirect3DVertexBuffer *src_vb, *dst_vb;
132 IDirect3DViewport3 *viewport;
133 D3DVERTEXBUFFERDESC vb_desc;
134 IDirect3DDevice3 *device;
135 struct vec3 *src_data;
136 struct vec4 *dst_data;
137 IDirect3D3 *d3d3;
138 D3DVIEWPORT2 vp2;
139 D3DVIEWPORT vp1;
140 HWND window;
141 HRESULT hr;
143 static D3DMATRIX identity =
145 1.0f, 0.0f, 0.0f, 0.0f,
146 0.0f, 1.0f, 0.0f, 0.0f,
147 0.0f, 0.0f, 1.0f, 0.0f,
148 0.0f, 0.0f, 0.0f, 1.0f,
150 static D3DMATRIX projection =
152 1.0f, 0.0f, 0.0f, 0.0f,
153 0.0f, 1.0f, 0.0f, 0.0f,
154 0.0f, 0.0f, 1.0f, 0.0f,
155 6.0f, 7.0f, 8.0f, 1.0f,
158 window = CreateWindowA("static", "d3d7_test", WS_OVERLAPPEDWINDOW,
159 0, 0, 640, 480, 0, 0, 0, 0);
160 if (!(device = create_device(window, DDSCL_NORMAL)))
162 skip("Failed to create a 3D device, skipping test.\n");
163 DestroyWindow(window);
164 return;
167 hr = IDirect3DDevice3_GetDirect3D(device, &d3d3);
168 ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
170 memset(&vb_desc, 0, sizeof(vb_desc));
171 vb_desc.dwSize = sizeof(vb_desc);
172 vb_desc.dwFVF = D3DFVF_XYZ;
173 vb_desc.dwNumVertices = 3;
174 hr = IDirect3D3_CreateVertexBuffer(d3d3, &vb_desc, &src_vb, 0, NULL);
175 ok(SUCCEEDED(hr), "Failed to create source vertex buffer, hr %#x.\n", hr);
177 hr = IDirect3DVertexBuffer_Lock(src_vb, DDLOCK_WRITEONLY, (void **)&src_data, NULL);
178 ok(SUCCEEDED(hr), "Failed to lock source vertex buffer, hr %#x.\n", hr);
179 src_data[0].x = -1.0f;
180 src_data[0].y = -1.0f;
181 src_data[0].z = -1.0f;
182 src_data[1].x = 0.0f;
183 src_data[1].y = 0.0f;
184 src_data[1].z = 0.0f;
185 src_data[2].x = 1.0f;
186 src_data[2].y = 1.0f;
187 src_data[2].z = 1.0f;
188 hr = IDirect3DVertexBuffer_Unlock(src_vb);
189 ok(SUCCEEDED(hr), "Failed to unlock source vertex buffer, hr %#x.\n", hr);
191 memset(&vb_desc, 0, sizeof(vb_desc));
192 vb_desc.dwSize = sizeof(vb_desc);
193 vb_desc.dwFVF = D3DFVF_XYZRHW;
194 vb_desc.dwNumVertices = 3;
195 hr = IDirect3D3_CreateVertexBuffer(d3d3, &vb_desc, &dst_vb, 0, NULL);
196 ok(SUCCEEDED(hr), "Failed to create destination vertex buffer, hr %#x.\n", hr);
198 hr = IDirect3D3_CreateViewport(d3d3, &viewport, NULL);
199 ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
200 hr = IDirect3DDevice3_AddViewport(device, viewport);
201 ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
202 vp2.dwSize = sizeof(vp2);
203 vp2.dwX = 10;
204 vp2.dwY = 20;
205 vp2.dwWidth = 100;
206 vp2.dwHeight = 200;
207 vp2.dvClipX = 2.0f;
208 vp2.dvClipY = 3.0f;
209 vp2.dvClipWidth = 4.0f;
210 vp2.dvClipHeight = 5.0f;
211 vp2.dvMinZ = -2.0f;
212 vp2.dvMaxZ = 3.0f;
213 hr = IDirect3DViewport3_SetViewport2(viewport, &vp2);
214 ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
215 hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
216 ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
218 hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
219 ok(SUCCEEDED(hr), "Failed to set world transformation, hr %#x.\n", hr);
220 hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &identity);
221 ok(SUCCEEDED(hr), "Failed to set view transformation, hr %#x.\n", hr);
222 hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &identity);
223 ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr);
225 hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
226 ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
228 hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
229 ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
230 ok(compare_vec4(&dst_data[0], -6.500e+1f, +1.800e+2f, +2.000e-1f, +1.000e+0f, 4096),
231 "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
232 dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
233 ok(compare_vec4(&dst_data[1], -4.000e+1f, +1.400e+2f, +4.000e-1f, +1.000e+0f, 4096),
234 "Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
235 dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
236 ok(compare_vec4(&dst_data[2], -1.500e+1f, +1.000e+2f, +6.000e-1f, +1.000e+0f, 4096),
237 "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
238 dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
239 hr = IDirect3DVertexBuffer_Unlock(dst_vb);
240 ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
242 hr = IDirect3DDevice3_MultiplyTransform(device, D3DTRANSFORMSTATE_PROJECTION, &projection);
243 ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr);
245 hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
246 ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
248 hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
249 ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
250 ok(compare_vec4(&dst_data[0], +8.500e+1f, -1.000e+2f, +1.800e+0f, +1.000e+0f, 4096),
251 "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
252 dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
253 ok(compare_vec4(&dst_data[1], +1.100e+2f, -1.400e+2f, +2.000e+0f, +1.000e+0f, 4096),
254 "Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
255 dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
256 ok(compare_vec4(&dst_data[2], +1.350e+2f, -1.800e+2f, +2.200e+0f, +1.000e+0f, 4096),
257 "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
258 dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
259 hr = IDirect3DVertexBuffer_Unlock(dst_vb);
260 ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
262 vp2.dwSize = sizeof(vp2);
263 vp2.dwX = 30;
264 vp2.dwY = 40;
265 vp2.dwWidth = 90;
266 vp2.dwHeight = 80;
267 vp2.dvClipX = 4.0f;
268 vp2.dvClipY = 6.0f;
269 vp2.dvClipWidth = 2.0f;
270 vp2.dvClipHeight = 4.0f;
271 vp2.dvMinZ = 3.0f;
272 vp2.dvMaxZ = -2.0f;
273 hr = IDirect3DViewport3_SetViewport2(viewport, &vp2);
274 ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
276 hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
277 ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
279 hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
280 ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
281 ok(compare_vec4(&dst_data[0], +7.500e+1f, +4.000e+1f, -8.000e-1f, +1.000e+0f, 4096),
282 "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
283 dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
284 ok(compare_vec4(&dst_data[1], +1.200e+2f, +2.000e+1f, -1.000e+0f, +1.000e+0f, 4096),
285 "Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
286 dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
287 ok(compare_vec4(&dst_data[2], +1.650e+2f, +0.000e+0f, -1.200e+0f, +1.000e+0f, 4096),
288 "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
289 dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
290 hr = IDirect3DVertexBuffer_Unlock(dst_vb);
291 ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
293 vp1.dwSize = sizeof(vp1);
294 vp1.dwX = 30;
295 vp1.dwY = 40;
296 vp1.dwWidth = 90;
297 vp1.dwHeight = 80;
298 vp1.dvScaleX = 7.0f;
299 vp1.dvScaleY = 2.0f;
300 vp1.dvMaxX = 6.0f;
301 vp1.dvMaxY = 10.0f;
302 vp1.dvMinZ = -2.0f;
303 vp1.dvMaxZ = 3.0f;
304 hr = IDirect3DViewport3_SetViewport(viewport, &vp1);
305 ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
307 hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
308 ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
310 hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
311 ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
312 ok(compare_vec4(&dst_data[0], +1.100e+2f, +6.800e+1f, +7.000e+0f, +1.000e+0f, 4096),
313 "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
314 dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
315 ok(compare_vec4(&dst_data[1], +1.170e+2f, +6.600e+1f, +8.000e+0f, +1.000e+0f, 4096),
316 "Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
317 dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
318 ok(compare_vec4(&dst_data[2], +1.240e+2f, +6.400e+1f, +9.000e+0f, +1.000e+0f, 4096),
319 "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
320 dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
321 hr = IDirect3DVertexBuffer_Unlock(dst_vb);
322 ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
324 hr = IDirect3DDevice3_DeleteViewport(device, viewport);
325 ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
327 IDirect3DVertexBuffer_Release(dst_vb);
328 IDirect3DVertexBuffer_Release(src_vb);
329 IDirect3DViewport3_Release(viewport);
330 IDirect3D3_Release(d3d3);
331 IDirect3DDevice3_Release(device);
332 DestroyWindow(window);
335 static void test_coop_level_create_device_window(void)
337 HWND focus_window, device_window;
338 IDirectDraw4 *ddraw;
339 HRESULT hr;
341 focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
342 0, 0, 640, 480, 0, 0, 0, 0);
343 if (!(ddraw = create_ddraw()))
345 skip("Failed to create a ddraw object, skipping test.\n");
346 DestroyWindow(focus_window);
347 return;
350 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
351 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
352 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
353 ok(!device_window, "Unexpected device window found.\n");
354 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
355 ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
356 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
357 ok(!device_window, "Unexpected device window found.\n");
358 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
359 ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
360 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
361 ok(!device_window, "Unexpected device window found.\n");
362 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
363 ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
364 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
365 ok(!device_window, "Unexpected device window found.\n");
366 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
367 ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
368 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
369 ok(!device_window, "Unexpected device window found.\n");
371 /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
372 if (broken(hr == DDERR_INVALIDPARAMS))
374 win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
375 IDirectDraw4_Release(ddraw);
376 DestroyWindow(focus_window);
377 return;
380 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
381 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
382 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
383 ok(!device_window, "Unexpected device window found.\n");
384 hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
385 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
386 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
387 ok(!device_window, "Unexpected device window found.\n");
389 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
390 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
391 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
392 ok(!device_window, "Unexpected device window found.\n");
393 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
394 | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
395 ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
396 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
397 todo_wine ok(!!device_window, "Device window not found.\n");
399 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
400 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
401 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
402 ok(!device_window, "Unexpected device window found.\n");
403 hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
404 | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
405 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
406 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
407 todo_wine ok(!!device_window, "Device window not found.\n");
409 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
410 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
411 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
412 ok(!device_window, "Unexpected device window found.\n");
413 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
414 ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
415 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
416 ok(!device_window, "Unexpected device window found.\n");
417 hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
418 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
419 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
420 ok(!device_window, "Unexpected device window found.\n");
421 hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
422 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
423 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
424 todo_wine ok(!!device_window, "Device window not found.\n");
426 IDirectDraw4_Release(ddraw);
427 DestroyWindow(focus_window);
430 START_TEST(ddraw4)
432 test_process_vertices();
433 test_coop_level_create_device_window();