2 * Unit tests for ddraw functions
5 * Part of this test involves changing the screen resolution. But this is
6 * really disrupting if the user is doing something else and is not very nice
7 * to CRT screens. Plus, ideally it needs someone watching it to check that
8 * each mode displays correctly.
9 * So this is only done if the test is being run in interactive mode.
11 * Copyright (C) 2003 Sami Aario
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
32 static IDirectDrawSurface
*lpDDSPrimary
;
33 static IDirectDrawSurface
*lpDDSBack
;
34 static IDirectDraw
*lpDD
;
36 static HWND hwnd
, hwnd2
;
38 static int modes_size
;
39 static DDSURFACEDESC
*modes
;
40 static RECT rect_before_create
;
41 static RECT rect_after_delete
;
42 static int modes16bpp_cnt
;
43 static int refresh_rate
;
44 static int refresh_rate_cnt
;
46 static HRESULT (WINAPI
*pDirectDrawEnumerateA
)(LPDDENUMCALLBACKA cb
, void *ctx
);
47 static HRESULT (WINAPI
*pDirectDrawEnumerateW
)(LPDDENUMCALLBACKW cb
, void *ctx
);
48 static HRESULT (WINAPI
*pDirectDrawEnumerateExA
)(LPDDENUMCALLBACKEXA cb
, void *ctx
, DWORD flags
);
49 static HRESULT (WINAPI
*pDirectDrawEnumerateExW
)(LPDDENUMCALLBACKEXW cb
, void *ctx
, DWORD flags
);
51 static void init_function_pointers(void)
53 HMODULE hmod
= GetModuleHandleA("ddraw.dll");
54 pDirectDrawEnumerateA
= (void*)GetProcAddress(hmod
, "DirectDrawEnumerateA");
55 pDirectDrawEnumerateW
= (void*)GetProcAddress(hmod
, "DirectDrawEnumerateW");
56 pDirectDrawEnumerateExA
= (void*)GetProcAddress(hmod
, "DirectDrawEnumerateExA");
57 pDirectDrawEnumerateExW
= (void*)GetProcAddress(hmod
, "DirectDrawEnumerateExW");
60 static HWND
createwindow(void)
64 hwnd
= CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
66 GetSystemMetrics(SM_CXSCREEN
),
67 GetSystemMetrics(SM_CYSCREEN
),
68 NULL
, NULL
, GetModuleHandleA(0), NULL
);
70 ShowWindow(hwnd
, SW_HIDE
);
77 static BOOL
createdirectdraw(void)
81 SetRect(&rect_before_create
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
83 rc
= DirectDrawCreate(NULL
, &lpDD
, NULL
);
84 ok(rc
==DD_OK
|| rc
==DDERR_NODIRECTDRAWSUPPORT
, "DirectDrawCreateEx returned: %x\n", rc
);
86 trace("DirectDrawCreateEx() failed with an error %x\n", rc
);
93 static void releasedirectdraw(void)
97 IDirectDraw_Release(lpDD
);
99 SetRect(&rect_after_delete
, 0, 0,
100 GetSystemMetrics(SM_CXSCREEN
),
101 GetSystemMetrics(SM_CYSCREEN
));
102 ok(EqualRect(&rect_before_create
, &rect_after_delete
) != 0,
103 "Original display mode was not restored\n");
107 static BOOL WINAPI
test_nullcontext_callbackA(GUID
*lpGUID
,
108 char *lpDriverDescription
, char *lpDriverName
, void *lpContext
)
110 trace("test_nullcontext_callbackA: %p %s %s %p\n",
111 lpGUID
, lpDriverDescription
, lpDriverName
, lpContext
);
113 ok(!lpContext
, "Expected NULL lpContext\n");
118 static BOOL WINAPI
test_context_callbackA(GUID
*lpGUID
,
119 char *lpDriverDescription
, char *lpDriverName
, void *lpContext
)
121 trace("test_context_callbackA: %p %s %s %p\n",
122 lpGUID
, lpDriverDescription
, lpDriverName
, lpContext
);
124 ok(lpContext
== (void *)0xdeadbeef, "Expected non-NULL lpContext\n");
129 static void test_DirectDrawEnumerateA(void)
133 if (!pDirectDrawEnumerateA
)
135 win_skip("DirectDrawEnumerateA is not available\n");
139 /* Test with NULL callback parameter. */
140 ret
= pDirectDrawEnumerateA(NULL
, NULL
);
141 ok(ret
== DDERR_INVALIDPARAMS
, "Expected DDERR_INVALIDPARAMS, got %d\n", ret
);
143 /* Test with valid callback parameter and NULL context parameter. */
144 trace("Calling DirectDrawEnumerateA with test_nullcontext_callbackA callback and NULL context.\n");
145 ret
= pDirectDrawEnumerateA(test_nullcontext_callbackA
, NULL
);
146 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
148 /* Test with valid callback parameter and valid context parameter. */
149 trace("Calling DirectDrawEnumerateA with test_context_callbackA callback and non-NULL context.\n");
150 ret
= pDirectDrawEnumerateA(test_context_callbackA
, (void *)0xdeadbeef);
151 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
154 static BOOL WINAPI
test_callbackW(GUID
*lpGUID
, WCHAR
*lpDriverDescription
,
155 WCHAR
*lpDriverName
, void *lpContext
)
157 ok(0, "The callback should not be invoked by DirectDrawEnumerateW\n");
161 static void test_DirectDrawEnumerateW(void)
165 if (!pDirectDrawEnumerateW
)
167 win_skip("DirectDrawEnumerateW is not available\n");
171 /* DirectDrawEnumerateW is not implemented on Windows. */
173 /* Test with NULL callback parameter. */
174 ret
= pDirectDrawEnumerateW(NULL
, NULL
);
175 ok(ret
== DDERR_INVALIDPARAMS
||
176 ret
== DDERR_UNSUPPORTED
, /* Older ddraw */
177 "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret
);
179 /* Test with invalid callback parameter. */
180 ret
= pDirectDrawEnumerateW((LPDDENUMCALLBACKW
)0xdeadbeef, NULL
);
181 ok(ret
== DDERR_INVALIDPARAMS
/* XP */ ||
182 ret
== DDERR_UNSUPPORTED
/* Win7 */,
183 "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret
);
185 /* Test with valid callback parameter and NULL context parameter. */
186 ret
= pDirectDrawEnumerateW(test_callbackW
, NULL
);
187 ok(ret
== DDERR_UNSUPPORTED
, "Expected DDERR_UNSUPPORTED, got %d\n", ret
);
190 static BOOL WINAPI
test_nullcontext_callbackExA(GUID
*lpGUID
, char *lpDriverDescription
,
191 char *lpDriverName
, void *lpContext
, HMONITOR hm
)
193 trace("test_nullcontext_callbackExA: %p %s %s %p %p\n", lpGUID
,
194 lpDriverDescription
, lpDriverName
, lpContext
, hm
);
196 ok(!lpContext
, "Expected NULL lpContext\n");
201 static BOOL WINAPI
test_context_callbackExA(GUID
*lpGUID
, char *lpDriverDescription
,
202 char *lpDriverName
, void *lpContext
, HMONITOR hm
)
204 trace("test_context_callbackExA: %p %s %s %p %p\n", lpGUID
,
205 lpDriverDescription
, lpDriverName
, lpContext
, hm
);
207 ok(lpContext
== (void *)0xdeadbeef, "Expected non-NULL lpContext\n");
212 static BOOL WINAPI
test_count_callbackExA(GUID
*lpGUID
, char *lpDriverDescription
,
213 char *lpDriverName
, void *lpContext
, HMONITOR hm
)
215 DWORD
*count
= (DWORD
*)lpContext
;
217 trace("test_count_callbackExA: %p %s %s %p %p\n", lpGUID
,
218 lpDriverDescription
, lpDriverName
, lpContext
, hm
);
225 static void test_DirectDrawEnumerateExA(void)
230 if (!pDirectDrawEnumerateExA
)
232 win_skip("DirectDrawEnumerateExA is not available\n");
236 /* Test with NULL callback parameter. */
237 ret
= pDirectDrawEnumerateExA(NULL
, NULL
, 0);
238 ok(ret
== DDERR_INVALIDPARAMS
, "Expected DDERR_INVALIDPARAMS, got %d\n", ret
);
240 /* Test with valid callback parameter and invalid flags */
241 ret
= pDirectDrawEnumerateExA(test_nullcontext_callbackExA
, NULL
, ~0);
242 ok(ret
== DDERR_INVALIDPARAMS
, "Expected DDERR_INVALIDPARAMS, got %d\n", ret
);
244 /* Test with valid callback parameter and NULL context parameter. */
245 trace("Calling DirectDrawEnumerateExA with empty flags and NULL context.\n");
246 ret
= pDirectDrawEnumerateExA(test_nullcontext_callbackExA
, NULL
, 0);
247 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
249 /* Test with valid callback parameter and non-NULL context parameter. */
250 trace("Calling DirectDrawEnumerateExA with empty flags and non-NULL context.\n");
251 ret
= pDirectDrawEnumerateExA(test_context_callbackExA
, (void *)0xdeadbeef, 0);
252 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
254 /* Test with valid callback parameter and count the number of primary devices */
256 ret
= pDirectDrawEnumerateExA(test_count_callbackExA
, &callbackCount
, 0);
257 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
258 ok(callbackCount
== 1, "Expected 1 primary device, got %d\n", callbackCount
);
260 /* Test with valid callback parameter and count the number of secondary devices */
262 ret
= pDirectDrawEnumerateExA(test_count_callbackExA
, &callbackCount
,
263 DDENUM_ATTACHEDSECONDARYDEVICES
);
264 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
265 /* Note: this list includes the primary devices as well and some systems (such as the TestBot)
266 do not include any secondary devices */
267 ok(callbackCount
>= 1, "Expected at least one device, got %d\n", callbackCount
);
269 /* Test with valid callback parameter, NULL context parameter, and all flags set. */
270 trace("Calling DirectDrawEnumerateExA with all flags set and NULL context.\n");
271 ret
= pDirectDrawEnumerateExA(test_nullcontext_callbackExA
, NULL
,
272 DDENUM_ATTACHEDSECONDARYDEVICES
|
273 DDENUM_DETACHEDSECONDARYDEVICES
|
274 DDENUM_NONDISPLAYDEVICES
);
275 ok(ret
== DD_OK
, "Expected DD_OK, got %d\n", ret
);
278 static BOOL WINAPI
test_callbackExW(GUID
*lpGUID
, WCHAR
*lpDriverDescription
,
279 WCHAR
*lpDriverName
, void *lpContext
, HMONITOR hm
)
281 ok(0, "The callback should not be invoked by DirectDrawEnumerateExW.\n");
285 static void test_DirectDrawEnumerateExW(void)
289 if (!pDirectDrawEnumerateExW
)
291 win_skip("DirectDrawEnumerateExW is not available\n");
295 /* DirectDrawEnumerateExW is not implemented on Windows. */
297 /* Test with NULL callback parameter. */
298 ret
= pDirectDrawEnumerateExW(NULL
, NULL
, 0);
299 ok(ret
== DDERR_UNSUPPORTED
, "Expected DDERR_UNSUPPORTED, got %d\n", ret
);
301 /* Test with invalid callback parameter. */
302 ret
= pDirectDrawEnumerateExW((LPDDENUMCALLBACKEXW
)0xdeadbeef, NULL
, 0);
303 ok(ret
== DDERR_UNSUPPORTED
, "Expected DDERR_UNSUPPORTED, got %d\n", ret
);
305 /* Test with valid callback parameter and invalid flags */
306 ret
= pDirectDrawEnumerateExW(test_callbackExW
, NULL
, ~0);
307 ok(ret
== DDERR_UNSUPPORTED
, "Expected DDERR_UNSUPPORTED, got %d\n", ret
);
309 /* Test with valid callback parameter and NULL context parameter. */
310 ret
= pDirectDrawEnumerateExW(test_callbackExW
, NULL
, 0);
311 ok(ret
== DDERR_UNSUPPORTED
, "Expected DDERR_UNSUPPORTED, got %d\n", ret
);
313 /* Test with valid callback parameter, NULL context parameter, and all flags set. */
314 ret
= pDirectDrawEnumerateExW(test_callbackExW
, NULL
,
315 DDENUM_ATTACHEDSECONDARYDEVICES
|
316 DDENUM_DETACHEDSECONDARYDEVICES
|
317 DDENUM_NONDISPLAYDEVICES
);
318 ok(ret
== DDERR_UNSUPPORTED
, "Expected DDERR_UNSUPPORTED, got %d\n", ret
);
321 static void adddisplaymode(DDSURFACEDESC
*lpddsd
)
324 modes
= HeapAlloc(GetProcessHeap(), 0, (modes_size
= 2) * sizeof(DDSURFACEDESC
));
325 if (modes_cnt
== modes_size
)
326 modes
= HeapReAlloc(GetProcessHeap(), 0, modes
, (modes_size
*= 2) * sizeof(DDSURFACEDESC
));
328 modes
[modes_cnt
++] = *lpddsd
;
331 static void flushdisplaymodes(void)
333 HeapFree(GetProcessHeap(), 0, modes
);
335 modes_cnt
= modes_size
= 0;
338 static HRESULT WINAPI
enummodescallback(DDSURFACEDESC
*lpddsd
, void *lpContext
)
340 if (winetest_debug
> 1)
341 trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
342 lpddsd
->dwWidth
, lpddsd
->dwHeight
, U1(lpddsd
->ddpfPixelFormat
).dwRGBBitCount
,
343 U2(*lpddsd
).dwRefreshRate
, U1(*lpddsd
).lPitch
, lpddsd
->dwFlags
);
345 /* Check that the pitch is valid if applicable */
346 if(lpddsd
->dwFlags
& DDSD_PITCH
)
348 ok(U1(*lpddsd
).lPitch
!= 0, "EnumDisplayModes callback with bad pitch\n");
351 /* Check that frequency is valid if applicable
353 * This fails on some Windows drivers or Windows versions, so it isn't important
355 if(lpddsd->dwFlags & DDSD_REFRESHRATE)
357 ok(U2(*lpddsd).dwRefreshRate != 0, "EnumDisplayModes callback with bad refresh rate\n");
361 adddisplaymode(lpddsd
);
362 if(U1(lpddsd
->ddpfPixelFormat
).dwRGBBitCount
== 16)
368 static HRESULT WINAPI
enummodescallback_16bit(DDSURFACEDESC
*lpddsd
, void *lpContext
)
370 if (winetest_debug
> 1)
371 trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
372 lpddsd
->dwWidth
, lpddsd
->dwHeight
, U1(lpddsd
->ddpfPixelFormat
).dwRGBBitCount
,
373 U2(*lpddsd
).dwRefreshRate
, U1(*lpddsd
).lPitch
, lpddsd
->dwFlags
);
375 ok(lpddsd
->dwFlags
== (DDSD_HEIGHT
|DDSD_WIDTH
|DDSD_PIXELFORMAT
|DDSD_PITCH
|DDSD_REFRESHRATE
),
376 "Wrong surface description flags %02X\n", lpddsd
->dwFlags
);
377 ok(lpddsd
->ddpfPixelFormat
.dwFlags
== DDPF_RGB
, "Wrong pixel format flag %02X\n",
378 lpddsd
->ddpfPixelFormat
.dwFlags
);
379 ok(U1(lpddsd
->ddpfPixelFormat
).dwRGBBitCount
== 16, "Expected 16 bpp got %i\n",
380 U1(lpddsd
->ddpfPixelFormat
).dwRGBBitCount
);
382 /* Check that the pitch is valid if applicable */
383 if(lpddsd
->dwFlags
& DDSD_PITCH
)
385 ok(U1(*lpddsd
).lPitch
!= 0, "EnumDisplayModes callback with bad pitch\n");
390 if(U2(*lpddsd
).dwRefreshRate
)
392 refresh_rate
= U2(*lpddsd
).dwRefreshRate
;
398 if(refresh_rate
== U2(*lpddsd
).dwRefreshRate
)
407 static HRESULT WINAPI
enummodescallback_count(DDSURFACEDESC
*lpddsd
, void *lpContext
)
409 ok(lpddsd
->dwFlags
== (DDSD_HEIGHT
|DDSD_WIDTH
|DDSD_PIXELFORMAT
|DDSD_PITCH
|DDSD_REFRESHRATE
),
410 "Wrong surface description flags %02X\n", lpddsd
->dwFlags
);
417 static void enumdisplaymodes(void)
421 int count
, refresh_count
;
423 ZeroMemory(&ddsd
, sizeof(DDSURFACEDESC
));
424 ddsd
.dwSize
= sizeof(DDSURFACEDESC
);
425 ddsd
.dwFlags
= DDSD_CAPS
;
426 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
;
428 /* Flags parameter is reserved in very old ddraw versions (3 and older?) and must be 0 */
429 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback
);
430 ok(rc
==DD_OK
, "EnumDisplayModes returned: %x\n",rc
);
432 count
= modes16bpp_cnt
;
435 ddsd
.dwFlags
= DDSD_PIXELFORMAT
;
436 ddsd
.ddpfPixelFormat
.dwFlags
= DDPF_RGB
;
437 U1(ddsd
.ddpfPixelFormat
).dwRGBBitCount
= 16;
438 U2(ddsd
.ddpfPixelFormat
).dwRBitMask
= 0xf800;
439 U3(ddsd
.ddpfPixelFormat
).dwGBitMask
= 0x07e0;
440 U4(ddsd
.ddpfPixelFormat
).dwBBitMask
= 0x001F;
442 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
443 ok(rc
==DD_OK
, "EnumDisplayModes returned: %x\n",rc
);
444 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
447 U2(ddsd
.ddpfPixelFormat
).dwRBitMask
= 0x0000;
448 U3(ddsd
.ddpfPixelFormat
).dwGBitMask
= 0x0000;
449 U4(ddsd
.ddpfPixelFormat
).dwBBitMask
= 0x0000;
451 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
452 ok(rc
==DD_OK
, "EnumDisplayModes returned: %x\n",rc
);
453 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
456 U2(ddsd
.ddpfPixelFormat
).dwRBitMask
= 0xF0F0;
457 U3(ddsd
.ddpfPixelFormat
).dwGBitMask
= 0x0F00;
458 U4(ddsd
.ddpfPixelFormat
).dwBBitMask
= 0x000F;
460 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
461 ok(rc
==DD_OK
, "EnumDisplayModes returned: %x\n",rc
);
462 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
466 ddsd
.ddpfPixelFormat
.dwFlags
= DDPF_YUV
;
468 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
469 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
470 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
473 ddsd
.ddpfPixelFormat
.dwFlags
= DDPF_PALETTEINDEXED8
;
475 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
476 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
477 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
480 ddsd
.dwFlags
= DDSD_PIXELFORMAT
;
481 ddsd
.ddpfPixelFormat
.dwFlags
= 0;
483 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
484 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
485 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
490 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_count
);
491 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
492 ok(modes16bpp_cnt
== modes_cnt
, "Expected %d modes got %d\n", modes_cnt
, modes16bpp_cnt
);
495 ddsd
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_PITCH
;
496 U1(ddsd
).lPitch
= 123;
498 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
499 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
500 ok(modes16bpp_cnt
== count
, "Expected %d modes got %d\n", count
, modes16bpp_cnt
);
503 ddsd
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_REFRESHRATE
;
504 /* Ask for a refresh rate that could not possibly be used. But note that
505 * the Windows 'Standard VGA' driver claims to run the display at 1Hz!
507 U2(ddsd
).dwRefreshRate
= 2;
509 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
510 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
511 ok(modes16bpp_cnt
== 0, "Expected 0 modes got %d\n", modes16bpp_cnt
);
514 ddsd
.dwFlags
= DDSD_PIXELFORMAT
;
516 rc
= IDirectDraw_EnumDisplayModes(lpDD
, DDEDM_REFRESHRATES
, &ddsd
, 0, enummodescallback_16bit
);
517 if(rc
== DDERR_INVALIDPARAMS
)
519 skip("Ddraw version too old. Skipping.\n");
522 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
523 refresh_count
= refresh_rate_cnt
;
528 ddsd
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_REFRESHRATE
;
529 U2(ddsd
).dwRefreshRate
= refresh_rate
;
531 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, &ddsd
, 0, enummodescallback_16bit
);
532 ok(rc
==DD_OK
,"EnumDisplayModes returned: %x\n",rc
);
533 ok(modes16bpp_cnt
== refresh_count
, "Expected %d modes got %d\n", refresh_count
, modes16bpp_cnt
);
536 rc
= IDirectDraw_EnumDisplayModes(lpDD
, 0, NULL
, 0, enummodescallback
);
537 ok(rc
==DD_OK
, "EnumDisplayModes returned: %x\n",rc
);
541 static void setdisplaymode(int i
)
546 SetRect(&orig_rect
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
548 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
549 hwnd
, DDSCL_ALLOWMODEX
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
550 ok(rc
==DD_OK
,"SetCooperativeLevel returned: %x\n",rc
);
551 if (modes
[i
].dwFlags
& DDSD_PIXELFORMAT
)
553 if (modes
[i
].ddpfPixelFormat
.dwFlags
& DDPF_RGB
)
555 rc
= IDirectDraw_SetDisplayMode(lpDD
,
556 modes
[i
].dwWidth
, modes
[i
].dwHeight
,
557 U1(modes
[i
].ddpfPixelFormat
).dwRGBBitCount
);
558 ok(DD_OK
==rc
|| DDERR_UNSUPPORTED
==rc
,"SetDisplayMode returned: %x\n",rc
);
561 RECT scrn
, test
, virt
;
563 SetRect(&virt
, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN
), GetSystemMetrics(SM_CYVIRTUALSCREEN
));
564 OffsetRect(&virt
, GetSystemMetrics(SM_XVIRTUALSCREEN
), GetSystemMetrics(SM_YVIRTUALSCREEN
));
565 SetRect(&scrn
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
566 trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes
[i
].dwWidth
, modes
[i
].dwHeight
,
567 scrn
.right
, scrn
.bottom
, virt
.left
, virt
.top
, virt
.right
, virt
.bottom
);
568 if (!EqualRect(&scrn
, &orig_rect
))
570 BOOL rect_result
, ret
;
572 /* Check that the client rect was resized */
573 ret
= GetClientRect(hwnd
, &test
);
574 ok(ret
, "GetClientRect returned %d\n", ret
);
575 ret
= EqualRect(&scrn
, &test
);
576 todo_wine
ok(ret
, "Fullscreen window has wrong size\n");
578 /* Check that switching to normal cooperative level
579 does not restore the display mode */
580 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, hwnd
, DDSCL_NORMAL
);
581 ok(rc
==DD_OK
, "SetCooperativeLevel returned %x\n", rc
);
582 SetRect(&test
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
583 rect_result
= EqualRect(&scrn
, &test
);
584 ok(rect_result
!=0, "Setting cooperative level to DDSCL_NORMAL changed the display mode\n");
586 /* Go back to fullscreen */
587 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
588 hwnd
, DDSCL_ALLOWMODEX
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
589 ok(rc
==DD_OK
, "SetCooperativeLevel returned: %x\n",rc
);
591 /* If the display mode was changed, set the correct mode
592 to avoid irrelevant failures */
593 if (rect_result
== 0)
595 rc
= IDirectDraw_SetDisplayMode(lpDD
,
596 modes
[i
].dwWidth
, modes
[i
].dwHeight
,
597 U1(modes
[i
].ddpfPixelFormat
).dwRGBBitCount
);
598 ok(DD_OK
==rc
, "SetDisplayMode returned: %x\n",rc
);
601 rc
= IDirectDraw_RestoreDisplayMode(lpDD
);
602 ok(DD_OK
==rc
,"RestoreDisplayMode returned: %x\n",rc
);
608 static void createsurface(void)
614 ddsd
.dwSize
= sizeof(ddsd
);
615 ddsd
.dwFlags
= DDSD_CAPS
| DDSD_BACKBUFFERCOUNT
;
616 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
|
619 ddsd
.dwBackBufferCount
= 1;
620 rc
= IDirectDraw_CreateSurface(lpDD
, &ddsd
, &lpDDSPrimary
, NULL
);
621 ok(rc
==DD_OK
,"CreateSurface returned: %x\n",rc
);
622 ddscaps
.dwCaps
= DDSCAPS_BACKBUFFER
;
623 rc
= IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary
, &ddscaps
, &lpDDSBack
);
624 ok(rc
==DD_OK
,"GetAttachedSurface returned: %x\n",rc
);
627 static void destroysurface(void)
629 if( lpDDSPrimary
!= NULL
)
631 IDirectDrawSurface_Release(lpDDSPrimary
);
636 static void testsurface(void)
638 const char* testMsg
= "ddraw device context test";
642 rc
= IDirectDrawSurface_GetDC(lpDDSBack
, &hdc
);
643 ok(rc
==DD_OK
, "IDirectDrawSurface_GetDC returned: %x\n",rc
);
644 SetBkColor(hdc
, RGB(0, 0, 255));
645 SetTextColor(hdc
, RGB(255, 255, 0));
646 TextOutA(hdc
, 0, 0, testMsg
, strlen(testMsg
));
647 rc
= IDirectDrawSurface_ReleaseDC(lpDDSBack
, hdc
);
648 ok(rc
==DD_OK
, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc
);
652 rc
= IDirectDrawSurface_Flip(lpDDSPrimary
, NULL
, DDFLIP_WAIT
);
653 ok(rc
==DD_OK
|| rc
==DDERR_SURFACELOST
, "IDirectDrawSurface_BltFast returned: %x\n",rc
);
659 else if (rc
== DDERR_SURFACELOST
)
661 rc
= IDirectDrawSurface_Restore(lpDDSPrimary
);
662 ok(rc
==DD_OK
, "IDirectDrawSurface_Restore returned: %x\n",rc
);
667 static void testdisplaymodes(void)
671 for (i
= 0; i
< modes_cnt
; ++i
)
680 static void testcooperativelevels_normal(void)
684 DDSURFACEDESC surfacedesc
;
685 IDirectDrawSurface
*surface
= (IDirectDrawSurface
*) 0xdeadbeef;
687 memset(&surfacedesc
, 0, sizeof(surfacedesc
));
688 surfacedesc
.dwSize
= sizeof(surfacedesc
);
689 surfacedesc
.ddpfPixelFormat
.dwSize
= sizeof(surfacedesc
.ddpfPixelFormat
);
690 surfacedesc
.dwFlags
= DDSD_CAPS
| DDSD_BACKBUFFERCOUNT
;
691 surfacedesc
.dwBackBufferCount
= 1;
692 surfacedesc
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
| DDSCAPS_COMPLEX
| DDSCAPS_FLIP
;
694 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, hwnd
, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW
);
695 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc
);
697 /* Do some tests with DDSCL_NORMAL mode */
699 /* Fullscreen mode + normal mode + exclusive mode */
701 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, NULL
, DDSCL_FULLSCREEN
| DDSCL_EXCLUSIVE
| DDSCL_NORMAL
);
702 ok(rc
==DDERR_INVALIDPARAMS
, "Expected DDERR_INVALIDPARAMS, received: %x\n", rc
);
706 sfw
=SetForegroundWindow(hwnd2
);
708 skip("Failed to create the second window\n");
710 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, hwnd
, DDSCL_FULLSCREEN
| DDSCL_EXCLUSIVE
| DDSCL_NORMAL
);
711 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc
);
714 ok(GetForegroundWindow()==hwnd
,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd
, hwnd2
);
716 /* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
717 rc
= IDirectDraw_CreateSurface(lpDD
, &surfacedesc
, &surface
, NULL
);
719 if (rc
== DDERR_UNSUPPORTEDMODE
)
720 skip("Unsupported mode\n");
723 ok(rc
== DD_OK
, "IDirectDraw_CreateSurface returned %08x\n", rc
);
724 ok(surface
!=NULL
, "Returned NULL surface pointer\n");
726 if(surface
&& surface
!= (IDirectDrawSurface
*)0xdeadbeef) IDirectDrawSurface_Release(surface
);
728 /* Exclusive mode + normal mode */
729 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, hwnd
, DDSCL_EXCLUSIVE
| DDSCL_NORMAL
);
730 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc
);
732 /* Fullscreen mode + normal mode */
735 if(hwnd2
) sfw
=SetForegroundWindow(hwnd2
);
737 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, hwnd
, DDSCL_FULLSCREEN
| DDSCL_NORMAL
);
738 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc
);
741 ok(GetForegroundWindow()==hwnd2
,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2
, hwnd
);
743 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, NULL
, DDSCL_FULLSCREEN
| DDSCL_NORMAL
);
744 ok(rc
==DD_OK
, "Expected DD_OK, received %x\n", rc
);
746 /* Try creating a double buffered primary in fullscreen + normal mode */
747 rc
= IDirectDraw_CreateSurface(lpDD
, &surfacedesc
, &surface
, NULL
);
748 if (rc
== DDERR_UNSUPPORTEDMODE
)
749 skip("Unsupported mode\n");
752 ok(rc
== DDERR_NOEXCLUSIVEMODE
, "IDirectDraw_CreateSurface returned %08x\n", rc
);
753 ok(surface
== NULL
, "Returned surface pointer is %p\n", surface
);
756 if(surface
&& surface
!= (IDirectDrawSurface
*)0xdeadbeef) IDirectDrawSurface_Release(surface
);
758 /* switching from Fullscreen mode to Normal mode */
761 if(hwnd2
) sfw
=SetForegroundWindow(hwnd2
);
763 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
765 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc
);
768 ok(GetForegroundWindow()==hwnd2
,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2
, hwnd
);
770 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, NULL
, DDSCL_NORMAL
);
771 ok(rc
==DD_OK
, "Expected DD_OK, received %x\n", rc
);
773 /* Try creating a double buffered primary in normal mode */
774 rc
= IDirectDraw_CreateSurface(lpDD
, &surfacedesc
, &surface
, NULL
);
775 if (rc
== DDERR_UNSUPPORTEDMODE
)
776 skip("Unsupported mode\n");
779 ok(rc
== DDERR_NOEXCLUSIVEMODE
, "IDirectDraw_CreateSurface returned %08x\n", rc
);
780 ok(surface
== NULL
, "Returned surface pointer is %p\n", surface
);
782 if(surface
&& surface
!= (IDirectDrawSurface
*)0xdeadbeef) IDirectDrawSurface_Release(surface
);
784 /* switching from Normal mode to Fullscreen + Normal mode */
787 if(hwnd2
) sfw
=SetForegroundWindow(hwnd2
);
789 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
790 hwnd
, DDSCL_NORMAL
| DDSCL_FULLSCREEN
);
791 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc
);
794 ok(GetForegroundWindow()==hwnd2
,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2
, hwnd
);
796 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, NULL
, DDSCL_NORMAL
| DDSCL_FULLSCREEN
);
797 ok(rc
==DD_OK
, "Expected DD_OK, received %x\n", rc
);
799 /* Set the focus window */
801 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, hwnd
, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW
);
802 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc
);
804 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, NULL
, DDSCL_SETFOCUSWINDOW
);
806 if (rc
== DDERR_INVALIDPARAMS
)
808 win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
812 ok(rc
==DD_OK
, "Expected DD_OK, received %x\n", rc
);
814 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
815 hwnd
, DDSCL_SETFOCUSWINDOW
);
817 if (rc
== DDERR_INVALIDPARAMS
)
819 win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
823 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
825 /* Set the focus window a second time*/
826 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
827 hwnd
, DDSCL_SETFOCUSWINDOW
);
828 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc
);
830 /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
831 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
832 hwnd
, DDSCL_NORMAL
| DDSCL_SETFOCUSWINDOW
);
833 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
835 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
836 hwnd
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
| DDSCL_SETFOCUSWINDOW
);
837 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
839 /* This one succeeds */
840 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
841 hwnd
, DDSCL_NOWINDOWCHANGES
| DDSCL_SETFOCUSWINDOW
);
842 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
844 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
845 hwnd
, DDSCL_MULTITHREADED
| DDSCL_SETFOCUSWINDOW
);
846 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
848 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
849 hwnd
, DDSCL_FPUSETUP
| DDSCL_SETFOCUSWINDOW
);
850 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
852 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
853 hwnd
, DDSCL_FPUPRESERVE
| DDSCL_SETFOCUSWINDOW
);
854 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
856 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
857 hwnd
, DDSCL_ALLOWREBOOT
| DDSCL_SETFOCUSWINDOW
);
858 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
860 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
861 hwnd
, DDSCL_ALLOWMODEX
| DDSCL_SETFOCUSWINDOW
);
862 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
864 /* Set the device window without any other flags. Should give an error */
865 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
866 hwnd
, DDSCL_SETDEVICEWINDOW
);
867 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc
);
869 /* Set device window with DDSCL_NORMAL */
870 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
871 hwnd
, DDSCL_NORMAL
| DDSCL_SETDEVICEWINDOW
);
872 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc
);
874 /* Also set the focus window. Should give an error */
875 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
876 hwnd
, DDSCL_ALLOWMODEX
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
| DDSCL_SETDEVICEWINDOW
| DDSCL_SETFOCUSWINDOW
);
877 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
882 static void testcooperativelevels_exclusive(void)
888 /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
890 /* First, resize the window so it is not the same size as any screen */
891 success
= SetWindowPos(hwnd
, 0, 0, 0, 281, 92, 0);
892 ok(success
, "SetWindowPos failed\n");
894 /* Try to set exclusive mode only */
895 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
896 hwnd
, DDSCL_EXCLUSIVE
);
897 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc
);
899 /* Full screen mode only */
900 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
901 hwnd
, DDSCL_FULLSCREEN
);
902 ok(rc
==DDERR_INVALIDPARAMS
,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc
);
904 /* Full screen mode + exclusive mode */
906 rc
= IDirectDraw_SetCooperativeLevel(lpDD
, NULL
, DDSCL_FULLSCREEN
| DDSCL_EXCLUSIVE
);
907 ok(rc
==DDERR_INVALIDPARAMS
, "Expected DDERR_INVALIDPARAMS, received %x\n", rc
);
911 sfw
=SetForegroundWindow(hwnd2
);
913 skip("Failed to create the second window\n");
915 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
916 hwnd
, DDSCL_FULLSCREEN
| DDSCL_EXCLUSIVE
);
917 ok(rc
==DD_OK
,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc
);
920 ok(GetForegroundWindow()==hwnd
,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd
, hwnd2
);
922 /* rect_before_create is assumed to hold the screen rect */
923 GetClientRect(hwnd
, &window_rect
);
924 success
= EqualRect(&rect_before_create
, &window_rect
);
925 ok(success
, "Fullscreen window has wrong size.\n");
927 /* Set the focus window. Should fail */
928 rc
= IDirectDraw_SetCooperativeLevel(lpDD
,
929 hwnd
, DDSCL_SETFOCUSWINDOW
);
930 ok(rc
==DDERR_HWNDALREADYSET
||
931 broken(rc
==DDERR_INVALIDPARAMS
) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc
);
937 static void testddraw3(void)
939 const GUID My_IID_IDirectDraw3
= {
943 { 0x8f,0xcc,0x0,0xc0,0x4f,0xd9,0x18,0x9d }
947 hr
= IDirectDraw_QueryInterface(lpDD
, &My_IID_IDirectDraw3
, (void **) &dd3
);
948 ok(hr
== E_NOINTERFACE
, "QueryInterface for IID_IDirectDraw3 returned 0x%08x, expected E_NOINTERFACE\n", hr
);
949 if(SUCCEEDED(hr
) && dd3
) IDirectDraw3_Release(dd3
);
952 static void testddraw7(void)
956 DDDEVICEIDENTIFIER2
*pdddi2
;
960 hr
= IDirectDraw_QueryInterface(lpDD
, &IID_IDirectDraw7
, (void **) &dd7
);
961 if (hr
==E_NOINTERFACE
)
963 win_skip("DirectDraw7 is not supported\n");
966 ok(hr
==DD_OK
, "IDirectDraw7_QueryInterface returned %08x\n", hr
);
970 dddi2Bytes
= FIELD_OFFSET(DDDEVICEIDENTIFIER2
, dwWHQLLevel
) + sizeof(DWORD
);
972 pdddi2
= HeapAlloc( GetProcessHeap(), 0, dddi2Bytes
+ 2*sizeof(DWORD
) );
973 pend
= (DWORD
*)((char *)pdddi2
+ dddi2Bytes
);
974 pend
[0] = 0xdeadbeef;
975 pend
[1] = 0xdeadbeef;
977 hr
= IDirectDraw7_GetDeviceIdentifier(dd7
, pdddi2
, 0);
978 ok(hr
==DD_OK
, "get device identifier failed with %08x\n", hr
);
982 /* szDriver contains the name of the driver DLL */
983 ok(strstr(pdddi2
->szDriver
, ".dll")!=NULL
, "szDriver does not contain DLL name\n");
984 /* check how strings are copied into the structure */
985 ok(pdddi2
->szDriver
[MAX_DDDEVICEID_STRING
- 1]==0, "szDriver not cleared\n");
986 ok(pdddi2
->szDescription
[MAX_DDDEVICEID_STRING
- 1]==0, "szDescription not cleared\n");
987 /* verify that 8 byte structure size alignment will not overwrite memory */
988 ok(pend
[0]==0xdeadbeef || broken(pend
[0] != 0xdeadbeef), /* win2k */
989 "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
990 ok(pend
[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
993 /* recheck with the DDGDI_GETHOSTIDENTIFIER flag */
994 pend
[0] = 0xdeadbeef;
995 pend
[1] = 0xdeadbeef;
996 hr
= IDirectDraw7_GetDeviceIdentifier(dd7
, pdddi2
, DDGDI_GETHOSTIDENTIFIER
);
997 ok(hr
==DD_OK
, "get device identifier failed with %08x\n", hr
);
1000 /* szDriver contains the name of the driver DLL */
1001 ok(strstr(pdddi2
->szDriver
, ".dll")!=NULL
, "szDriver does not contain DLL name\n");
1002 /* check how strings are copied into the structure */
1003 ok(pdddi2
->szDriver
[MAX_DDDEVICEID_STRING
- 1]==0, "szDriver not cleared\n");
1004 ok(pdddi2
->szDescription
[MAX_DDDEVICEID_STRING
- 1]==0, "szDescription not cleared\n");
1005 /* verify that 8 byte structure size alignment will not overwrite memory */
1006 ok(pend
[0]==0xdeadbeef || broken(pend
[0] != 0xdeadbeef), /* win2k */
1007 "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
1008 ok(pend
[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
1011 IDirectDraw_Release(dd7
);
1012 HeapFree( GetProcessHeap(), 0, pdddi2
);
1016 START_TEST(ddrawmodes
)
1018 init_function_pointers();
1020 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
1021 wc
.lpfnWndProc
= DefWindowProcA
;
1022 wc
.hInstance
= GetModuleHandleA(0);
1023 wc
.hbrBackground
= GetStockObject(BLACK_BRUSH
);
1024 wc
.lpszClassName
= "TestWindowClass";
1025 if (!RegisterClassA(&wc
))
1027 skip("RegisterClassA failed\n");
1031 hwnd2
=createwindow();
1032 hwnd
=createwindow();
1036 skip("Failed to create the main window\n");
1040 if (!createdirectdraw())
1042 skip("Failed to create the direct draw object\n");
1046 test_DirectDrawEnumerateA();
1047 test_DirectDrawEnumerateW();
1048 test_DirectDrawEnumerateExA();
1049 test_DirectDrawEnumerateExW();
1052 if (winetest_interactive
)
1054 flushdisplaymodes();
1057 releasedirectdraw();
1060 testcooperativelevels_normal();
1061 releasedirectdraw();
1064 testcooperativelevels_exclusive();
1065 releasedirectdraw();