setupapi: Added a test for registering device interface and getting device path.
This commit is contained in:
parent
caafb52559
commit
c4fb0f236e
|
@ -49,6 +49,7 @@ static BOOL (WINAPI *pSetupDiGetDeviceInstanceIdA)(HDEVINFO, PSP_DEVINFO_DAT
|
|||
static BOOL (WINAPI *pSetupDiGetDeviceInterfaceDetailA)(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA);
|
||||
static BOOL (WINAPI *pSetupDiGetDeviceInterfaceDetailW)(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_W, DWORD, PDWORD, PSP_DEVINFO_DATA);
|
||||
static BOOL (WINAPI *pSetupDiRegisterDeviceInfo)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PSP_DETSIG_CMPPROC, PVOID, PSP_DEVINFO_DATA);
|
||||
static HDEVINFO (WINAPI *pSetupDiGetClassDevsA)(CONST GUID *, LPCSTR, HWND, DWORD);
|
||||
|
||||
static void init_function_pointers(void)
|
||||
{
|
||||
|
@ -70,6 +71,7 @@ static void init_function_pointers(void)
|
|||
pSetupDiOpenDevRegKey = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenDevRegKey");
|
||||
pSetupDiCreateDevRegKeyW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDevRegKeyW");
|
||||
pSetupDiRegisterDeviceInfo = (void *)GetProcAddress(hSetupAPI, "SetupDiRegisterDeviceInfo");
|
||||
pSetupDiGetClassDevsA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetClassDevsA");
|
||||
}
|
||||
|
||||
/* RegDeleteTreeW from dlls/advapi32/registry.c */
|
||||
|
@ -779,6 +781,71 @@ static void testDevRegKey(void)
|
|||
devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey);
|
||||
}
|
||||
|
||||
static void testRegisterAndGetDetail(void)
|
||||
{
|
||||
HDEVINFO set;
|
||||
BOOL ret;
|
||||
GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,
|
||||
0x00,0x11,0x95,0x5c,0x2b,0xdb}};
|
||||
SP_DEVINFO_DATA devInfo = { sizeof(SP_DEVINFO_DATA), { 0 } };
|
||||
SP_DEVICE_INTERFACE_DATA interfaceData = { sizeof(interfaceData), { 0 } };
|
||||
DWORD dwSize = 0;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
set = pSetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_ALLCLASSES);
|
||||
ok(set != INVALID_HANDLE_VALUE, "SetupDiGetClassDevsA failed: %08x\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiCreateDeviceInfoA(set, "LEGACY_BOGUS", &guid, NULL, 0,
|
||||
DICD_GENERATE_ID, &devInfo);
|
||||
ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, &guid, NULL, 0, &interfaceData);
|
||||
ok(ret, "SetupDiCreateDeviceInterfaceA failed: %08x\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL);
|
||||
ok(ret, "SetupDiRegisterDeviceInfo failed: %08x\n", GetLastError());
|
||||
|
||||
pSetupDiDestroyDeviceInfoList(set);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
set = pSetupDiGetClassDevsA(&guid, NULL, 0, DIGCF_DEVICEINTERFACE);
|
||||
ok(set != INVALID_HANDLE_VALUE, "SetupDiGetClassDevsA failed: %08x\n",
|
||||
GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiEnumDeviceInterfaces(set, NULL, &guid, 0, &interfaceData);
|
||||
todo_wine
|
||||
ok(ret, "SetupDiEnumDeviceInterfaces failed: %08x\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, NULL, 0, &dwSize, NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"Expected ERROR_INSUFFICIENT_BUFFER, got %08x\n", GetLastError());
|
||||
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
static const char path[] =
|
||||
"\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}";
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA_A detail = NULL;
|
||||
|
||||
detail = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A)HeapAlloc(GetProcessHeap(), 0, dwSize);
|
||||
if (detail)
|
||||
{
|
||||
detail->cbSize = offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(char);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData,
|
||||
detail, dwSize, &dwSize, NULL);
|
||||
ok(ret, "SetupDiGetDeviceInterfaceDetailA failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(!lstrcmpiA(path, detail->DevicePath), "Unexpected path %s\n",
|
||||
detail->DevicePath);
|
||||
HeapFree(GetProcessHeap(), 0, detail);
|
||||
}
|
||||
}
|
||||
|
||||
pSetupDiDestroyDeviceInfoList(set);
|
||||
}
|
||||
|
||||
START_TEST(devinst)
|
||||
{
|
||||
init_function_pointers();
|
||||
|
@ -799,4 +866,5 @@ START_TEST(devinst)
|
|||
testCreateDeviceInterface();
|
||||
testGetDeviceInterfaceDetail();
|
||||
testDevRegKey();
|
||||
testRegisterAndGetDetail();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue