2003-11-18 01:12:00 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for ddraw functions
|
|
|
|
*
|
2006-09-29 13:03:40 +02:00
|
|
|
*
|
|
|
|
* Part of this test involves changing the screen resolution. But this is
|
|
|
|
* really disrupting if the user is doing something else and is not very nice
|
|
|
|
* to CRT screens. Plus, ideally it needs someone watching it to check that
|
|
|
|
* each mode displays correctly.
|
|
|
|
* So this is only done if the test is being run in interactive mode.
|
|
|
|
*
|
2003-11-18 01:12:00 +01:00
|
|
|
* Copyright (C) 2003 Sami Aario
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-11-18 01:12:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "ddraw.h"
|
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
static LPDIRECTDRAW lpDD = NULL;
|
|
|
|
static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
|
|
|
|
static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
|
2003-11-18 01:12:00 +01:00
|
|
|
static WNDCLASS wc;
|
|
|
|
static HWND hwnd;
|
|
|
|
static int modes_cnt;
|
|
|
|
static int modes_size;
|
|
|
|
static LPDDSURFACEDESC modes;
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
static void createwindow(void)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wc.lpfnWndProc = DefWindowProcA;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = GetModuleHandleA(0);
|
|
|
|
wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
|
|
|
|
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
|
2008-12-05 07:51:16 +01:00
|
|
|
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
2003-11-18 01:12:00 +01:00
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = "TestWindowClass";
|
|
|
|
if(!RegisterClassA(&wc))
|
|
|
|
assert(0);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
|
|
|
|
WS_POPUP, 0, 0,
|
|
|
|
GetSystemMetrics(SM_CXSCREEN),
|
|
|
|
GetSystemMetrics(SM_CYSCREEN),
|
|
|
|
NULL, NULL, GetModuleHandleA(0), NULL);
|
2004-02-16 21:23:58 +01:00
|
|
|
assert(hwnd != NULL);
|
2003-11-18 01:12:00 +01:00
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
UpdateWindow(hwnd);
|
|
|
|
SetFocus(hwnd);
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
}
|
|
|
|
|
2006-08-30 05:56:32 +02:00
|
|
|
static BOOL createdirectdraw(void)
|
2005-10-06 14:26:04 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
|
2003-11-18 01:12:00 +01:00
|
|
|
rc = DirectDrawCreate(NULL, &lpDD, NULL);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
|
2006-08-30 05:56:32 +02:00
|
|
|
if (!lpDD) {
|
2006-10-10 19:23:33 +02:00
|
|
|
trace("DirectDrawCreateEx() failed with an error %x\n", rc);
|
2006-08-30 05:56:32 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2003-11-18 01:12:00 +01:00
|
|
|
}
|
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void releasedirectdraw(void)
|
2004-02-16 21:23:58 +01:00
|
|
|
{
|
|
|
|
if( lpDD != NULL )
|
|
|
|
{
|
|
|
|
IDirectDraw_Release(lpDD);
|
|
|
|
lpDD = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void adddisplaymode(LPDDSURFACEDESC lpddsd)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
|
|
|
if (!modes)
|
|
|
|
modes = malloc((modes_size = 2) * sizeof(DDSURFACEDESC));
|
|
|
|
if (modes_cnt == modes_size)
|
|
|
|
modes = realloc(modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
|
|
|
|
assert(modes);
|
|
|
|
modes[modes_cnt++] = *lpddsd;
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void flushdisplaymodes(void)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
|
|
|
free(modes);
|
|
|
|
modes = 0;
|
|
|
|
modes_cnt = modes_size = 0;
|
|
|
|
}
|
|
|
|
|
2005-12-12 11:53:56 +01:00
|
|
|
static HRESULT WINAPI enummodescallback(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
2008-01-01 21:33:32 +01:00
|
|
|
trace("Width = %i, Height = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\r\n",
|
2003-11-18 01:12:00 +01:00
|
|
|
lpddsd->dwWidth, lpddsd->dwHeight,
|
2008-01-16 12:17:27 +01:00
|
|
|
U2(*lpddsd).dwRefreshRate, U1(*lpddsd).lPitch, lpddsd->dwFlags);
|
2008-01-01 21:33:32 +01:00
|
|
|
|
|
|
|
/* Check that the pitch is valid if applicable */
|
|
|
|
if(lpddsd->dwFlags & DDSD_PITCH)
|
|
|
|
{
|
2008-01-16 12:17:27 +01:00
|
|
|
ok(U1(*lpddsd).lPitch != 0, "EnumDisplayModes callback with bad pitch\n");
|
2008-01-01 21:33:32 +01:00
|
|
|
}
|
|
|
|
|
2008-01-27 13:55:32 +01:00
|
|
|
/* Check that frequency is valid if applicable
|
|
|
|
*
|
|
|
|
* This fails on some Windows drivers or Windows versions, so it isn't important
|
|
|
|
* apparently
|
2008-01-01 21:33:32 +01:00
|
|
|
if(lpddsd->dwFlags & DDSD_REFRESHRATE)
|
|
|
|
{
|
2008-01-16 12:17:27 +01:00
|
|
|
ok(U2(*lpddsd).dwRefreshRate != 0, "EnumDisplayModes callback with bad refresh rate\n");
|
2008-01-01 21:33:32 +01:00
|
|
|
}
|
2008-01-27 13:55:32 +01:00
|
|
|
*/
|
2008-01-01 21:33:32 +01:00
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
adddisplaymode(lpddsd);
|
2003-11-18 01:12:00 +01:00
|
|
|
|
|
|
|
return DDENUMRET_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void enumdisplaymodes(void)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
|
|
|
DDSURFACEDESC ddsd;
|
|
|
|
HRESULT rc;
|
|
|
|
|
|
|
|
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
|
|
|
|
ddsd.dwSize = sizeof(DDSURFACEDESC);
|
|
|
|
ddsd.dwFlags = DDSD_CAPS;
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD,
|
2004-02-16 21:23:58 +01:00
|
|
|
DDEDM_STANDARDVGAMODES, &ddsd, 0, enummodescallback);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK || rc==E_INVALIDARG,"EnumDisplayModes returned: %x\n",rc);
|
2003-11-18 01:12:00 +01:00
|
|
|
}
|
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
static void setdisplaymode(int i)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2004-02-16 21:23:58 +01:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
|
2004-02-16 21:23:58 +01:00
|
|
|
if (modes[i].dwFlags & DDSD_PIXELFORMAT)
|
|
|
|
{
|
|
|
|
if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
|
|
|
|
{
|
|
|
|
rc = IDirectDraw_SetDisplayMode(lpDD,
|
|
|
|
modes[i].dwWidth, modes[i].dwHeight,
|
2005-06-13 14:10:54 +02:00
|
|
|
U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc);
|
2006-12-14 23:51:23 +01:00
|
|
|
if (rc == DD_OK)
|
|
|
|
{
|
|
|
|
RECT r, scrn, virt;
|
|
|
|
|
|
|
|
SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
|
|
|
|
OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN));
|
|
|
|
SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight,
|
|
|
|
scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom);
|
|
|
|
|
|
|
|
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
|
|
|
|
/* ddraw sets clip rect here to the screen size, even for
|
|
|
|
multiple monitors */
|
|
|
|
ok(EqualRect(&r, &scrn), "Invalid clip rect: (%d %d) x (%d %d)\n",
|
|
|
|
r.left, r.top, r.right, r.bottom);
|
|
|
|
|
|
|
|
ok(ClipCursor(NULL), "ClipCursor() failed\n");
|
|
|
|
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
|
|
|
|
ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n",
|
|
|
|
r.left, r.top, r.right, r.bottom);
|
|
|
|
|
2005-03-16 20:49:25 +01:00
|
|
|
rc = IDirectDraw_RestoreDisplayMode(lpDD);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc);
|
2005-03-16 20:49:25 +01:00
|
|
|
}
|
2004-02-16 21:23:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void createsurface(void)
|
2004-02-16 21:23:58 +01:00
|
|
|
{
|
|
|
|
DDSURFACEDESC ddsd;
|
|
|
|
DDSCAPS ddscaps;
|
|
|
|
HRESULT rc;
|
2003-11-18 01:12:00 +01:00
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
ddsd.dwSize = sizeof(ddsd);
|
|
|
|
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
|
|
|
|
DDSCAPS_FLIP |
|
|
|
|
DDSCAPS_COMPLEX;
|
|
|
|
ddsd.dwBackBufferCount = 1;
|
|
|
|
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL );
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
|
2004-02-16 21:23:58 +01:00
|
|
|
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
|
|
|
rc = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddscaps, &lpDDSBack);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"GetAttachedSurface returned: %x\n",rc);
|
2004-02-16 21:23:58 +01:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void destroysurface(void)
|
2004-02-16 21:23:58 +01:00
|
|
|
{
|
|
|
|
if( lpDDSPrimary != NULL )
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
2004-02-16 21:23:58 +01:00
|
|
|
IDirectDrawSurface_Release(lpDDSPrimary);
|
|
|
|
lpDDSPrimary = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void testsurface(void)
|
2004-02-16 21:23:58 +01:00
|
|
|
{
|
|
|
|
const char* testMsg = "ddraw device context test";
|
|
|
|
HDC hdc;
|
|
|
|
HRESULT rc;
|
|
|
|
|
|
|
|
rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc);
|
2004-02-16 21:23:58 +01:00
|
|
|
SetBkColor(hdc, RGB(0, 0, 255));
|
|
|
|
SetTextColor(hdc, RGB(255, 255, 0));
|
|
|
|
TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg));
|
|
|
|
IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
|
2004-02-16 21:23:58 +01:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %x\n",rc);
|
2004-02-16 21:23:58 +01:00
|
|
|
|
|
|
|
if (rc == DD_OK)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (rc == DDERR_SURFACELOST)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
2004-02-16 21:23:58 +01:00
|
|
|
rc = IDirectDrawSurface_Restore(lpDDSPrimary);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %x\n",rc);
|
2003-11-18 01:12:00 +01:00
|
|
|
}
|
|
|
|
}
|
2004-02-16 21:23:58 +01:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void testdisplaymodes(void)
|
2004-02-16 21:23:58 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < modes_cnt; ++i)
|
|
|
|
{
|
|
|
|
setdisplaymode(i);
|
|
|
|
createsurface();
|
|
|
|
testsurface();
|
|
|
|
destroysurface();
|
|
|
|
}
|
2003-11-18 01:12:00 +01:00
|
|
|
}
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
static void testcooperativelevels_normal(void)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
2006-09-09 13:35:50 +02:00
|
|
|
DDSURFACEDESC surfacedesc;
|
|
|
|
IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
|
|
|
|
|
|
|
|
memset(&surfacedesc, 0, sizeof(surfacedesc));
|
|
|
|
surfacedesc.dwSize = sizeof(surfacedesc);
|
|
|
|
surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat);
|
|
|
|
surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
|
|
|
surfacedesc.dwBackBufferCount = 1;
|
|
|
|
surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Do some tests with DDSCL_NORMAL mode */
|
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_NORMAL);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
2006-09-09 13:35:50 +02:00
|
|
|
/* Try creating a double buffered primary in normal mode */
|
|
|
|
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
2008-09-21 13:08:13 +02:00
|
|
|
if (rc == DDERR_UNSUPPORTEDMODE)
|
|
|
|
skip("Unsupported mode\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
|
|
|
|
ok(surface == NULL, "Returned surface pointer is %p\n", surface);
|
|
|
|
}
|
2008-05-28 11:18:15 +02:00
|
|
|
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
2006-09-09 13:35:50 +02:00
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
/* Set the focus window */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
2006-03-21 18:24:49 +01:00
|
|
|
/* Set the focus window a second time*/
|
2005-10-06 14:26:04 +02:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* This one succeeds */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Set the device window without any other flags. Should give an error */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_SETDEVICEWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Set device window with DDSCL_NORMAL */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Also set the focus window. Should give an error */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testcooperativelevels_exclusive(void)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
|
|
|
|
/* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
|
|
|
|
|
|
|
|
/* Try to set exclusive mode only */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_EXCLUSIVE);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Full screen mode only */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_FULLSCREEN);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Full screen mode + exclusive mode */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Set the focus window. Should fail */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_SETFOCUSWINDOW);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DDERR_HWNDALREADYSET,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
}
|
|
|
|
|
2003-11-18 01:12:00 +01:00
|
|
|
START_TEST(ddrawmodes)
|
|
|
|
{
|
2005-10-06 14:26:04 +02:00
|
|
|
createwindow();
|
2006-08-30 05:56:32 +02:00
|
|
|
if (!createdirectdraw())
|
|
|
|
return;
|
2004-02-16 21:23:58 +01:00
|
|
|
enumdisplaymodes();
|
2006-09-29 13:03:40 +02:00
|
|
|
if (winetest_interactive)
|
|
|
|
testdisplaymodes();
|
2004-02-16 21:23:58 +01:00
|
|
|
flushdisplaymodes();
|
|
|
|
releasedirectdraw();
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
createdirectdraw();
|
|
|
|
testcooperativelevels_normal();
|
|
|
|
releasedirectdraw();
|
|
|
|
|
|
|
|
createdirectdraw();
|
|
|
|
testcooperativelevels_exclusive();
|
|
|
|
releasedirectdraw();
|
2003-11-18 01:12:00 +01:00
|
|
|
}
|