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"
|
|
|
|
|
2012-11-05 21:38:23 +01:00
|
|
|
static IDirectDrawSurface *lpDDSPrimary;
|
|
|
|
static IDirectDrawSurface *lpDDSBack;
|
2012-11-07 21:41:12 +01:00
|
|
|
static IDirectDraw *lpDD;
|
2013-10-31 09:40:41 +01:00
|
|
|
static WNDCLASSA wc;
|
2010-10-28 14:18:15 +02:00
|
|
|
static HWND hwnd, hwnd2;
|
2003-11-18 01:12:00 +01:00
|
|
|
static int modes_cnt;
|
|
|
|
static int modes_size;
|
2012-12-07 00:07:05 +01:00
|
|
|
static DDSURFACEDESC *modes;
|
2010-04-16 23:04:41 +02:00
|
|
|
static RECT rect_before_create;
|
|
|
|
static RECT rect_after_delete;
|
2011-05-08 16:54:54 +02:00
|
|
|
static int modes16bpp_cnt;
|
|
|
|
static int refresh_rate;
|
|
|
|
static int refresh_rate_cnt;
|
2003-11-18 01:12:00 +01:00
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static HRESULT (WINAPI *pDirectDrawEnumerateA)(LPDDENUMCALLBACKA cb, void *ctx);
|
|
|
|
static HRESULT (WINAPI *pDirectDrawEnumerateW)(LPDDENUMCALLBACKW cb, void *ctx);
|
|
|
|
static HRESULT (WINAPI *pDirectDrawEnumerateExA)(LPDDENUMCALLBACKEXA cb, void *ctx, DWORD flags);
|
|
|
|
static HRESULT (WINAPI *pDirectDrawEnumerateExW)(LPDDENUMCALLBACKEXW cb, void *ctx, DWORD flags);
|
2009-10-08 16:03:49 +02:00
|
|
|
|
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hmod = GetModuleHandleA("ddraw.dll");
|
|
|
|
pDirectDrawEnumerateA = (void*)GetProcAddress(hmod, "DirectDrawEnumerateA");
|
2009-10-08 16:04:00 +02:00
|
|
|
pDirectDrawEnumerateW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateW");
|
2009-10-08 16:04:08 +02:00
|
|
|
pDirectDrawEnumerateExA = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExA");
|
2009-10-08 16:04:18 +02:00
|
|
|
pDirectDrawEnumerateExW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExW");
|
2009-10-08 16:03:49 +02:00
|
|
|
}
|
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
static HWND createwindow(void)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
2010-10-28 14:18:15 +02:00
|
|
|
HWND hwnd;
|
2009-09-01 09:09:37 +02:00
|
|
|
|
2003-11-18 01:12:00 +01:00
|
|
|
hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
|
|
|
|
WS_POPUP, 0, 0,
|
|
|
|
GetSystemMetrics(SM_CXSCREEN),
|
|
|
|
GetSystemMetrics(SM_CYSCREEN),
|
|
|
|
NULL, NULL, GetModuleHandleA(0), NULL);
|
2009-09-01 09:09:37 +02:00
|
|
|
|
2003-11-18 01:12:00 +01:00
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
UpdateWindow(hwnd);
|
|
|
|
SetFocus(hwnd);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
|
|
|
return 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;
|
|
|
|
|
2010-04-16 23:04:41 +02:00
|
|
|
SetRect(&rect_before_create, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
|
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
|
|
|
{
|
2010-04-16 23:04:41 +02:00
|
|
|
if( lpDD != NULL )
|
|
|
|
{
|
|
|
|
IDirectDraw_Release(lpDD);
|
|
|
|
lpDD = NULL;
|
|
|
|
SetRect(&rect_after_delete, 0, 0,
|
|
|
|
GetSystemMetrics(SM_CXSCREEN),
|
|
|
|
GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
ok(EqualRect(&rect_before_create, &rect_after_delete) != 0,
|
|
|
|
"Original display mode was not restored\n");
|
|
|
|
}
|
2004-02-16 21:23:58 +01:00
|
|
|
}
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static BOOL WINAPI test_nullcontext_callbackA(GUID *lpGUID,
|
|
|
|
char *lpDriverDescription, char *lpDriverName, void *lpContext)
|
2009-10-08 16:03:49 +02:00
|
|
|
{
|
|
|
|
trace("test_nullcontext_callbackA: %p %s %s %p\n",
|
|
|
|
lpGUID, lpDriverDescription, lpDriverName, lpContext);
|
|
|
|
|
|
|
|
ok(!lpContext, "Expected NULL lpContext\n");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static BOOL WINAPI test_context_callbackA(GUID *lpGUID,
|
|
|
|
char *lpDriverDescription, char *lpDriverName, void *lpContext)
|
2009-10-08 16:03:49 +02:00
|
|
|
{
|
|
|
|
trace("test_context_callbackA: %p %s %s %p\n",
|
|
|
|
lpGUID, lpDriverDescription, lpDriverName, lpContext);
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
ok(lpContext == (void *)0xdeadbeef, "Expected non-NULL lpContext\n");
|
2009-10-08 16:03:49 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DirectDrawEnumerateA(void)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
if (!pDirectDrawEnumerateA)
|
|
|
|
{
|
|
|
|
win_skip("DirectDrawEnumerateA is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test with NULL callback parameter. */
|
|
|
|
ret = pDirectDrawEnumerateA(NULL, NULL);
|
|
|
|
ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and NULL context parameter. */
|
|
|
|
trace("Calling DirectDrawEnumerateA with test_nullcontext_callbackA callback and NULL context.\n");
|
|
|
|
ret = pDirectDrawEnumerateA(test_nullcontext_callbackA, NULL);
|
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and valid context parameter. */
|
|
|
|
trace("Calling DirectDrawEnumerateA with test_context_callbackA callback and non-NULL context.\n");
|
2013-09-11 08:47:51 +02:00
|
|
|
ret = pDirectDrawEnumerateA(test_context_callbackA, (void *)0xdeadbeef);
|
2009-10-08 16:03:49 +02:00
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static BOOL WINAPI test_callbackW(GUID *lpGUID, WCHAR *lpDriverDescription,
|
|
|
|
WCHAR *lpDriverName, void *lpContext)
|
2009-10-08 16:04:00 +02:00
|
|
|
{
|
|
|
|
ok(0, "The callback should not be invoked by DirectDrawEnumerateW\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DirectDrawEnumerateW(void)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
if (!pDirectDrawEnumerateW)
|
|
|
|
{
|
|
|
|
win_skip("DirectDrawEnumerateW is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DirectDrawEnumerateW is not implemented on Windows. */
|
|
|
|
|
|
|
|
/* Test with NULL callback parameter. */
|
|
|
|
ret = pDirectDrawEnumerateW(NULL, NULL);
|
2009-10-10 10:06:32 +02:00
|
|
|
ok(ret == DDERR_INVALIDPARAMS ||
|
|
|
|
ret == DDERR_UNSUPPORTED, /* Older ddraw */
|
|
|
|
"Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret);
|
2009-10-08 16:04:00 +02:00
|
|
|
|
|
|
|
/* Test with invalid callback parameter. */
|
|
|
|
ret = pDirectDrawEnumerateW((LPDDENUMCALLBACKW)0xdeadbeef, NULL);
|
|
|
|
ok(ret == DDERR_INVALIDPARAMS /* XP */ ||
|
|
|
|
ret == DDERR_UNSUPPORTED /* Win7 */,
|
|
|
|
"Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and NULL context parameter. */
|
|
|
|
ret = pDirectDrawEnumerateW(test_callbackW, NULL);
|
|
|
|
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static BOOL WINAPI test_nullcontext_callbackExA(GUID *lpGUID, char *lpDriverDescription,
|
|
|
|
char *lpDriverName, void *lpContext, HMONITOR hm)
|
2009-10-08 16:04:08 +02:00
|
|
|
{
|
|
|
|
trace("test_nullcontext_callbackExA: %p %s %s %p %p\n", lpGUID,
|
|
|
|
lpDriverDescription, lpDriverName, lpContext, hm);
|
|
|
|
|
|
|
|
ok(!lpContext, "Expected NULL lpContext\n");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static BOOL WINAPI test_context_callbackExA(GUID *lpGUID, char *lpDriverDescription,
|
|
|
|
char *lpDriverName, void *lpContext, HMONITOR hm)
|
2009-10-08 16:04:08 +02:00
|
|
|
{
|
|
|
|
trace("test_context_callbackExA: %p %s %s %p %p\n", lpGUID,
|
|
|
|
lpDriverDescription, lpDriverName, lpContext, hm);
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
ok(lpContext == (void *)0xdeadbeef, "Expected non-NULL lpContext\n");
|
2009-10-08 16:04:08 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-01-09 16:34:46 +01:00
|
|
|
static BOOL WINAPI test_count_callbackExA(GUID *lpGUID, char *lpDriverDescription,
|
|
|
|
char *lpDriverName, void *lpContext, HMONITOR hm)
|
|
|
|
{
|
|
|
|
DWORD *count = (DWORD *)lpContext;
|
|
|
|
|
|
|
|
trace("test_count_callbackExA: %p %s %s %p %p\n", lpGUID,
|
|
|
|
lpDriverDescription, lpDriverName, lpContext, hm);
|
|
|
|
|
|
|
|
(*count)++;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-10-08 16:04:08 +02:00
|
|
|
static void test_DirectDrawEnumerateExA(void)
|
|
|
|
{
|
2014-01-09 16:34:46 +01:00
|
|
|
DWORD callbackCount;
|
2009-10-08 16:04:08 +02:00
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
if (!pDirectDrawEnumerateExA)
|
|
|
|
{
|
|
|
|
win_skip("DirectDrawEnumerateExA is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test with NULL callback parameter. */
|
|
|
|
ret = pDirectDrawEnumerateExA(NULL, NULL, 0);
|
|
|
|
ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and invalid flags */
|
|
|
|
ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, ~0);
|
|
|
|
ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and NULL context parameter. */
|
|
|
|
trace("Calling DirectDrawEnumerateExA with empty flags and NULL context.\n");
|
|
|
|
ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, 0);
|
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and non-NULL context parameter. */
|
|
|
|
trace("Calling DirectDrawEnumerateExA with empty flags and non-NULL context.\n");
|
2013-09-11 08:47:51 +02:00
|
|
|
ret = pDirectDrawEnumerateExA(test_context_callbackExA, (void *)0xdeadbeef, 0);
|
2009-10-08 16:04:08 +02:00
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
|
2014-01-09 16:34:46 +01:00
|
|
|
/* Test with valid callback parameter and count the number of primary devices */
|
|
|
|
callbackCount = 0;
|
|
|
|
ret = pDirectDrawEnumerateExA(test_count_callbackExA, &callbackCount, 0);
|
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
ok(callbackCount == 1, "Expected 1 primary device, got %d\n", callbackCount);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and count the number of secondary devices */
|
|
|
|
callbackCount = 0;
|
|
|
|
ret = pDirectDrawEnumerateExA(test_count_callbackExA, &callbackCount,
|
|
|
|
DDENUM_ATTACHEDSECONDARYDEVICES);
|
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
/* Note: this list includes the primary devices as well and some systems (such as the TestBot)
|
|
|
|
do not include any secondary devices */
|
|
|
|
ok(callbackCount >= 1, "Expected at least one device, got %d\n", callbackCount);
|
|
|
|
|
2009-10-08 16:04:08 +02:00
|
|
|
/* Test with valid callback parameter, NULL context parameter, and all flags set. */
|
|
|
|
trace("Calling DirectDrawEnumerateExA with all flags set and NULL context.\n");
|
|
|
|
ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL,
|
|
|
|
DDENUM_ATTACHEDSECONDARYDEVICES |
|
|
|
|
DDENUM_DETACHEDSECONDARYDEVICES |
|
|
|
|
DDENUM_NONDISPLAYDEVICES);
|
|
|
|
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2013-09-11 08:47:51 +02:00
|
|
|
static BOOL WINAPI test_callbackExW(GUID *lpGUID, WCHAR *lpDriverDescription,
|
|
|
|
WCHAR *lpDriverName, void *lpContext, HMONITOR hm)
|
2009-10-08 16:04:18 +02:00
|
|
|
{
|
|
|
|
ok(0, "The callback should not be invoked by DirectDrawEnumerateExW.\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DirectDrawEnumerateExW(void)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
if (!pDirectDrawEnumerateExW)
|
|
|
|
{
|
|
|
|
win_skip("DirectDrawEnumerateExW is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DirectDrawEnumerateExW is not implemented on Windows. */
|
|
|
|
|
|
|
|
/* Test with NULL callback parameter. */
|
|
|
|
ret = pDirectDrawEnumerateExW(NULL, NULL, 0);
|
|
|
|
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with invalid callback parameter. */
|
|
|
|
ret = pDirectDrawEnumerateExW((LPDDENUMCALLBACKEXW)0xdeadbeef, NULL, 0);
|
|
|
|
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and invalid flags */
|
|
|
|
ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, ~0);
|
|
|
|
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter and NULL context parameter. */
|
|
|
|
ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, 0);
|
|
|
|
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
|
|
|
|
/* Test with valid callback parameter, NULL context parameter, and all flags set. */
|
|
|
|
ret = pDirectDrawEnumerateExW(test_callbackExW, NULL,
|
|
|
|
DDENUM_ATTACHEDSECONDARYDEVICES |
|
|
|
|
DDENUM_DETACHEDSECONDARYDEVICES |
|
|
|
|
DDENUM_NONDISPLAYDEVICES);
|
|
|
|
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2012-12-07 00:07:05 +01:00
|
|
|
static void adddisplaymode(DDSURFACEDESC *lpddsd)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
2009-09-01 09:09:37 +02:00
|
|
|
if (!modes)
|
|
|
|
modes = HeapAlloc(GetProcessHeap(), 0, (modes_size = 2) * sizeof(DDSURFACEDESC));
|
|
|
|
if (modes_cnt == modes_size)
|
|
|
|
modes = HeapReAlloc(GetProcessHeap(), 0, modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
|
2003-11-18 01:12:00 +01:00
|
|
|
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
|
|
|
{
|
2009-05-13 10:33:42 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, modes);
|
2003-11-18 01:12:00 +01:00
|
|
|
modes = 0;
|
|
|
|
modes_cnt = modes_size = 0;
|
|
|
|
}
|
|
|
|
|
2012-12-07 00:07:05 +01:00
|
|
|
static HRESULT WINAPI enummodescallback(DDSURFACEDESC *lpddsd, void *lpContext)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
2011-05-08 16:54:54 +02:00
|
|
|
trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
|
|
|
|
lpddsd->dwWidth, lpddsd->dwHeight, U1(lpddsd->ddpfPixelFormat).dwRGBBitCount,
|
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);
|
2011-05-08 16:54:54 +02:00
|
|
|
if(U1(lpddsd->ddpfPixelFormat).dwRGBBitCount == 16)
|
|
|
|
modes16bpp_cnt++;
|
|
|
|
|
|
|
|
return DDENUMRET_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-07 00:07:05 +01:00
|
|
|
static HRESULT WINAPI enummodescallback_16bit(DDSURFACEDESC *lpddsd, void *lpContext)
|
2011-05-08 16:54:54 +02:00
|
|
|
{
|
|
|
|
trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
|
|
|
|
lpddsd->dwWidth, lpddsd->dwHeight, U1(lpddsd->ddpfPixelFormat).dwRGBBitCount,
|
|
|
|
U2(*lpddsd).dwRefreshRate, U1(*lpddsd).lPitch, lpddsd->dwFlags);
|
|
|
|
|
|
|
|
ok(lpddsd->dwFlags == (DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE),
|
|
|
|
"Wrong surface description flags %02X\n", lpddsd->dwFlags);
|
|
|
|
ok(lpddsd->ddpfPixelFormat.dwFlags == DDPF_RGB, "Wrong pixel format flag %02X\n",
|
|
|
|
lpddsd->ddpfPixelFormat.dwFlags);
|
|
|
|
ok(U1(lpddsd->ddpfPixelFormat).dwRGBBitCount == 16, "Expected 16 bpp got %i\n",
|
|
|
|
U1(lpddsd->ddpfPixelFormat).dwRGBBitCount);
|
|
|
|
|
|
|
|
/* Check that the pitch is valid if applicable */
|
|
|
|
if(lpddsd->dwFlags & DDSD_PITCH)
|
|
|
|
{
|
|
|
|
ok(U1(*lpddsd).lPitch != 0, "EnumDisplayModes callback with bad pitch\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!refresh_rate)
|
|
|
|
{
|
|
|
|
if(U2(*lpddsd).dwRefreshRate )
|
|
|
|
{
|
|
|
|
refresh_rate = U2(*lpddsd).dwRefreshRate;
|
|
|
|
refresh_rate_cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(refresh_rate == U2(*lpddsd).dwRefreshRate)
|
|
|
|
refresh_rate_cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
modes16bpp_cnt++;
|
|
|
|
|
|
|
|
return DDENUMRET_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-07 00:07:05 +01:00
|
|
|
static HRESULT WINAPI enummodescallback_count(DDSURFACEDESC *lpddsd, void *lpContext)
|
2011-05-08 16:54:54 +02:00
|
|
|
{
|
|
|
|
ok(lpddsd->dwFlags == (DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE),
|
|
|
|
"Wrong surface description flags %02X\n", lpddsd->dwFlags);
|
|
|
|
|
|
|
|
modes16bpp_cnt++;
|
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;
|
2011-05-08 16:54:54 +02:00
|
|
|
int count, refresh_count;
|
2003-11-18 01:12:00 +01:00
|
|
|
|
|
|
|
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
|
|
|
|
ddsd.dwSize = sizeof(DDSURFACEDESC);
|
|
|
|
ddsd.dwFlags = DDSD_CAPS;
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
|
|
|
2011-05-08 16:54:54 +02:00
|
|
|
/* Flags parameter is reserved in very old ddraw versions (3 and older?) and must be 0 */
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback);
|
|
|
|
ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
|
|
|
|
|
|
|
|
count = modes16bpp_cnt;
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = DDSD_PIXELFORMAT;
|
|
|
|
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
|
|
|
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 16;
|
2011-08-29 20:07:27 +02:00
|
|
|
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xf800;
|
|
|
|
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x07e0;
|
2011-05-08 16:54:54 +02:00
|
|
|
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001F;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x0000;
|
|
|
|
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000;
|
|
|
|
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xF0F0;
|
|
|
|
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0F00;
|
|
|
|
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000F;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.ddpfPixelFormat.dwFlags = DDPF_YUV;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = DDSD_PIXELFORMAT;
|
|
|
|
ddsd.ddpfPixelFormat.dwFlags = 0;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = 0;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_count);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == modes_cnt, "Expected %d modes got %d\n", modes_cnt, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_PITCH;
|
2011-05-15 11:27:01 +02:00
|
|
|
U1(ddsd).lPitch = 123;
|
2011-05-08 16:54:54 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
|
2013-02-20 00:14:40 +01:00
|
|
|
/* Ask for a refresh rate that could not possibly be used. But note that
|
|
|
|
* the Windows 'Standard VGA' driver claims to run the display at 1Hz!
|
|
|
|
*/
|
|
|
|
U2(ddsd).dwRefreshRate = 2;
|
2011-05-08 16:54:54 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == 0, "Expected 0 modes got %d\n", modes16bpp_cnt);
|
|
|
|
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = DDSD_PIXELFORMAT;
|
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, DDEDM_REFRESHRATES, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
if(rc == DDERR_INVALIDPARAMS)
|
|
|
|
{
|
|
|
|
skip("Ddraw version too old. Skipping.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
refresh_count = refresh_rate_cnt;
|
|
|
|
|
|
|
|
if(refresh_rate)
|
|
|
|
{
|
|
|
|
modes16bpp_cnt = 0;
|
|
|
|
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
|
2011-05-15 11:27:01 +02:00
|
|
|
U2(ddsd).dwRefreshRate = refresh_rate;
|
2011-05-08 16:54:54 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
|
|
|
|
ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
|
|
|
|
ok(modes16bpp_cnt == refresh_count, "Expected %d modes got %d\n", refresh_count, modes16bpp_cnt);
|
|
|
|
}
|
2011-09-03 21:06:11 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, 0, enummodescallback);
|
|
|
|
ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
|
2003-11-18 01:12:00 +01:00
|
|
|
}
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
static void setdisplaymode(int i)
|
2003-11-18 01:12:00 +01:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2010-04-07 12:24:15 +02:00
|
|
|
RECT orig_rect;
|
|
|
|
|
|
|
|
SetRect(&orig_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
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)
|
|
|
|
{
|
2010-04-07 12:24:15 +02:00
|
|
|
RECT r, scrn, test, virt;
|
2006-12-14 23:51:23 +01:00
|
|
|
|
|
|
|
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);
|
2010-04-07 12:24:15 +02:00
|
|
|
if (!EqualRect(&scrn, &orig_rect))
|
|
|
|
{
|
2010-04-16 23:04:41 +02:00
|
|
|
HRESULT rect_result;
|
|
|
|
|
2010-04-07 12:24:15 +02:00
|
|
|
/* Check that the client rect was resized */
|
|
|
|
rc = GetClientRect(hwnd, &test);
|
|
|
|
ok(rc!=0, "GetClientRect returned %x\n", rc);
|
|
|
|
rc = EqualRect(&scrn, &test);
|
|
|
|
todo_wine ok(rc!=0, "Fullscreen window has wrong size\n");
|
2010-04-16 23:04:41 +02:00
|
|
|
|
|
|
|
/* Check that switching to normal cooperative level
|
|
|
|
does not restore the display mode */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL);
|
|
|
|
ok(rc==DD_OK, "SetCooperativeLevel returned %x\n", rc);
|
|
|
|
SetRect(&test, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
rect_result = EqualRect(&scrn, &test);
|
|
|
|
ok(rect_result!=0, "Setting cooperative level to DDSCL_NORMAL changed the display mode\n");
|
|
|
|
|
|
|
|
/* Go back to fullscreen */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
|
|
|
ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n",rc);
|
|
|
|
|
|
|
|
/* If the display mode was changed, set the correct mode
|
|
|
|
to avoid irrelevant failures */
|
|
|
|
if (rect_result == 0)
|
|
|
|
{
|
|
|
|
rc = IDirectDraw_SetDisplayMode(lpDD,
|
|
|
|
modes[i].dwWidth, modes[i].dwHeight,
|
|
|
|
U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
|
|
|
|
ok(DD_OK==rc, "SetDisplayMode returned: %x\n",rc);
|
|
|
|
}
|
2010-04-07 12:24:15 +02:00
|
|
|
}
|
2006-12-14 23:51:23 +01:00
|
|
|
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;
|
2009-09-01 09:09:37 +02: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;
|
2009-09-01 09:09:37 +02:00
|
|
|
|
2004-02-16 21:23:58 +01:00
|
|
|
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));
|
2013-10-31 09:40:41 +01:00
|
|
|
TextOutA(hdc, 0, 0, testMsg, strlen(testMsg));
|
2012-03-12 19:56:09 +01:00
|
|
|
rc = IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
|
2006-10-10 19:23:33 +02:00
|
|
|
ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
|
2009-09-01 09:09:37 +02:00
|
|
|
|
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)
|
|
|
|
{
|
2010-10-28 14:18:15 +02:00
|
|
|
BOOL sfw;
|
2005-10-06 14:26:04 +02:00
|
|
|
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
|
|
|
|
2010-10-22 08:32:39 +02:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
|
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
/* Do some tests with DDSCL_NORMAL mode */
|
2010-10-28 14:18:15 +02:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
/* Fullscreen mode + normal mode + exclusive mode */
|
2010-11-01 22:32:52 +01:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
|
|
|
ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received: %x\n", rc);
|
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
sfw=FALSE;
|
|
|
|
if(hwnd2)
|
|
|
|
sfw=SetForegroundWindow(hwnd2);
|
|
|
|
else
|
|
|
|
skip("Failed to create the second window\n");
|
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
|
|
|
if(sfw)
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
/* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
|
|
|
|
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
if (rc == DDERR_UNSUPPORTEDMODE)
|
|
|
|
skip("Unsupported mode\n");
|
|
|
|
else
|
|
|
|
{
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc);
|
|
|
|
ok(surface!=NULL, "Returned NULL surface pointer\n");
|
2010-10-11 11:50:35 +02:00
|
|
|
}
|
|
|
|
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
/* Exclusive mode + normal mode */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
/* Fullscreen mode + normal mode */
|
2010-11-01 22:32:52 +01:00
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
sfw=FALSE;
|
|
|
|
if(hwnd2) sfw=SetForegroundWindow(hwnd2);
|
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
|
|
|
if(sfw)
|
|
|
|
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
|
|
|
|
|
2010-11-01 22:32:52 +01:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL);
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
|
2010-11-01 22:32:52 +01:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
/* Try creating a double buffered primary in fullscreen + normal mode */
|
|
|
|
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
|
|
|
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);
|
|
|
|
}
|
2010-10-28 14:18:15 +02:00
|
|
|
|
2010-10-11 11:50:35 +02:00
|
|
|
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
|
|
|
/* switching from Fullscreen mode to Normal mode */
|
2010-11-01 22:32:52 +01:00
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
sfw=FALSE;
|
|
|
|
if(hwnd2) sfw=SetForegroundWindow(hwnd2);
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
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
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
if(sfw)
|
|
|
|
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
|
|
|
|
|
2010-11-01 22:32:52 +01:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
|
|
|
|
ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
|
|
|
|
|
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
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
/* switching from Normal mode to Fullscreen + Normal mode */
|
2010-11-01 22:32:52 +01:00
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
sfw=FALSE;
|
|
|
|
if(hwnd2) sfw=SetForegroundWindow(hwnd2);
|
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN);
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
|
|
|
if(sfw)
|
|
|
|
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
|
|
|
|
|
2010-11-01 22:32:52 +01:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN);
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
|
2010-11-01 22:32:52 +01:00
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
/* Set the focus window */
|
2010-10-22 08:32:39 +02:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
|
|
|
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
|
|
|
|
|
2010-11-01 22:32:52 +01:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_SETFOCUSWINDOW);
|
|
|
|
|
|
|
|
if (rc == DDERR_INVALIDPARAMS)
|
|
|
|
{
|
|
|
|
win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_SETFOCUSWINDOW);
|
2009-03-23 07:42:58 +01:00
|
|
|
|
|
|
|
if (rc == DDERR_INVALIDPARAMS)
|
|
|
|
{
|
|
|
|
win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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);
|
2009-09-01 09:09:37 +02:00
|
|
|
|
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)
|
|
|
|
{
|
2010-10-28 14:18:15 +02:00
|
|
|
BOOL sfw, success;
|
2005-10-06 14:26:04 +02:00
|
|
|
HRESULT rc;
|
2010-07-28 00:39:42 +02:00
|
|
|
RECT window_rect;
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
|
|
|
|
|
2010-07-28 00:39:42 +02:00
|
|
|
/* First, resize the window so it is not the same size as any screen */
|
|
|
|
success = SetWindowPos(hwnd, 0, 0, 0, 281, 92, 0);
|
|
|
|
ok(success, "SetWindowPos failed\n");
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
/* 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 */
|
2010-11-01 22:32:52 +01:00
|
|
|
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
2010-11-03 07:10:54 +01:00
|
|
|
ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %x\n", rc);
|
2010-11-01 22:32:52 +01:00
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
sfw=FALSE;
|
|
|
|
if(hwnd2)
|
|
|
|
sfw=SetForegroundWindow(hwnd2);
|
|
|
|
else
|
|
|
|
skip("Failed to create the second window\n");
|
|
|
|
|
2005-10-06 14:26:04 +02:00
|
|
|
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);
|
2010-10-28 14:18:15 +02:00
|
|
|
|
|
|
|
if(sfw)
|
|
|
|
ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
|
|
|
|
|
2010-07-28 00:39:42 +02:00
|
|
|
/* rect_before_create is assumed to hold the screen rect */
|
2010-10-28 14:18:15 +02:00
|
|
|
GetClientRect(hwnd, &window_rect);
|
2010-07-28 00:39:42 +02:00
|
|
|
rc = EqualRect(&rect_before_create, &window_rect);
|
2010-11-08 11:50:33 +01:00
|
|
|
ok(rc, "Fullscreen window has wrong size.\n");
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
/* Set the focus window. Should fail */
|
|
|
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
|
|
|
hwnd, DDSCL_SETFOCUSWINDOW);
|
2009-03-23 07:42:58 +01:00
|
|
|
ok(rc==DDERR_HWNDALREADYSET ||
|
|
|
|
broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
|
2005-10-06 14:26:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
}
|
|
|
|
|
2008-12-16 20:56:41 +01:00
|
|
|
static void testddraw3(void)
|
|
|
|
{
|
|
|
|
const GUID My_IID_IDirectDraw3 = {
|
|
|
|
0x618f8ad4,
|
|
|
|
0x8b7a,
|
|
|
|
0x11d0,
|
|
|
|
{ 0x8f,0xcc,0x0,0xc0,0x4f,0xd9,0x18,0x9d }
|
|
|
|
};
|
|
|
|
IDirectDraw3 *dd3;
|
|
|
|
HRESULT hr;
|
|
|
|
hr = IDirectDraw_QueryInterface(lpDD, &My_IID_IDirectDraw3, (void **) &dd3);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectDraw3 returned 0x%08x, expected E_NOINTERFACE\n", hr);
|
|
|
|
if(SUCCEEDED(hr) && dd3) IDirectDraw3_Release(dd3);
|
|
|
|
}
|
|
|
|
|
2009-10-26 15:17:40 +01:00
|
|
|
static void testddraw7(void)
|
|
|
|
{
|
|
|
|
IDirectDraw7 *dd7;
|
|
|
|
HRESULT hr;
|
|
|
|
DDDEVICEIDENTIFIER2 *pdddi2;
|
|
|
|
DWORD dddi2Bytes;
|
|
|
|
DWORD *pend;
|
|
|
|
|
|
|
|
hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
|
2009-11-02 12:03:32 +01:00
|
|
|
if (hr==E_NOINTERFACE)
|
|
|
|
{
|
|
|
|
win_skip("DirectDraw7 is not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
2009-10-26 15:17:40 +01:00
|
|
|
ok(hr==DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
|
|
|
|
|
|
|
|
if (hr==DD_OK)
|
|
|
|
{
|
|
|
|
dddi2Bytes = FIELD_OFFSET(DDDEVICEIDENTIFIER2, dwWHQLLevel) + sizeof(DWORD);
|
|
|
|
|
2010-02-05 11:54:51 +01:00
|
|
|
pdddi2 = HeapAlloc( GetProcessHeap(), 0, dddi2Bytes + 2*sizeof(DWORD) );
|
2009-10-26 15:17:40 +01:00
|
|
|
pend = (DWORD *)((char *)pdddi2 + dddi2Bytes);
|
2010-02-05 11:54:51 +01:00
|
|
|
pend[0] = 0xdeadbeef;
|
|
|
|
pend[1] = 0xdeadbeef;
|
2009-10-26 15:17:40 +01:00
|
|
|
|
|
|
|
hr = IDirectDraw7_GetDeviceIdentifier(dd7, pdddi2, 0);
|
|
|
|
ok(hr==DD_OK, "get device identifier failed with %08x\n", hr);
|
|
|
|
|
|
|
|
if (hr==DD_OK)
|
|
|
|
{
|
2014-02-11 05:27:33 +01:00
|
|
|
/* szDriver contains the name of the driver DLL */
|
|
|
|
ok(strstr(pdddi2->szDriver, ".dll")!=NULL, "szDriver does not contain DLL name\n");
|
2009-10-26 15:17:40 +01:00
|
|
|
/* check how strings are copied into the structure */
|
|
|
|
ok(pdddi2->szDriver[MAX_DDDEVICEID_STRING - 1]==0, "szDriver not cleared\n");
|
|
|
|
ok(pdddi2->szDescription[MAX_DDDEVICEID_STRING - 1]==0, "szDescription not cleared\n");
|
|
|
|
/* verify that 8 byte structure size alignment will not overwrite memory */
|
2010-02-05 11:54:51 +01:00
|
|
|
ok(pend[0]==0xdeadbeef || broken(pend[0] != 0xdeadbeef), /* win2k */
|
|
|
|
"memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
|
|
|
|
ok(pend[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
|
2009-10-26 15:17:40 +01:00
|
|
|
}
|
|
|
|
|
2014-02-11 17:21:53 +01:00
|
|
|
/* recheck with the DDGDI_GETHOSTIDENTIFIER flag */
|
|
|
|
pend[0] = 0xdeadbeef;
|
|
|
|
pend[1] = 0xdeadbeef;
|
|
|
|
hr = IDirectDraw7_GetDeviceIdentifier(dd7, pdddi2, DDGDI_GETHOSTIDENTIFIER);
|
|
|
|
ok(hr==DD_OK, "get device identifier failed with %08x\n", hr);
|
|
|
|
if (hr==DD_OK)
|
|
|
|
{
|
|
|
|
/* szDriver contains the name of the driver DLL */
|
|
|
|
ok(strstr(pdddi2->szDriver, ".dll")!=NULL, "szDriver does not contain DLL name\n");
|
|
|
|
/* check how strings are copied into the structure */
|
|
|
|
ok(pdddi2->szDriver[MAX_DDDEVICEID_STRING - 1]==0, "szDriver not cleared\n");
|
|
|
|
ok(pdddi2->szDescription[MAX_DDDEVICEID_STRING - 1]==0, "szDescription not cleared\n");
|
|
|
|
/* verify that 8 byte structure size alignment will not overwrite memory */
|
|
|
|
ok(pend[0]==0xdeadbeef || broken(pend[0] != 0xdeadbeef), /* win2k */
|
|
|
|
"memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
|
|
|
|
ok(pend[1]==0xdeadbeef, "memory beyond DDDEVICEIDENTIFIER2 overwritten\n");
|
|
|
|
}
|
|
|
|
|
2009-10-26 15:17:40 +01:00
|
|
|
IDirectDraw_Release(dd7);
|
|
|
|
HeapFree( GetProcessHeap(), 0, pdddi2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-18 01:12:00 +01:00
|
|
|
START_TEST(ddrawmodes)
|
|
|
|
{
|
2009-10-08 16:03:49 +02:00
|
|
|
init_function_pointers();
|
|
|
|
|
2010-10-28 14:18:15 +02:00
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wc.lpfnWndProc = DefWindowProcA;
|
|
|
|
wc.hInstance = GetModuleHandleA(0);
|
|
|
|
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
|
|
|
wc.lpszClassName = "TestWindowClass";
|
|
|
|
if (!RegisterClassA(&wc))
|
|
|
|
{
|
|
|
|
skip("RegisterClassA failed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwnd2=createwindow();
|
|
|
|
hwnd=createwindow();
|
|
|
|
|
|
|
|
if (!hwnd)
|
|
|
|
{
|
|
|
|
skip("Failed to create the main window\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:56:32 +02:00
|
|
|
if (!createdirectdraw())
|
2010-10-28 14:18:15 +02:00
|
|
|
{
|
|
|
|
skip("Failed to create the direct draw object\n");
|
2006-08-30 05:56:32 +02:00
|
|
|
return;
|
2010-10-28 14:18:15 +02:00
|
|
|
}
|
2009-10-08 16:03:49 +02:00
|
|
|
|
|
|
|
test_DirectDrawEnumerateA();
|
2009-10-08 16:04:00 +02:00
|
|
|
test_DirectDrawEnumerateW();
|
2009-10-08 16:04:08 +02:00
|
|
|
test_DirectDrawEnumerateExA();
|
2009-10-08 16:04:18 +02:00
|
|
|
test_DirectDrawEnumerateExW();
|
2009-10-08 16:03:49 +02:00
|
|
|
|
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();
|
2008-12-16 20:56:41 +01:00
|
|
|
testddraw3();
|
2009-10-26 15:17:40 +01:00
|
|
|
testddraw7();
|
2004-02-16 21:23:58 +01:00
|
|
|
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
|
|
|
}
|