comctl32: Update thumb position on WM_MOUSEMOVE instead of deferring it.
[wine/multimedia.git] / dlls / ddraw / tests / ddrawmodes.c
bloba4b71fb9c606fccdaac037c5146a35399ba5d3ee
1 /*
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
28 #include <assert.h>
29 #include "wine/test.h"
30 #include "ddraw.h"
32 static LPDIRECTDRAW lpDD = NULL;
33 static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
34 static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
35 static WNDCLASS wc;
36 static HWND hwnd, hwnd2;
37 static int modes_cnt;
38 static int modes_size;
39 static LPDDSURFACEDESC 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,LPVOID);
47 static HRESULT (WINAPI *pDirectDrawEnumerateW)(LPDDENUMCALLBACKW,LPVOID);
48 static HRESULT (WINAPI *pDirectDrawEnumerateExA)(LPDDENUMCALLBACKEXA,LPVOID,DWORD);
49 static HRESULT (WINAPI *pDirectDrawEnumerateExW)(LPDDENUMCALLBACKEXW,LPVOID,DWORD);
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)
62 HWND hwnd;
64 hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
65 WS_POPUP, 0, 0,
66 GetSystemMetrics(SM_CXSCREEN),
67 GetSystemMetrics(SM_CYSCREEN),
68 NULL, NULL, GetModuleHandleA(0), NULL);
70 ShowWindow(hwnd, SW_HIDE);
71 UpdateWindow(hwnd);
72 SetFocus(hwnd);
74 return hwnd;
77 static BOOL createdirectdraw(void)
79 HRESULT rc;
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);
85 if (!lpDD) {
86 trace("DirectDrawCreateEx() failed with an error %x\n", rc);
87 return FALSE;
89 return TRUE;
93 static void releasedirectdraw(void)
95 if( lpDD != NULL )
97 IDirectDraw_Release(lpDD);
98 lpDD = NULL;
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, LPSTR lpDriverDescription,
108 LPSTR lpDriverName, LPVOID lpContext)
110 trace("test_nullcontext_callbackA: %p %s %s %p\n",
111 lpGUID, lpDriverDescription, lpDriverName, lpContext);
113 ok(!lpContext, "Expected NULL lpContext\n");
115 return TRUE;
118 static BOOL WINAPI test_context_callbackA(GUID *lpGUID, LPSTR lpDriverDescription,
119 LPSTR lpDriverName, LPVOID lpContext)
121 trace("test_context_callbackA: %p %s %s %p\n",
122 lpGUID, lpDriverDescription, lpDriverName, lpContext);
124 ok(lpContext == (LPVOID)0xdeadbeef, "Expected non-NULL lpContext\n");
126 return TRUE;
129 static void test_DirectDrawEnumerateA(void)
131 HRESULT ret;
133 if (!pDirectDrawEnumerateA)
135 win_skip("DirectDrawEnumerateA is not available\n");
136 return;
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, (LPVOID)0xdeadbeef);
151 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
154 static BOOL WINAPI test_callbackW(GUID *lpGUID, LPWSTR lpDriverDescription,
155 LPWSTR lpDriverName, LPVOID lpContext)
157 ok(0, "The callback should not be invoked by DirectDrawEnumerateW\n");
158 return TRUE;
161 static void test_DirectDrawEnumerateW(void)
163 HRESULT ret;
165 if (!pDirectDrawEnumerateW)
167 win_skip("DirectDrawEnumerateW is not available\n");
168 return;
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, LPSTR lpDriverDescription,
191 LPSTR lpDriverName, LPVOID lpContext,
192 HMONITOR hm)
194 trace("test_nullcontext_callbackExA: %p %s %s %p %p\n", lpGUID,
195 lpDriverDescription, lpDriverName, lpContext, hm);
197 ok(!lpContext, "Expected NULL lpContext\n");
199 return TRUE;
202 static BOOL WINAPI test_context_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
203 LPSTR lpDriverName, LPVOID lpContext,
204 HMONITOR hm)
206 trace("test_context_callbackExA: %p %s %s %p %p\n", lpGUID,
207 lpDriverDescription, lpDriverName, lpContext, hm);
209 ok(lpContext == (LPVOID)0xdeadbeef, "Expected non-NULL lpContext\n");
211 return TRUE;
214 static void test_DirectDrawEnumerateExA(void)
216 HRESULT ret;
218 if (!pDirectDrawEnumerateExA)
220 win_skip("DirectDrawEnumerateExA is not available\n");
221 return;
224 /* Test with NULL callback parameter. */
225 ret = pDirectDrawEnumerateExA(NULL, NULL, 0);
226 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
228 /* Test with valid callback parameter and invalid flags */
229 ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, ~0);
230 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
232 /* Test with valid callback parameter and NULL context parameter. */
233 trace("Calling DirectDrawEnumerateExA with empty flags and NULL context.\n");
234 ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, 0);
235 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
237 /* Test with valid callback parameter and non-NULL context parameter. */
238 trace("Calling DirectDrawEnumerateExA with empty flags and non-NULL context.\n");
239 ret = pDirectDrawEnumerateExA(test_context_callbackExA, (LPVOID)0xdeadbeef, 0);
240 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
242 /* Test with valid callback parameter, NULL context parameter, and all flags set. */
243 trace("Calling DirectDrawEnumerateExA with all flags set and NULL context.\n");
244 ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL,
245 DDENUM_ATTACHEDSECONDARYDEVICES |
246 DDENUM_DETACHEDSECONDARYDEVICES |
247 DDENUM_NONDISPLAYDEVICES);
248 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
251 static BOOL WINAPI test_callbackExW(GUID *lpGUID, LPWSTR lpDriverDescription,
252 LPWSTR lpDriverName, LPVOID lpContext,
253 HMONITOR hm)
255 ok(0, "The callback should not be invoked by DirectDrawEnumerateExW.\n");
256 return TRUE;
259 static void test_DirectDrawEnumerateExW(void)
261 HRESULT ret;
263 if (!pDirectDrawEnumerateExW)
265 win_skip("DirectDrawEnumerateExW is not available\n");
266 return;
269 /* DirectDrawEnumerateExW is not implemented on Windows. */
271 /* Test with NULL callback parameter. */
272 ret = pDirectDrawEnumerateExW(NULL, NULL, 0);
273 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
275 /* Test with invalid callback parameter. */
276 ret = pDirectDrawEnumerateExW((LPDDENUMCALLBACKEXW)0xdeadbeef, NULL, 0);
277 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
279 /* Test with valid callback parameter and invalid flags */
280 ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, ~0);
281 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
283 /* Test with valid callback parameter and NULL context parameter. */
284 ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, 0);
285 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
287 /* Test with valid callback parameter, NULL context parameter, and all flags set. */
288 ret = pDirectDrawEnumerateExW(test_callbackExW, NULL,
289 DDENUM_ATTACHEDSECONDARYDEVICES |
290 DDENUM_DETACHEDSECONDARYDEVICES |
291 DDENUM_NONDISPLAYDEVICES);
292 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
295 static void adddisplaymode(LPDDSURFACEDESC lpddsd)
297 if (!modes)
298 modes = HeapAlloc(GetProcessHeap(), 0, (modes_size = 2) * sizeof(DDSURFACEDESC));
299 if (modes_cnt == modes_size)
300 modes = HeapReAlloc(GetProcessHeap(), 0, modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
301 assert(modes);
302 modes[modes_cnt++] = *lpddsd;
305 static void flushdisplaymodes(void)
307 HeapFree(GetProcessHeap(), 0, modes);
308 modes = 0;
309 modes_cnt = modes_size = 0;
312 static HRESULT WINAPI enummodescallback(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
314 trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
315 lpddsd->dwWidth, lpddsd->dwHeight, U1(lpddsd->ddpfPixelFormat).dwRGBBitCount,
316 U2(*lpddsd).dwRefreshRate, U1(*lpddsd).lPitch, lpddsd->dwFlags);
318 /* Check that the pitch is valid if applicable */
319 if(lpddsd->dwFlags & DDSD_PITCH)
321 ok(U1(*lpddsd).lPitch != 0, "EnumDisplayModes callback with bad pitch\n");
324 /* Check that frequency is valid if applicable
326 * This fails on some Windows drivers or Windows versions, so it isn't important
327 * apparently
328 if(lpddsd->dwFlags & DDSD_REFRESHRATE)
330 ok(U2(*lpddsd).dwRefreshRate != 0, "EnumDisplayModes callback with bad refresh rate\n");
334 adddisplaymode(lpddsd);
335 if(U1(lpddsd->ddpfPixelFormat).dwRGBBitCount == 16)
336 modes16bpp_cnt++;
338 return DDENUMRET_OK;
341 static HRESULT WINAPI enummodescallback_16bit(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
343 trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
344 lpddsd->dwWidth, lpddsd->dwHeight, U1(lpddsd->ddpfPixelFormat).dwRGBBitCount,
345 U2(*lpddsd).dwRefreshRate, U1(*lpddsd).lPitch, lpddsd->dwFlags);
347 ok(lpddsd->dwFlags == (DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE),
348 "Wrong surface description flags %02X\n", lpddsd->dwFlags);
349 ok(lpddsd->ddpfPixelFormat.dwFlags == DDPF_RGB, "Wrong pixel format flag %02X\n",
350 lpddsd->ddpfPixelFormat.dwFlags);
351 ok(U1(lpddsd->ddpfPixelFormat).dwRGBBitCount == 16, "Expected 16 bpp got %i\n",
352 U1(lpddsd->ddpfPixelFormat).dwRGBBitCount);
354 /* Check that the pitch is valid if applicable */
355 if(lpddsd->dwFlags & DDSD_PITCH)
357 ok(U1(*lpddsd).lPitch != 0, "EnumDisplayModes callback with bad pitch\n");
360 if(!refresh_rate)
362 if(U2(*lpddsd).dwRefreshRate )
364 refresh_rate = U2(*lpddsd).dwRefreshRate;
365 refresh_rate_cnt++;
368 else
370 if(refresh_rate == U2(*lpddsd).dwRefreshRate)
371 refresh_rate_cnt++;
374 modes16bpp_cnt++;
376 return DDENUMRET_OK;
379 static HRESULT WINAPI enummodescallback_count(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
381 ok(lpddsd->dwFlags == (DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE),
382 "Wrong surface description flags %02X\n", lpddsd->dwFlags);
384 modes16bpp_cnt++;
386 return DDENUMRET_OK;
389 static void enumdisplaymodes(void)
391 DDSURFACEDESC ddsd;
392 HRESULT rc;
393 int count, refresh_count;
395 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
396 ddsd.dwSize = sizeof(DDSURFACEDESC);
397 ddsd.dwFlags = DDSD_CAPS;
398 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
400 /* Flags parameter is reserved in very old ddraw versions (3 and older?) and must be 0 */
401 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback);
402 ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
404 count = modes16bpp_cnt;
406 modes16bpp_cnt = 0;
407 ddsd.dwFlags = DDSD_PIXELFORMAT;
408 ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
409 U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 16;
410 U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xf800;
411 U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x07e0;
412 U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001F;
414 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
415 ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
416 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
418 modes16bpp_cnt = 0;
419 U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x0000;
420 U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000;
421 U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000;
423 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
424 ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
425 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
427 modes16bpp_cnt = 0;
428 U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xF0F0;
429 U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0F00;
430 U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000F;
432 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
433 ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
434 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
437 modes16bpp_cnt = 0;
438 ddsd.ddpfPixelFormat.dwFlags = DDPF_YUV;
440 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
441 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
442 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
444 modes16bpp_cnt = 0;
445 ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8;
447 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
448 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
449 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
451 modes16bpp_cnt = 0;
452 ddsd.dwFlags = DDSD_PIXELFORMAT;
453 ddsd.ddpfPixelFormat.dwFlags = 0;
455 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
456 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
457 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
459 modes16bpp_cnt = 0;
460 ddsd.dwFlags = 0;
462 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_count);
463 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
464 ok(modes16bpp_cnt == modes_cnt, "Expected %d modes got %d\n", modes_cnt, modes16bpp_cnt);
466 modes16bpp_cnt = 0;
467 ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_PITCH;
468 U1(ddsd).lPitch = 123;
470 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
471 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
472 ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
474 modes16bpp_cnt = 0;
475 ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
476 U2(ddsd).dwRefreshRate = 1;
478 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
479 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
480 ok(modes16bpp_cnt == 0, "Expected 0 modes got %d\n", modes16bpp_cnt);
482 modes16bpp_cnt = 0;
483 ddsd.dwFlags = DDSD_PIXELFORMAT;
485 rc = IDirectDraw_EnumDisplayModes(lpDD, DDEDM_REFRESHRATES, &ddsd, 0, enummodescallback_16bit);
486 if(rc == DDERR_INVALIDPARAMS)
488 skip("Ddraw version too old. Skipping.\n");
489 return;
491 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
492 refresh_count = refresh_rate_cnt;
494 if(refresh_rate)
496 modes16bpp_cnt = 0;
497 ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
498 U2(ddsd).dwRefreshRate = refresh_rate;
500 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
501 ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
502 ok(modes16bpp_cnt == refresh_count, "Expected %d modes got %d\n", refresh_count, modes16bpp_cnt);
505 rc = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, 0, enummodescallback);
506 ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
510 static void setdisplaymode(int i)
512 HRESULT rc;
513 RECT orig_rect;
515 SetRect(&orig_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
517 rc = IDirectDraw_SetCooperativeLevel(lpDD,
518 hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
519 ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
520 if (modes[i].dwFlags & DDSD_PIXELFORMAT)
522 if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
524 rc = IDirectDraw_SetDisplayMode(lpDD,
525 modes[i].dwWidth, modes[i].dwHeight,
526 U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
527 ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc);
528 if (rc == DD_OK)
530 RECT r, scrn, test, virt;
532 SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
533 OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN));
534 SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
535 trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight,
536 scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom);
537 if (!EqualRect(&scrn, &orig_rect))
539 HRESULT rect_result;
541 /* Check that the client rect was resized */
542 rc = GetClientRect(hwnd, &test);
543 ok(rc!=0, "GetClientRect returned %x\n", rc);
544 rc = EqualRect(&scrn, &test);
545 todo_wine ok(rc!=0, "Fullscreen window has wrong size\n");
547 /* Check that switching to normal cooperative level
548 does not restore the display mode */
549 rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL);
550 ok(rc==DD_OK, "SetCooperativeLevel returned %x\n", rc);
551 SetRect(&test, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
552 rect_result = EqualRect(&scrn, &test);
553 ok(rect_result!=0, "Setting cooperative level to DDSCL_NORMAL changed the display mode\n");
555 /* Go back to fullscreen */
556 rc = IDirectDraw_SetCooperativeLevel(lpDD,
557 hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
558 ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n",rc);
560 /* If the display mode was changed, set the correct mode
561 to avoid irrelevant failures */
562 if (rect_result == 0)
564 rc = IDirectDraw_SetDisplayMode(lpDD,
565 modes[i].dwWidth, modes[i].dwHeight,
566 U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
567 ok(DD_OK==rc, "SetDisplayMode returned: %x\n",rc);
570 ok(GetClipCursor(&r), "GetClipCursor() failed\n");
571 /* ddraw sets clip rect here to the screen size, even for
572 multiple monitors */
573 ok(EqualRect(&r, &scrn), "Invalid clip rect: (%d %d) x (%d %d)\n",
574 r.left, r.top, r.right, r.bottom);
576 ok(ClipCursor(NULL), "ClipCursor() failed\n");
577 ok(GetClipCursor(&r), "GetClipCursor() failed\n");
578 ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n",
579 r.left, r.top, r.right, r.bottom);
581 rc = IDirectDraw_RestoreDisplayMode(lpDD);
582 ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc);
588 static void createsurface(void)
590 DDSURFACEDESC ddsd;
591 DDSCAPS ddscaps;
592 HRESULT rc;
594 ddsd.dwSize = sizeof(ddsd);
595 ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
596 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
597 DDSCAPS_FLIP |
598 DDSCAPS_COMPLEX;
599 ddsd.dwBackBufferCount = 1;
600 rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL );
601 ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
602 ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
603 rc = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddscaps, &lpDDSBack);
604 ok(rc==DD_OK,"GetAttachedSurface returned: %x\n",rc);
607 static void destroysurface(void)
609 if( lpDDSPrimary != NULL )
611 IDirectDrawSurface_Release(lpDDSPrimary);
612 lpDDSPrimary = NULL;
616 static void testsurface(void)
618 const char* testMsg = "ddraw device context test";
619 HDC hdc;
620 HRESULT rc;
622 rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
623 ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc);
624 SetBkColor(hdc, RGB(0, 0, 255));
625 SetTextColor(hdc, RGB(255, 255, 0));
626 TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg));
627 IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
628 ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
630 while (1)
632 rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
633 ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %x\n",rc);
635 if (rc == DD_OK)
637 break;
639 else if (rc == DDERR_SURFACELOST)
641 rc = IDirectDrawSurface_Restore(lpDDSPrimary);
642 ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %x\n",rc);
647 static void testdisplaymodes(void)
649 int i;
651 for (i = 0; i < modes_cnt; ++i)
653 setdisplaymode(i);
654 createsurface();
655 testsurface();
656 destroysurface();
660 static void testcooperativelevels_normal(void)
662 BOOL sfw;
663 HRESULT rc;
664 DDSURFACEDESC surfacedesc;
665 IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
667 memset(&surfacedesc, 0, sizeof(surfacedesc));
668 surfacedesc.dwSize = sizeof(surfacedesc);
669 surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat);
670 surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
671 surfacedesc.dwBackBufferCount = 1;
672 surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
674 rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
675 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
677 /* Do some tests with DDSCL_NORMAL mode */
679 /* Fullscreen mode + normal mode + exclusive mode */
681 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
682 ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received: %x\n", rc);
684 sfw=FALSE;
685 if(hwnd2)
686 sfw=SetForegroundWindow(hwnd2);
687 else
688 skip("Failed to create the second window\n");
690 rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
691 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
693 if(sfw)
694 ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
696 /* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
697 rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
699 if (rc == DDERR_UNSUPPORTEDMODE)
700 skip("Unsupported mode\n");
701 else
703 ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc);
704 ok(surface!=NULL, "Returned NULL surface pointer\n");
706 if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
708 /* Exclusive mode + normal mode */
709 rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
710 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
712 /* Fullscreen mode + normal mode */
714 sfw=FALSE;
715 if(hwnd2) sfw=SetForegroundWindow(hwnd2);
717 rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
718 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);
720 if(sfw)
721 ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
723 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL);
724 ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
726 /* Try creating a double buffered primary in fullscreen + normal mode */
727 rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
728 if (rc == DDERR_UNSUPPORTEDMODE)
729 skip("Unsupported mode\n");
730 else
732 ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
733 ok(surface == NULL, "Returned surface pointer is %p\n", surface);
736 if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
738 /* switching from Fullscreen mode to Normal mode */
740 sfw=FALSE;
741 if(hwnd2) sfw=SetForegroundWindow(hwnd2);
743 rc = IDirectDraw_SetCooperativeLevel(lpDD,
744 hwnd, DDSCL_NORMAL);
745 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
747 if(sfw)
748 ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
750 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
751 ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
753 /* Try creating a double buffered primary in normal mode */
754 rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
755 if (rc == DDERR_UNSUPPORTEDMODE)
756 skip("Unsupported mode\n");
757 else
759 ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
760 ok(surface == NULL, "Returned surface pointer is %p\n", surface);
762 if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
764 /* switching from Normal mode to Fullscreen + Normal mode */
766 sfw=FALSE;
767 if(hwnd2) sfw=SetForegroundWindow(hwnd2);
769 rc = IDirectDraw_SetCooperativeLevel(lpDD,
770 hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN);
771 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc);
773 if(sfw)
774 ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
776 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN);
777 ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
779 /* Set the focus window */
781 rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
782 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
784 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_SETFOCUSWINDOW);
786 if (rc == DDERR_INVALIDPARAMS)
788 win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
789 return;
792 ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
794 rc = IDirectDraw_SetCooperativeLevel(lpDD,
795 hwnd, DDSCL_SETFOCUSWINDOW);
797 if (rc == DDERR_INVALIDPARAMS)
799 win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
800 return;
803 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
805 /* Set the focus window a second time*/
806 rc = IDirectDraw_SetCooperativeLevel(lpDD,
807 hwnd, DDSCL_SETFOCUSWINDOW);
808 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);
810 /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
811 rc = IDirectDraw_SetCooperativeLevel(lpDD,
812 hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
813 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
815 rc = IDirectDraw_SetCooperativeLevel(lpDD,
816 hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
817 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
819 /* This one succeeds */
820 rc = IDirectDraw_SetCooperativeLevel(lpDD,
821 hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
822 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
824 rc = IDirectDraw_SetCooperativeLevel(lpDD,
825 hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
826 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
828 rc = IDirectDraw_SetCooperativeLevel(lpDD,
829 hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
830 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
832 rc = IDirectDraw_SetCooperativeLevel(lpDD,
833 hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
834 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
836 rc = IDirectDraw_SetCooperativeLevel(lpDD,
837 hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
838 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
840 rc = IDirectDraw_SetCooperativeLevel(lpDD,
841 hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
842 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
844 /* Set the device window without any other flags. Should give an error */
845 rc = IDirectDraw_SetCooperativeLevel(lpDD,
846 hwnd, DDSCL_SETDEVICEWINDOW);
847 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
849 /* Set device window with DDSCL_NORMAL */
850 rc = IDirectDraw_SetCooperativeLevel(lpDD,
851 hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
852 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
854 /* Also set the focus window. Should give an error */
855 rc = IDirectDraw_SetCooperativeLevel(lpDD,
856 hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
857 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
859 /* All done */
862 static void testcooperativelevels_exclusive(void)
864 BOOL sfw, success;
865 HRESULT rc;
866 RECT window_rect;
868 /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
870 /* First, resize the window so it is not the same size as any screen */
871 success = SetWindowPos(hwnd, 0, 0, 0, 281, 92, 0);
872 ok(success, "SetWindowPos failed\n");
874 /* Try to set exclusive mode only */
875 rc = IDirectDraw_SetCooperativeLevel(lpDD,
876 hwnd, DDSCL_EXCLUSIVE);
877 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc);
879 /* Full screen mode only */
880 rc = IDirectDraw_SetCooperativeLevel(lpDD,
881 hwnd, DDSCL_FULLSCREEN);
882 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
884 /* Full screen mode + exclusive mode */
886 rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
887 ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %x\n", rc);
889 sfw=FALSE;
890 if(hwnd2)
891 sfw=SetForegroundWindow(hwnd2);
892 else
893 skip("Failed to create the second window\n");
895 rc = IDirectDraw_SetCooperativeLevel(lpDD,
896 hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
897 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
899 if(sfw)
900 ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
902 /* rect_before_create is assumed to hold the screen rect */
903 GetClientRect(hwnd, &window_rect);
904 rc = EqualRect(&rect_before_create, &window_rect);
905 ok(rc, "Fullscreen window has wrong size.\n");
907 /* Set the focus window. Should fail */
908 rc = IDirectDraw_SetCooperativeLevel(lpDD,
909 hwnd, DDSCL_SETFOCUSWINDOW);
910 ok(rc==DDERR_HWNDALREADYSET ||
911 broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
914 /* All done */
917 static void testddraw3(void)
919 const GUID My_IID_IDirectDraw3 = {
920 0x618f8ad4,
921 0x8b7a,
922 0x11d0,
923 { 0x8f,0xcc,0x0,0xc0,0x4f,0xd9,0x18,0x9d }
925 IDirectDraw3 *dd3;
926 HRESULT hr;
927 hr = IDirectDraw_QueryInterface(lpDD, &My_IID_IDirectDraw3, (void **) &dd3);
928 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectDraw3 returned 0x%08x, expected E_NOINTERFACE\n", hr);
929 if(SUCCEEDED(hr) && dd3) IDirectDraw3_Release(dd3);
932 static void testddraw7(void)
934 IDirectDraw7 *dd7;
935 HRESULT hr;
936 DDDEVICEIDENTIFIER2 *pdddi2;
937 DWORD dddi2Bytes;
938 DWORD *pend;
940 hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
941 if (hr==E_NOINTERFACE)
943 win_skip("DirectDraw7 is not supported\n");
944 return;
946 ok(hr==DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
948 if (hr==DD_OK)
950 dddi2Bytes = FIELD_OFFSET(DDDEVICEIDENTIFIER2, dwWHQLLevel) + sizeof(DWORD);
952 pdddi2 = HeapAlloc( GetProcessHeap(), 0, dddi2Bytes + 2*sizeof(DWORD) );
953 pend = (DWORD *)((char *)pdddi2 + dddi2Bytes);
954 pend[0] = 0xdeadbeef;
955 pend[1] = 0xdeadbeef;
957 hr = IDirectDraw7_GetDeviceIdentifier(dd7, pdddi2, 0);
958 ok(hr==DD_OK, "get device identifier failed with %08x\n", hr);
960 if (hr==DD_OK)
962 /* check how strings are copied into the structure */
963 ok(pdddi2->szDriver[MAX_DDDEVICEID_STRING - 1]==0, "szDriver not cleared\n");
964 ok(pdddi2->szDescription[MAX_DDDEVICEID_STRING - 1]==0, "szDescription not cleared\n");
965 /* verify that 8 byte structure size alignment will not overwrite memory */
966 ok(pend[0]==0xdeadbeef || broken(pend[0] != 0xdeadbeef), /* win2k */
967 "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
968 ok(pend[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
971 IDirectDraw_Release(dd7);
972 HeapFree( GetProcessHeap(), 0, pdddi2 );
976 START_TEST(ddrawmodes)
978 init_function_pointers();
980 wc.style = CS_HREDRAW | CS_VREDRAW;
981 wc.lpfnWndProc = DefWindowProcA;
982 wc.cbClsExtra = 0;
983 wc.cbWndExtra = 0;
984 wc.hInstance = GetModuleHandleA(0);
985 wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
986 wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
987 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
988 wc.lpszMenuName = NULL;
989 wc.lpszClassName = "TestWindowClass";
990 if (!RegisterClassA(&wc))
992 skip("RegisterClassA failed\n");
993 return;
996 hwnd2=createwindow();
997 hwnd=createwindow();
999 if (!hwnd)
1001 skip("Failed to create the main window\n");
1002 return;
1005 if (!createdirectdraw())
1007 skip("Failed to create the direct draw object\n");
1008 return;
1011 test_DirectDrawEnumerateA();
1012 test_DirectDrawEnumerateW();
1013 test_DirectDrawEnumerateExA();
1014 test_DirectDrawEnumerateExW();
1016 enumdisplaymodes();
1017 if (winetest_interactive)
1018 testdisplaymodes();
1019 flushdisplaymodes();
1020 testddraw3();
1021 testddraw7();
1022 releasedirectdraw();
1024 createdirectdraw();
1025 testcooperativelevels_normal();
1026 releasedirectdraw();
1028 createdirectdraw();
1029 testcooperativelevels_exclusive();
1030 releasedirectdraw();