ddraw: Add tests for the foreground window set by SetCooperativeLevel.
This commit is contained in:
parent
5d4de2ac45
commit
94f74a7caf
|
@ -33,7 +33,7 @@ static LPDIRECTDRAW lpDD = NULL;
|
||||||
static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
|
static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
|
||||||
static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
|
static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
|
||||||
static WNDCLASS wc;
|
static WNDCLASS wc;
|
||||||
static HWND hwnd;
|
static HWND hwnd, hwnd2;
|
||||||
static int modes_cnt;
|
static int modes_cnt;
|
||||||
static int modes_size;
|
static int modes_size;
|
||||||
static LPDDSURFACEDESC modes;
|
static LPDDSURFACEDESC modes;
|
||||||
|
@ -54,31 +54,21 @@ static void init_function_pointers(void)
|
||||||
pDirectDrawEnumerateExW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExW");
|
pDirectDrawEnumerateExW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExW");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createwindow(void)
|
static HWND createwindow(void)
|
||||||
{
|
{
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
HWND hwnd;
|
||||||
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);
|
|
||||||
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
|
||||||
wc.lpszMenuName = NULL;
|
|
||||||
wc.lpszClassName = "TestWindowClass";
|
|
||||||
if(!RegisterClassA(&wc))
|
|
||||||
assert(0);
|
|
||||||
|
|
||||||
hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
|
hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
|
||||||
WS_POPUP, 0, 0,
|
WS_POPUP, 0, 0,
|
||||||
GetSystemMetrics(SM_CXSCREEN),
|
GetSystemMetrics(SM_CXSCREEN),
|
||||||
GetSystemMetrics(SM_CYSCREEN),
|
GetSystemMetrics(SM_CYSCREEN),
|
||||||
NULL, NULL, GetModuleHandleA(0), NULL);
|
NULL, NULL, GetModuleHandleA(0), NULL);
|
||||||
assert(hwnd != NULL);
|
|
||||||
|
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
ShowWindow(hwnd, SW_HIDE);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
SetFocus(hwnd);
|
SetFocus(hwnd);
|
||||||
|
|
||||||
|
return hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL createdirectdraw(void)
|
static BOOL createdirectdraw(void)
|
||||||
|
@ -546,6 +536,7 @@ static void testdisplaymodes(void)
|
||||||
|
|
||||||
static void testcooperativelevels_normal(void)
|
static void testcooperativelevels_normal(void)
|
||||||
{
|
{
|
||||||
|
BOOL sfw;
|
||||||
HRESULT rc;
|
HRESULT rc;
|
||||||
DDSURFACEDESC surfacedesc;
|
DDSURFACEDESC surfacedesc;
|
||||||
IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
|
IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
|
||||||
|
@ -561,11 +552,23 @@ static void testcooperativelevels_normal(void)
|
||||||
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
|
||||||
|
|
||||||
/* Do some tests with DDSCL_NORMAL mode */
|
/* Do some tests with DDSCL_NORMAL mode */
|
||||||
|
|
||||||
/* Fullscreen mode + normal mode + exclusive mode */
|
/* Fullscreen mode + normal mode + exclusive mode */
|
||||||
|
sfw=FALSE;
|
||||||
|
if(hwnd2)
|
||||||
|
sfw=SetForegroundWindow(hwnd2);
|
||||||
|
else
|
||||||
|
skip("Failed to create the second window\n");
|
||||||
|
|
||||||
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
||||||
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
|
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
|
||||||
|
|
||||||
|
if(sfw)
|
||||||
|
todo_wine ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
|
||||||
|
|
||||||
/* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
|
/* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
|
||||||
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
||||||
|
|
||||||
if (rc == DDERR_UNSUPPORTEDMODE)
|
if (rc == DDERR_UNSUPPORTEDMODE)
|
||||||
skip("Unsupported mode\n");
|
skip("Unsupported mode\n");
|
||||||
else
|
else
|
||||||
|
@ -574,12 +577,21 @@ static void testcooperativelevels_normal(void)
|
||||||
todo_wine ok(surface!=NULL, "Returned NULL surface pointer \n");
|
todo_wine ok(surface!=NULL, "Returned NULL surface pointer \n");
|
||||||
}
|
}
|
||||||
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
||||||
|
|
||||||
/* Exclusive mode + normal mode */
|
/* Exclusive mode + normal mode */
|
||||||
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
|
||||||
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
|
||||||
|
|
||||||
/* Fullscreen mode + normal mode */
|
/* Fullscreen mode + normal mode */
|
||||||
|
sfw=FALSE;
|
||||||
|
if(hwnd2) sfw=SetForegroundWindow(hwnd2);
|
||||||
|
|
||||||
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
|
||||||
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);
|
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);
|
||||||
|
|
||||||
|
if(sfw)
|
||||||
|
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
|
||||||
|
|
||||||
/* Try creating a double buffered primary in fullscreen + normal mode */
|
/* Try creating a double buffered primary in fullscreen + normal mode */
|
||||||
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
||||||
if (rc == DDERR_UNSUPPORTEDMODE)
|
if (rc == DDERR_UNSUPPORTEDMODE)
|
||||||
|
@ -589,12 +601,20 @@ static void testcooperativelevels_normal(void)
|
||||||
ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
|
ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
|
||||||
ok(surface == NULL, "Returned surface pointer is %p\n", surface);
|
ok(surface == NULL, "Returned surface pointer is %p\n", surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
||||||
/* Normal mode */
|
|
||||||
|
/* switching from Fullscreen mode to Normal mode */
|
||||||
|
sfw=FALSE;
|
||||||
|
if(hwnd2) sfw=SetForegroundWindow(hwnd2);
|
||||||
|
|
||||||
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
||||||
hwnd, DDSCL_NORMAL);
|
hwnd, DDSCL_NORMAL);
|
||||||
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
|
||||||
|
|
||||||
|
if(sfw)
|
||||||
|
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
|
||||||
|
|
||||||
/* Try creating a double buffered primary in normal mode */
|
/* Try creating a double buffered primary in normal mode */
|
||||||
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
|
||||||
if (rc == DDERR_UNSUPPORTEDMODE)
|
if (rc == DDERR_UNSUPPORTEDMODE)
|
||||||
|
@ -606,6 +626,17 @@ static void testcooperativelevels_normal(void)
|
||||||
}
|
}
|
||||||
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
|
||||||
|
|
||||||
|
/* switching from Normal mode to Fullscreen + Normal mode */
|
||||||
|
sfw=FALSE;
|
||||||
|
if(hwnd2) sfw=SetForegroundWindow(hwnd2);
|
||||||
|
|
||||||
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
||||||
|
hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN);
|
||||||
|
todo_wine ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc);
|
||||||
|
|
||||||
|
if(sfw)
|
||||||
|
ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
|
||||||
|
|
||||||
/* Set the focus window */
|
/* Set the focus window */
|
||||||
|
|
||||||
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
|
rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
|
||||||
|
@ -681,7 +712,7 @@ static void testcooperativelevels_normal(void)
|
||||||
|
|
||||||
static void testcooperativelevels_exclusive(void)
|
static void testcooperativelevels_exclusive(void)
|
||||||
{
|
{
|
||||||
BOOL success;
|
BOOL sfw, success;
|
||||||
HRESULT rc;
|
HRESULT rc;
|
||||||
RECT window_rect;
|
RECT window_rect;
|
||||||
|
|
||||||
|
@ -702,11 +733,21 @@ static void testcooperativelevels_exclusive(void)
|
||||||
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
|
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
|
||||||
|
|
||||||
/* Full screen mode + exclusive mode */
|
/* Full screen mode + exclusive mode */
|
||||||
|
sfw=FALSE;
|
||||||
|
if(hwnd2)
|
||||||
|
sfw=SetForegroundWindow(hwnd2);
|
||||||
|
else
|
||||||
|
skip("Failed to create the second window\n");
|
||||||
|
|
||||||
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
rc = IDirectDraw_SetCooperativeLevel(lpDD,
|
||||||
hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
||||||
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
|
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
|
||||||
GetClientRect(hwnd, &window_rect);
|
|
||||||
|
if(sfw)
|
||||||
|
ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
|
||||||
|
|
||||||
/* rect_before_create is assumed to hold the screen rect */
|
/* rect_before_create is assumed to hold the screen rect */
|
||||||
|
GetClientRect(hwnd, &window_rect);
|
||||||
rc = EqualRect(&rect_before_create, &window_rect);
|
rc = EqualRect(&rect_before_create, &window_rect);
|
||||||
todo_wine ok(rc!=0, "Fullscreen window has wrong size\n");
|
todo_wine ok(rc!=0, "Fullscreen window has wrong size\n");
|
||||||
|
|
||||||
|
@ -783,9 +824,36 @@ START_TEST(ddrawmodes)
|
||||||
{
|
{
|
||||||
init_function_pointers();
|
init_function_pointers();
|
||||||
|
|
||||||
createwindow();
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
if (!createdirectdraw())
|
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);
|
||||||
|
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
||||||
|
wc.lpszMenuName = NULL;
|
||||||
|
wc.lpszClassName = "TestWindowClass";
|
||||||
|
if (!RegisterClassA(&wc))
|
||||||
|
{
|
||||||
|
skip("RegisterClassA failed\n");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwnd2=createwindow();
|
||||||
|
hwnd=createwindow();
|
||||||
|
|
||||||
|
if (!hwnd)
|
||||||
|
{
|
||||||
|
skip("Failed to create the main window\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!createdirectdraw())
|
||||||
|
{
|
||||||
|
skip("Failed to create the direct draw object\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
test_DirectDrawEnumerateA();
|
test_DirectDrawEnumerateA();
|
||||||
test_DirectDrawEnumerateW();
|
test_DirectDrawEnumerateW();
|
||||||
|
|
Loading…
Reference in New Issue