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 LPDIRECTDRAW lpDD = NULL;
33 static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
34 static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
38 static int modes_size;
39 static LPDDSURFACEDESC modes;
41 static HRESULT (WINAPI *pDirectDrawEnumerateA)(LPDDENUMCALLBACKA,LPVOID);
42 static HRESULT (WINAPI *pDirectDrawEnumerateW)(LPDDENUMCALLBACKW,LPVOID);
43 static HRESULT (WINAPI *pDirectDrawEnumerateExA)(LPDDENUMCALLBACKEXA,LPVOID,DWORD);
44 static HRESULT (WINAPI *pDirectDrawEnumerateExW)(LPDDENUMCALLBACKEXW,LPVOID,DWORD);
46 static void init_function_pointers(void)
48 HMODULE hmod = GetModuleHandleA("ddraw.dll");
49 pDirectDrawEnumerateA = (void*)GetProcAddress(hmod, "DirectDrawEnumerateA");
50 pDirectDrawEnumerateW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateW");
51 pDirectDrawEnumerateExA = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExA");
52 pDirectDrawEnumerateExW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExW");
55 static void createwindow(void)
57 wc.style = CS_HREDRAW | CS_VREDRAW;
58 wc.lpfnWndProc = DefWindowProcA;
61 wc.hInstance = GetModuleHandleA(0);
62 wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
63 wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
64 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
65 wc.lpszMenuName = NULL;
66 wc.lpszClassName = "TestWindowClass";
67 if(!RegisterClassA(&wc))
70 hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
72 GetSystemMetrics(SM_CXSCREEN),
73 GetSystemMetrics(SM_CYSCREEN),
74 NULL, NULL, GetModuleHandleA(0), NULL);
77 ShowWindow(hwnd, SW_HIDE);
82 static BOOL createdirectdraw(void)
86 rc = DirectDrawCreate(NULL, &lpDD, NULL);
87 ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
89 trace("DirectDrawCreateEx() failed with an error %x\n", rc);
96 static void releasedirectdraw(void)
100 IDirectDraw_Release(lpDD);
105 static BOOL WINAPI crash_callbackA(GUID *lpGUID, LPSTR lpDriverDescription,
106 LPSTR lpDriverName, LPVOID lpContext)
108 *(volatile char*)0 = 2;
112 static BOOL WINAPI test_nullcontext_callbackA(GUID *lpGUID, LPSTR lpDriverDescription,
113 LPSTR lpDriverName, LPVOID lpContext)
115 trace("test_nullcontext_callbackA: %p %s %s %p\n",
116 lpGUID, lpDriverDescription, lpDriverName, lpContext);
118 ok(!lpContext, "Expected NULL lpContext\n");
123 static BOOL WINAPI test_context_callbackA(GUID *lpGUID, LPSTR lpDriverDescription,
124 LPSTR lpDriverName, LPVOID lpContext)
126 trace("test_context_callbackA: %p %s %s %p\n",
127 lpGUID, lpDriverDescription, lpDriverName, lpContext);
129 ok(lpContext == (LPVOID)0xdeadbeef, "Expected non-NULL lpContext\n");
134 static void test_DirectDrawEnumerateA(void)
138 if (!pDirectDrawEnumerateA)
140 win_skip("DirectDrawEnumerateA is not available\n");
144 /* Test with NULL callback parameter. */
145 ret = pDirectDrawEnumerateA(NULL, NULL);
146 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
148 /* Test with invalid callback parameter. */
149 ret = pDirectDrawEnumerateA((LPDDENUMCALLBACKA)0xdeadbeef, NULL);
150 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
152 /* Test with callback that crashes. */
153 ret = pDirectDrawEnumerateA(crash_callbackA, NULL);
154 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
156 /* Test with valid callback parameter and NULL context parameter. */
157 trace("Calling DirectDrawEnumerateA with test_nullcontext_callbackA callback and NULL context.\n");
158 ret = pDirectDrawEnumerateA(test_nullcontext_callbackA, NULL);
159 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
161 /* Test with valid callback parameter and valid context parameter. */
162 trace("Calling DirectDrawEnumerateA with test_context_callbackA callback and non-NULL context.\n");
163 ret = pDirectDrawEnumerateA(test_context_callbackA, (LPVOID)0xdeadbeef);
164 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
167 static BOOL WINAPI test_callbackW(GUID *lpGUID, LPWSTR lpDriverDescription,
168 LPWSTR lpDriverName, LPVOID lpContext)
170 ok(0, "The callback should not be invoked by DirectDrawEnumerateW\n");
174 static void test_DirectDrawEnumerateW(void)
178 if (!pDirectDrawEnumerateW)
180 win_skip("DirectDrawEnumerateW is not available\n");
184 /* DirectDrawEnumerateW is not implemented on Windows. */
186 /* Test with NULL callback parameter. */
187 ret = pDirectDrawEnumerateW(NULL, NULL);
188 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
190 /* Test with invalid callback parameter. */
191 ret = pDirectDrawEnumerateW((LPDDENUMCALLBACKW)0xdeadbeef, NULL);
192 ok(ret == DDERR_INVALIDPARAMS /* XP */ ||
193 ret == DDERR_UNSUPPORTED /* Win7 */,
194 "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret);
196 /* Test with valid callback parameter and NULL context parameter. */
197 ret = pDirectDrawEnumerateW(test_callbackW, NULL);
198 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
201 static BOOL WINAPI crash_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
202 LPSTR lpDriverName, LPVOID lpContext,
205 *(volatile char*)0 = 2;
209 static BOOL WINAPI test_nullcontext_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
210 LPSTR lpDriverName, LPVOID lpContext,
213 trace("test_nullcontext_callbackExA: %p %s %s %p %p\n", lpGUID,
214 lpDriverDescription, lpDriverName, lpContext, hm);
216 ok(!lpContext, "Expected NULL lpContext\n");
221 static BOOL WINAPI test_context_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
222 LPSTR lpDriverName, LPVOID lpContext,
225 trace("test_context_callbackExA: %p %s %s %p %p\n", lpGUID,
226 lpDriverDescription, lpDriverName, lpContext, hm);
228 ok(lpContext == (LPVOID)0xdeadbeef, "Expected non-NULL lpContext\n");
233 static void test_DirectDrawEnumerateExA(void)
237 if (!pDirectDrawEnumerateExA)
239 win_skip("DirectDrawEnumerateExA is not available\n");
243 /* Test with NULL callback parameter. */
244 ret = pDirectDrawEnumerateExA(NULL, NULL, 0);
245 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
247 /* Test with invalid callback parameter. */
248 ret = pDirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)0xdeadbeef, NULL, 0);
249 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
251 /* Test with callback that crashes. */
252 ret = pDirectDrawEnumerateExA(crash_callbackExA, NULL, 0);
253 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
255 /* Test with valid callback parameter and invalid flags */
256 ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, ~0);
257 ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
259 /* Test with valid callback parameter and NULL context parameter. */
260 trace("Calling DirectDrawEnumerateExA with empty flags and NULL context.\n");
261 ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, 0);
262 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
264 /* Test with valid callback parameter and non-NULL context parameter. */
265 trace("Calling DirectDrawEnumerateExA with empty flags and non-NULL context.\n");
266 ret = pDirectDrawEnumerateExA(test_context_callbackExA, (LPVOID)0xdeadbeef, 0);
267 ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
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, LPWSTR lpDriverDescription,
279 LPWSTR lpDriverName, LPVOID lpContext,
282 ok(0, "The callback should not be invoked by DirectDrawEnumerateExW.\n");
286 static void test_DirectDrawEnumerateExW(void)
290 if (!pDirectDrawEnumerateExW)
292 win_skip("DirectDrawEnumerateExW is not available\n");
296 /* DirectDrawEnumerateExW is not implemented on Windows. */
298 /* Test with NULL callback parameter. */
299 ret = pDirectDrawEnumerateExW(NULL, NULL, 0);
300 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
302 /* Test with invalid callback parameter. */
303 ret = pDirectDrawEnumerateExW((LPDDENUMCALLBACKEXW)0xdeadbeef, NULL, 0);
304 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
306 /* Test with valid callback parameter and invalid flags */
307 ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, ~0);
308 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
310 /* Test with valid callback parameter and NULL context parameter. */
311 ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, 0);
312 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
314 /* Test with valid callback parameter, NULL context parameter, and all flags set. */
315 ret = pDirectDrawEnumerateExW(test_callbackExW, NULL,
316 DDENUM_ATTACHEDSECONDARYDEVICES |
317 DDENUM_DETACHEDSECONDARYDEVICES |
318 DDENUM_NONDISPLAYDEVICES);
319 ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
322 static void adddisplaymode(LPDDSURFACEDESC lpddsd)
325 modes = HeapAlloc(GetProcessHeap(), 0, (modes_size = 2) * sizeof(DDSURFACEDESC));
326 if (modes_cnt == modes_size)
327 modes = HeapReAlloc(GetProcessHeap(), 0, modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
329 modes[modes_cnt++] = *lpddsd;
332 static void flushdisplaymodes(void)
334 HeapFree(GetProcessHeap(), 0, modes);
336 modes_cnt = modes_size = 0;
339 static HRESULT WINAPI enummodescallback(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
341 trace("Width = %i, Height = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\r\n",
342 lpddsd->dwWidth, lpddsd->dwHeight,
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);
366 static void enumdisplaymodes(void)
371 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
372 ddsd.dwSize = sizeof(DDSURFACEDESC);
373 ddsd.dwFlags = DDSD_CAPS;
374 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
376 rc = IDirectDraw_EnumDisplayModes(lpDD,
377 DDEDM_STANDARDVGAMODES, &ddsd, 0, enummodescallback);
378 ok(rc==DD_OK || rc==E_INVALIDARG,"EnumDisplayModes returned: %x\n",rc);
381 static void setdisplaymode(int i)
385 rc = IDirectDraw_SetCooperativeLevel(lpDD,
386 hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
387 ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
388 if (modes[i].dwFlags & DDSD_PIXELFORMAT)
390 if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
392 rc = IDirectDraw_SetDisplayMode(lpDD,
393 modes[i].dwWidth, modes[i].dwHeight,
394 U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
395 ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc);
400 SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
401 OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN));
402 SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
403 trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight,
404 scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom);
406 ok(GetClipCursor(&r), "GetClipCursor() failed\n");
407 /* ddraw sets clip rect here to the screen size, even for
409 ok(EqualRect(&r, &scrn), "Invalid clip rect: (%d %d) x (%d %d)\n",
410 r.left, r.top, r.right, r.bottom);
412 ok(ClipCursor(NULL), "ClipCursor() failed\n");
413 ok(GetClipCursor(&r), "GetClipCursor() failed\n");
414 ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n",
415 r.left, r.top, r.right, r.bottom);
417 rc = IDirectDraw_RestoreDisplayMode(lpDD);
418 ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc);
424 static void createsurface(void)
430 ddsd.dwSize = sizeof(ddsd);
431 ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
432 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
435 ddsd.dwBackBufferCount = 1;
436 rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL );
437 ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
438 ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
439 rc = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddscaps, &lpDDSBack);
440 ok(rc==DD_OK,"GetAttachedSurface returned: %x\n",rc);
443 static void destroysurface(void)
445 if( lpDDSPrimary != NULL )
447 IDirectDrawSurface_Release(lpDDSPrimary);
452 static void testsurface(void)
454 const char* testMsg = "ddraw device context test";
458 rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
459 ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc);
460 SetBkColor(hdc, RGB(0, 0, 255));
461 SetTextColor(hdc, RGB(255, 255, 0));
462 TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg));
463 IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
464 ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
468 rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
469 ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %x\n",rc);
475 else if (rc == DDERR_SURFACELOST)
477 rc = IDirectDrawSurface_Restore(lpDDSPrimary);
478 ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %x\n",rc);
483 static void testdisplaymodes(void)
487 for (i = 0; i < modes_cnt; ++i)
496 static void testcooperativelevels_normal(void)
499 DDSURFACEDESC surfacedesc;
500 IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
502 memset(&surfacedesc, 0, sizeof(surfacedesc));
503 surfacedesc.dwSize = sizeof(surfacedesc);
504 surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat);
505 surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
506 surfacedesc.dwBackBufferCount = 1;
507 surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
509 /* Do some tests with DDSCL_NORMAL mode */
511 rc = IDirectDraw_SetCooperativeLevel(lpDD,
513 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
515 /* Try creating a double buffered primary in normal mode */
516 rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
517 if (rc == DDERR_UNSUPPORTEDMODE)
518 skip("Unsupported mode\n");
521 ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
522 ok(surface == NULL, "Returned surface pointer is %p\n", surface);
524 if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
526 /* Set the focus window */
527 rc = IDirectDraw_SetCooperativeLevel(lpDD,
528 hwnd, DDSCL_SETFOCUSWINDOW);
530 if (rc == DDERR_INVALIDPARAMS)
532 win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
536 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
538 /* Set the focus window a second time*/
539 rc = IDirectDraw_SetCooperativeLevel(lpDD,
540 hwnd, DDSCL_SETFOCUSWINDOW);
541 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);
543 /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
544 rc = IDirectDraw_SetCooperativeLevel(lpDD,
545 hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
546 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
548 rc = IDirectDraw_SetCooperativeLevel(lpDD,
549 hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
550 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
552 /* This one succeeds */
553 rc = IDirectDraw_SetCooperativeLevel(lpDD,
554 hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
555 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
557 rc = IDirectDraw_SetCooperativeLevel(lpDD,
558 hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
559 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
561 rc = IDirectDraw_SetCooperativeLevel(lpDD,
562 hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
563 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
565 rc = IDirectDraw_SetCooperativeLevel(lpDD,
566 hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
567 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
569 rc = IDirectDraw_SetCooperativeLevel(lpDD,
570 hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
571 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
573 rc = IDirectDraw_SetCooperativeLevel(lpDD,
574 hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
575 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
577 /* Set the device window without any other flags. Should give an error */
578 rc = IDirectDraw_SetCooperativeLevel(lpDD,
579 hwnd, DDSCL_SETDEVICEWINDOW);
580 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
582 /* Set device window with DDSCL_NORMAL */
583 rc = IDirectDraw_SetCooperativeLevel(lpDD,
584 hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
585 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
587 /* Also set the focus window. Should give an error */
588 rc = IDirectDraw_SetCooperativeLevel(lpDD,
589 hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
590 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
595 static void testcooperativelevels_exclusive(void)
599 /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
601 /* Try to set exclusive mode only */
602 rc = IDirectDraw_SetCooperativeLevel(lpDD,
603 hwnd, DDSCL_EXCLUSIVE);
604 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc);
606 /* Full screen mode only */
607 rc = IDirectDraw_SetCooperativeLevel(lpDD,
608 hwnd, DDSCL_FULLSCREEN);
609 ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
611 /* Full screen mode + exclusive mode */
612 rc = IDirectDraw_SetCooperativeLevel(lpDD,
613 hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
614 ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
616 /* Set the focus window. Should fail */
617 rc = IDirectDraw_SetCooperativeLevel(lpDD,
618 hwnd, DDSCL_SETFOCUSWINDOW);
619 ok(rc==DDERR_HWNDALREADYSET ||
620 broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
626 static void testddraw3(void)
628 const GUID My_IID_IDirectDraw3 = {
632 { 0x8f,0xcc,0x0,0xc0,0x4f,0xd9,0x18,0x9d }
636 hr = IDirectDraw_QueryInterface(lpDD, &My_IID_IDirectDraw3, (void **) &dd3);
637 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectDraw3 returned 0x%08x, expected E_NOINTERFACE\n", hr);
638 if(SUCCEEDED(hr) && dd3) IDirectDraw3_Release(dd3);
641 START_TEST(ddrawmodes)
643 init_function_pointers();
646 if (!createdirectdraw())
649 test_DirectDrawEnumerateA();
650 test_DirectDrawEnumerateW();
651 test_DirectDrawEnumerateExA();
652 test_DirectDrawEnumerateExW();
655 if (winetest_interactive)
662 testcooperativelevels_normal();
666 testcooperativelevels_exclusive();