[PATCH 1/2] dinput/tests: Tests for EnumObjects with different types of device objects

Lucas Fialho Zawacki lfzawacki at gmail.com
Thu Jul 14 14:24:17 CDT 2011


There were no tests for the dwFlags parameter of EnumObjects and I added them because of the next patch.
The number of tests grew dramatically because of the number of keyboard objects mostly.

---
 dlls/dinput/tests/device.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index ea25482..e79c564 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -64,11 +64,20 @@ static BOOL CALLBACK enum_callback(LPCDIDEVICEOBJECTINSTANCE oi, LPVOID info)
     return DIENUM_CONTINUE;
 }
 
+static BOOL CALLBACK enum_type_callback(LPCDIDEVICEOBJECTINSTANCE oi, LPVOID info)
+{
+    DWORD expected = *(DWORD*)info;
+    ok (expected & DIDFT_GETTYPE(oi->dwType), "EnumObjects() enumerated wrong type for obj %s, expected: %08x got: %08x\n", oi->tszName, expected, oi->dwType);
+    return DIENUM_CONTINUE;
+}
+
 static void test_object_info(LPDIRECTINPUTDEVICE device, HWND hwnd)
 {
     HRESULT hr;
     DIPROPDWORD dp;
     DIDEVICEOBJECTINSTANCE obj_info;
+    DWORD obj_types[] = {DIDFT_BUTTON, DIDFT_AXIS, DIDFT_POV};
+    int type_index;
     int cnt = 0, cnt1 = 0;
 
     hr = IDirectInputDevice_EnumObjects(device, enum_callback, &cnt, DIDFT_ALL);
@@ -82,6 +91,13 @@ static void test_object_info(LPDIRECTINPUTDEVICE device, HWND hwnd)
     if (0) /* fails for joystick only */
     ok(cnt == cnt1, "Enum count changed from %d to %d\n", cnt, cnt1);
 
+    /* Testing EnumObjects with different types of device objects */
+    for (type_index=0; type_index < sizeof(obj_types)/sizeof(obj_types[0]); type_index++)
+    {
+        hr = IDirectInputDevice_EnumObjects(device, enum_type_callback, &obj_types[type_index], obj_types[type_index]);
+        ok(SUCCEEDED(hr), "EnumObjects() failed: %08x\n", hr);
+    }
+
     /* No need to test devices without axis */
     obj_info.dwSize = sizeof(obj_info);
     hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);
-- 
1.7.0.4



More information about the wine-patches mailing list