Andrew Nguyen : ddraw: More fully implement and test DirectDrawEnumerateExA .
Alexandre Julliard
julliard at winehq.org
Fri Oct 9 09:24:10 CDT 2009
Module: wine
Branch: master
Commit: 3496fe5f431ffda72982b852b1987a5f865f8b1c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3496fe5f431ffda72982b852b1987a5f865f8b1c
Author: Andrew Nguyen <arethusa26 at gmail.com>
Date: Thu Oct 8 09:04:08 2009 -0500
ddraw: More fully implement and test DirectDrawEnumerateExA.
---
dlls/ddraw/main.c | 15 ++++++--
dlls/ddraw/tests/ddrawmodes.c | 80 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 3 deletions(-)
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c
index be4208d..137bb44 100644
--- a/dlls/ddraw/main.c
+++ b/dlls/ddraw/main.c
@@ -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;
diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c
index 17031b0..a095063 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -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)
More information about the wine-cvs
mailing list