From 68f63268a8ead73f8166cf9d23a33ba0dbd4c55f Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 19 Sep 2007 17:57:11 -0700 Subject: [PATCH] Add tests for SetupDiRegisterDeviceInfo --- dlls/setupapi/tests/devinst.c | 65 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index c88ad24..a18f91a 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -40,6 +40,7 @@ static BOOL (WINAPI *pSetupDiEnumDev static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID); static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiGetDeviceInstanceIdA)(HDEVINFO, PSP_DEVINFO_DATA, PSTR, DWORD, PDWORD); +static BOOL (WINAPI *pSetupDiRegisterDeviceInfo)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PSP_DETSIG_CMPPROC, PVOID, PSP_DEVINFO_DATA); static void init_function_pointers(void) { @@ -52,6 +53,7 @@ static void init_function_pointers(void) pSetupDiEnumDeviceInfo = (void *)GetProcAddress(hSetupAPI, "SetupDiEnumDeviceInfo"); pSetupDiGetDeviceInstanceIdA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInstanceIdA"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); + pSetupDiRegisterDeviceInfo = (void *)GetProcAddress(hSetupAPI, "SetupDiRegisterDeviceInfo"); } static void test_SetupDiCreateDeviceInfoListEx(void) @@ -272,6 +274,68 @@ static void testGetDeviceInstanceId(void } } +static void testRegisterDeviceInfo(void) +{ + BOOL ret; + GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04, + 0x00,0x11,0x95,0x5c,0x2b,0xdb}}; + HDEVINFO set; + + if (!pSetupDiCreateDeviceInfoList || !pSetupDiDestroyDeviceInfoList || + !pSetupDiRegisterDeviceInfo) + { + skip("No SetupDiRegisterDeviceInfo\n"); + return; + } + SetLastError(0xdeadbeef); + ret = pSetupDiRegisterDeviceInfo(NULL, NULL, 0, NULL, NULL, NULL); + todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, + "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); + ret = pSetupDiRegisterDeviceInfo(NULL, NULL, 0, NULL, NULL, NULL); + set = pSetupDiCreateDeviceInfoList(&guid, NULL); + ok(set != NULL, "SetupDiCreateDeviceInfoList failed: %d\n", GetLastError()); + if (set) + { + SP_DEVINFO_DATA devInfo = { 0 }; + + SetLastError(0xdeadbeef); + ret = pSetupDiRegisterDeviceInfo(set, NULL, 0, NULL, NULL, NULL); + todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); + todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + devInfo.cbSize = sizeof(devInfo); + SetLastError(0xdeadbeef); + ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); + todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + ret = pSetupDiCreateDeviceInfoA(set, "USB\\BOGUS\\0000", &guid, + NULL, NULL, 0, &devInfo); + ok(ret || GetLastError() == ERROR_DEVINST_ALREADY_EXISTS, + "SetupDiCreateDeviceInfoA failed: %d\n", GetLastError()); + if (ret) + { + /* If it already existed, registering it again will fail */ + ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, + NULL); + todo_wine + ok(ret, "SetupDiCreateDeviceInfoA failed: %d\n", GetLastError()); + } + /* FIXME: On Win2K+ systems, this is now persisted to registry in + * HKLM\System\CCS\Enum\USB\Bogus\0000. I don't check because the + * Win9x location is different. + * FIXME: the key also becomes undeletable. How to get rid of it? + */ + pSetupDiDestroyDeviceInfoList(set); + } +} + START_TEST(devinst) { init_function_pointers(); @@ -287,4 +351,5 @@ START_TEST(devinst) skip("SetupDiOpenClassRegKeyExA is not available\n"); testCreateDeviceInfo(); testGetDeviceInstanceId(); + testRegisterDeviceInfo(); } -- 1.4.1