[1/2] dinput/tests: Tests for IDirectInputJoyConfig8_GetConfig

Lucas Zawacki lfzawacki at gmail.com
Mon Aug 13 18:36:55 CDT 2012


From: Lucas Zawacki <lfzawacki at gmail.com>

---
 dlls/dinput/tests/dinput.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/dinputd.h          |    2 ++
 2 files changed, 46 insertions(+)

diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c
index 1cdc90b..c5386d6 100644
--- a/dlls/dinput/tests/dinput.c
+++ b/dlls/dinput/tests/dinput.c
@@ -22,6 +22,7 @@
 #include <initguid.h>
 #include <windows.h>
 #include <dinput.h>
+#include <dinputd.h>
 
 #include "wine/test.h"
 
@@ -562,6 +563,48 @@ static void test_RunControlPanel(void)
     IDirectInput_Release(pDI);
 }
 
+static void test_DirectInputJoyConfig8(void)
+{
+    IDirectInputA *pDI;
+    IDirectInputDeviceA *pDID;
+    IDirectInputJoyConfig8 *pDIJC;
+    DIJOYCONFIG info;
+    HRESULT hr;
+    int i;
+
+    hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL);
+    if (FAILED(hr))
+    {
+        win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
+        return;
+    }
+
+    hr = IDirectInput_QueryInterface(pDI, &IID_IDirectInputJoyConfig8, (void **)&pDIJC);
+    if (FAILED(hr))
+    {
+        win_skip("Failed to instantiate a IDirectInputJoyConfig8 instance: 0x%08x\n", hr);
+        return;
+    }
+
+    info.dwSize = sizeof(info);
+    hr = DI_OK;
+    i = 0;
+
+    /* Enumerate all connected joystick GUIDs and try to create the respective devices */
+    for (i = 0; SUCCEEDED(hr); i++)
+    {
+        hr = IDirectInputJoyConfig8_GetConfig(pDIJC, i, &info, DIJC_GUIDINSTANCE);
+
+        todo_wine ok (hr == DI_OK || hr == DIERR_NOMOREITEMS,
+           "IDirectInputJoyConfig8_GetConfig returned 0x%08x\n", hr);
+
+        if (SUCCEEDED(hr))
+            todo_wine ok (SUCCEEDED(IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL)),
+               "IDirectInput_CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr);
+    }
+
+}
+
 START_TEST(dinput)
 {
     HMODULE dinput_mod = GetModuleHandleA("dinput.dll");
@@ -579,5 +622,6 @@ START_TEST(dinput)
     test_GetDeviceStatus();
     test_Initialize();
     test_RunControlPanel();
+    test_DirectInputJoyConfig8();
     CoUninitialize();
 }
diff --git a/include/dinputd.h b/include/dinputd.h
index ac24a2c..9c3b435 100644
--- a/include/dinputd.h
+++ b/include/dinputd.h
@@ -44,6 +44,8 @@ typedef BOOL (CALLBACK *LPDIJOYTYPECALLBACK)(LPCWSTR, LPVOID);
 #define JOY_POVVAL_LEFT         2
 #define JOY_POVVAL_RIGHT        3
 
+#define DIERR_NOMOREITEMS       MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NO_MORE_ITEMS)
+
 typedef struct joypos_tag
 {
     DWORD dwX;
-- 
1.7.9.5




More information about the wine-patches mailing list