Commit 3496fe5f authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

ddraw: More fully implement and test DirectDrawEnumerateExA.

parent bab8f7e5
......@@ -403,7 +403,16 @@ DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA Callback,
LPVOID Context,
DWORD Flags)
{
BOOL stop = FALSE;
TRACE("(%p, %p, 0x%08x)\n", Callback, Context, Flags);
if (Flags & ~(DDENUM_ATTACHEDSECONDARYDEVICES |
DDENUM_DETACHEDSECONDARYDEVICES |
DDENUM_NONDISPLAYDEVICES))
return DDERR_INVALIDPARAMS;
if (Flags)
FIXME("flags 0x%08x not handled\n", Flags);
TRACE("Enumerating default DirectDraw HAL interface\n");
/* We only have one driver by now */
......@@ -413,11 +422,11 @@ DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA Callback,
driver_name[] = "display";
/* QuickTime expects the description "DirectDraw HAL" */
stop = !Callback(NULL, driver_desc, driver_name, Context, 0);
Callback(NULL, driver_desc, driver_name, Context, 0);
}
__EXCEPT_PAGE_FAULT
{
return E_INVALIDARG;
return DDERR_INVALIDPARAMS;
}
__ENDTRY;
......
......@@ -40,12 +40,14 @@ static LPDDSURFACEDESC modes;
static HRESULT (WINAPI *pDirectDrawEnumerateA)(LPDDENUMCALLBACKA,LPVOID);
static HRESULT (WINAPI *pDirectDrawEnumerateW)(LPDDENUMCALLBACKW,LPVOID);
static HRESULT (WINAPI *pDirectDrawEnumerateExA)(LPDDENUMCALLBACKEXA,LPVOID,DWORD);
static void init_function_pointers(void)
{
HMODULE hmod = GetModuleHandleA("ddraw.dll");
pDirectDrawEnumerateA = (void*)GetProcAddress(hmod, "DirectDrawEnumerateA");
pDirectDrawEnumerateW = (void*)GetProcAddress(hmod, "DirectDrawEnumerateW");
pDirectDrawEnumerateExA = (void*)GetProcAddress(hmod, "DirectDrawEnumerateExA");
}
static void createwindow(void)
......@@ -194,6 +196,83 @@ static void test_DirectDrawEnumerateW(void)
ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
}
static BOOL WINAPI crash_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
LPSTR lpDriverName, LPVOID lpContext,
HMONITOR hm)
{
*(volatile char*)0 = 2;
return TRUE;
}
static BOOL WINAPI test_nullcontext_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
LPSTR lpDriverName, LPVOID lpContext,
HMONITOR hm)
{
trace("test_nullcontext_callbackExA: %p %s %s %p %p\n", lpGUID,
lpDriverDescription, lpDriverName, lpContext, hm);
ok(!lpContext, "Expected NULL lpContext\n");
return TRUE;
}
static BOOL WINAPI test_context_callbackExA(GUID *lpGUID, LPSTR lpDriverDescription,
LPSTR lpDriverName, LPVOID lpContext,
HMONITOR hm)
{
trace("test_context_callbackExA: %p %s %s %p %p\n", lpGUID,
lpDriverDescription, lpDriverName, lpContext, hm);
ok(lpContext == (LPVOID)0xdeadbeef, "Expected non-NULL lpContext\n");
return TRUE;
}
static void test_DirectDrawEnumerateExA(void)
{
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 invalid callback parameter. */
ret = pDirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)0xdeadbeef, NULL, 0);
ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
/* Test with callback that crashes. */
ret = pDirectDrawEnumerateExA(crash_callbackExA, 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");
ret = pDirectDrawEnumerateExA(test_context_callbackExA, (LPVOID)0xdeadbeef, 0);
ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
/* 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);
}
static void adddisplaymode(LPDDSURFACEDESC lpddsd)
{
if (!modes)
......@@ -523,6 +602,7 @@ START_TEST(ddrawmodes)
test_DirectDrawEnumerateA();
test_DirectDrawEnumerateW();
test_DirectDrawEnumerateExA();
enumdisplaymodes();
if (winetest_interactive)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment