Alexander Morozov : setupapi: Added a test for registering device interface and getting device path.
Alexandre Julliard
julliard at winehq.org
Wed Apr 2 06:55:39 CDT 2008
Module: wine
Branch: master
Commit: c4fb0f236eadadf0910e59e8bfd87b610774c09d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c4fb0f236eadadf0910e59e8bfd87b610774c09d
Author: Alexander Morozov <amorozov at etersoft.ru>
Date: Fri Mar 28 20:38:46 2008 +0300
setupapi: Added a test for registering device interface and getting device path.
---
dlls/setupapi/tests/devinst.c | 68 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 2704d31..af98eb2 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -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();
}
More information about the wine-cvs
mailing list