Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 132 +++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 71 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 888b247d6d..86af09d31e 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -603,87 +603,77 @@ todo_wine devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); }
-static void testCreateDeviceInterface(void) +static void test_device_iface(void) { + SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; + SP_DEVINFO_DATA device = {0}; BOOL ret; HDEVINFO set; + DWORD i;
- if (!pSetupDiCreateDeviceInterfaceA || !pSetupDiEnumDeviceInterfaces) - { - win_skip("SetupDiCreateDeviceInterfaceA and/or SetupDiEnumDeviceInterfaces are not available\n"); - return; - } SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInterfaceA(NULL, NULL, NULL, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(NULL, NULL, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError()); + SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInterfaceA(NULL, NULL, &guid, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); - set = pSetupDiCreateDeviceInfoList(&guid, NULL); - ok(set != NULL, "SetupDiCreateDeviceInfoList failed: %d\n", GetLastError()); - if (set) - { - SP_DEVINFO_DATA devInfo = { 0 }; - SP_DEVICE_INTERFACE_DATA interfaceData = { sizeof(interfaceData), - { 0 } }; - DWORD i; + ret = SetupDiCreateDeviceInterfaceA(NULL, NULL, &guid, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError());
- SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInterfaceA(set, NULL, NULL, NULL, 0, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, NULL, NULL, 0, - NULL); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - devInfo.cbSize = sizeof(devInfo); - ret = pSetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, - NULL, NULL, 0, &devInfo); - ok(ret, "SetupDiCreateDeviceInfoA failed: %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, NULL, NULL, 0, - NULL); - ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER, - "Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError()); - ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, &guid, NULL, 0, - NULL); - ok(ret, "SetupDiCreateDeviceInterfaceA failed: %08x\n", GetLastError()); - /* Creating the same interface a second time succeeds */ - ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, &guid, NULL, 0, - NULL); - ok(ret, "SetupDiCreateDeviceInterfaceA failed: %08x\n", GetLastError()); - ret = pSetupDiCreateDeviceInterfaceA(set, &devInfo, &guid, "Oogah", 0, - NULL); - ok(ret, "SetupDiCreateDeviceInterfaceA failed: %08x\n", GetLastError()); - ret = pSetupDiEnumDeviceInterfaces(set, &devInfo, &guid, 0, - &interfaceData); - ok(ret, "SetupDiEnumDeviceInterfaces failed: %d\n", GetLastError()); - i = 0; - while (pSetupDiEnumDeviceInterfaces(set, &devInfo, &guid, i, - &interfaceData)) - i++; - ok(i == 2, "expected 2 interfaces, got %d\n", i); - ok(GetLastError() == ERROR_NO_MORE_ITEMS, - "SetupDiEnumDeviceInterfaces failed: %08x\n", GetLastError()); - - for (i = 0; i < 2; i++) - { - ret = pSetupDiEnumDeviceInterfaces(set, &devInfo, &guid, i, &interfaceData); - ok(ret, "SetupDiEnumDeviceInterfaces failed: %08x\n", GetLastError()); + set = SetupDiCreateDeviceInfoList(&guid, NULL); + ok(set != NULL, "Failed to create device list, error %#x.\n", GetLastError());
- ret = pSetupDiRemoveDeviceInterface(set, &interfaceData); - todo_wine ok(ret, "SetupDiRemoveDeviceInterface failed: %08x\n", GetLastError()); - } + SetLastError(0xdeadbeef); + ret = SetupDiCreateDeviceInterfaceA(set, NULL, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError());
- ret = pSetupDiRemoveDevice(set, &devInfo); - todo_wine ok(ret, "got %u\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = SetupDiCreateDeviceInterfaceA(set, &device, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + + device.cbSize = sizeof(device); + ret = SetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = SetupDiCreateDeviceInterfaceA(set, &device, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, NULL); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
- ret = pSetupDiDestroyDeviceInfoList(set); - ok(ret, "SetupDiDestroyDeviceInfoList failed: %08x\n", GetLastError()); + /* Creating the same interface a second time succeeds */ + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, NULL); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, "Oogah", 0, NULL); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + + ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, 0, &iface); + ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + + i = 0; + while (SetupDiEnumDeviceInterfaces(set, &device, &guid, i, &iface)) + i++; + ok(i == 2, "expected 2 interfaces, got %d\n", i); + ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + + for (i = 0; i < 2; i++) + { + ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, i, &iface); + ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + + ret = SetupDiRemoveDeviceInterface(set, &iface); +todo_wine + ok(ret, "Failed to remove interface, error %#x.\n", GetLastError()); } + + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); }
static void testGetDeviceInterfaceDetail(void) @@ -1538,7 +1528,7 @@ START_TEST(devinst) test_device_info(); test_get_device_instance_id(); test_register_device_info(); - testCreateDeviceInterface(); + test_device_iface(); testGetDeviceInterfaceDetail(); testDevRegKey(); testRegisterAndGetDetail();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 89 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 15 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 86af09d31e..539fe637e3 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -62,6 +62,7 @@ static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
/* This is a unique guid for testing purposes */ static GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}}; +static GUID guid2 = {0x6a55b5a5, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}};
static void init_function_pointers(void) { @@ -603,13 +604,48 @@ todo_wine devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); }
+static void check_device_iface_(int line, HDEVINFO set, SP_DEVINFO_DATA *device, + const GUID *class, int index, DWORD flags, const char *path) +{ + char buffer[200]; + SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_A *)buffer; + SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; + BOOL ret; + + detail->cbSize = sizeof(*detail); + + SetLastError(0xdeadbeef); + ret = SetupDiEnumDeviceInterfaces(set, device, class, index, &iface); + if (path) + { + ok_(__FILE__, line)(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + ok_(__FILE__, line)(IsEqualGUID(&iface.InterfaceClassGuid, class), + "Got unexpected class %s.\n", wine_dbgstr_guid(&iface.InterfaceClassGuid)); +todo_wine_if(flags & SPINT_REMOVED) + ok_(__FILE__, line)(iface.Flags == flags, "Got unexpected flags %#x.\n", iface.Flags); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, sizeof(buffer), NULL, NULL); + ok_(__FILE__, line)(ret, "Failed to get interface detail, error %#x.\n", GetLastError()); + ok_(__FILE__, line)(!strcasecmp(detail->DevicePath, path), "Got unexpected path %s.\n", detail->DevicePath); + } + else + { + ok_(__FILE__, line)(!ret, "Expected failure.\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_NO_MORE_ITEMS, + "Got unexpected error %#x.\n", GetLastError()); + } +} +#define check_device_iface(a,b,c,d,e,f) check_device_iface_(__LINE__,a,b,c,d,e,f) + static void test_device_iface(void) { + char buffer[200]; + SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_A *)buffer; SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; SP_DEVINFO_DATA device = {0}; BOOL ret; HDEVINFO set; - DWORD i; + + detail->cbSize = sizeof(*detail);
SetLastError(0xdeadbeef); ret = SetupDiCreateDeviceInterfaceA(NULL, NULL, NULL, NULL, 0, NULL); @@ -638,6 +674,8 @@ static void test_device_iface(void) ret = SetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); ok(ret, "Failed to create device, error %#x.\n", GetLastError());
+ check_device_iface(set, &device, &guid, 0, 0, NULL); + SetLastError(0xdeadbeef); ret = SetupDiCreateDeviceInterfaceA(set, &device, NULL, NULL, 0, NULL); ok(!ret, "Expected failure.\n"); @@ -646,31 +684,52 @@ static void test_device_iface(void) ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, NULL); ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
+ check_device_iface(set, &device, &guid, 0, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, &device, &guid, 1, 0, NULL); + /* Creating the same interface a second time succeeds */ ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, NULL); ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
+ check_device_iface(set, &device, &guid, 0, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, &device, &guid, 1, 0, NULL); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, "Oogah", 0, NULL); ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
- ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, 0, &iface); - ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + check_device_iface(set, &device, &guid, 0, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, &device, &guid, 1, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\Oogah"); + check_device_iface(set, &device, &guid, 2, 0, NULL);
- i = 0; - while (SetupDiEnumDeviceInterfaces(set, &device, &guid, i, &iface)) - i++; - ok(i == 2, "expected 2 interfaces, got %d\n", i); - ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, "test", 0, &iface); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + ok(IsEqualGUID(&iface.InterfaceClassGuid, &guid), "Got unexpected class %s.\n", + wine_dbgstr_guid(&iface.InterfaceClassGuid)); + ok(iface.Flags == 0, "Got unexpected flags %#x.\n", iface.Flags); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, sizeof(buffer), NULL, NULL); + ok(ret, "Failed to get interface detail, error %#x.\n", GetLastError()); + ok(!strcasecmp(detail->DevicePath, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\test"), + "Got unexpected path %s.\n", detail->DevicePath); + + check_device_iface(set, &device, &guid, 0, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, &device, &guid, 1, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\Oogah"); + check_device_iface(set, &device, &guid, 2, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\test"); + check_device_iface(set, &device, &guid, 3, 0, NULL); + + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid2, NULL, 0, NULL); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
- for (i = 0; i < 2; i++) - { - ret = SetupDiEnumDeviceInterfaces(set, &device, &guid, i, &iface); - ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + check_device_iface(set, &device, &guid2, 0, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A5-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, &device, &guid2, 1, 0, NULL);
- ret = SetupDiRemoveDeviceInterface(set, &iface); + ret = SetupDiEnumDeviceInterfaces(set, &device, &guid2, 0, &iface); + ok(ret, "Failed to enumerate interfaces, error %#x.\n", GetLastError()); + ret = SetupDiRemoveDeviceInterface(set, &iface); todo_wine - ok(ret, "Failed to remove interface, error %#x.\n", GetLastError()); - } + ok(ret, "Failed to remove interface, error %#x.\n", GetLastError()); + + check_device_iface(set, &device, &guid2, 0, SPINT_REMOVED, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A5-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, &device, &guid2, 1, 0, NULL);
ret = SetupDiDestroyDeviceInfoList(set); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError());
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 172 +++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 102 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 539fe637e3..7d485dd145 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -30,6 +30,7 @@ #include "setupapi.h" #include "cfgmgr32.h"
+#include "wine/heap.h" #include "wine/test.h"
static BOOL is_wow64; @@ -48,7 +49,6 @@ static HKEY (WINAPI *pSetupDiCreateDevRegKeyW)(HDEVINFO, PSP_DEVINFO_DATA, D static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiCreateDeviceInfoW)(HDEVINFO, PCWSTR, GUID *, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA); 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 HDEVINFO (WINAPI *pSetupDiGetClassDevsW)(const GUID *, LPCWSTR, HWND, DWORD); @@ -78,7 +78,6 @@ static void init_function_pointers(void) pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); pSetupDiEnumDeviceInterfaces = (void *)GetProcAddress(hSetupAPI, "SetupDiEnumDeviceInterfaces"); pSetupDiGetDeviceInterfaceDetailA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInterfaceDetailA"); - pSetupDiGetDeviceInterfaceDetailW = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInterfaceDetailW"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); pSetupDiOpenDevRegKey = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenDevRegKey"); pSetupDiCreateDevRegKeyW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDevRegKeyW"); @@ -735,7 +734,7 @@ todo_wine ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); }
-static void testGetDeviceInterfaceDetail(void) +static void test_device_iface_detail(void) { static const WCHAR bogus[] = {'S','y','s','t','e','m','\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\', @@ -747,112 +746,81 @@ static void testGetDeviceInterfaceDetail(void) '{','6','a','5','5','b','5','a','4','-','3','f','6','5','-', '1','1','d','b','-','b','7','0','4','-', '0','0','1','1','9','5','5','c','2','b','d','b','}',0}; - BOOL ret; + static const char path[] = "\\?\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; + SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail; + SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; + SP_DEVINFO_DATA device = {sizeof(device)}; + DWORD size = 0, expectedsize; HDEVINFO set; + BOOL ret;
- if (!pSetupDiCreateDeviceInterfaceA || !pSetupDiGetDeviceInterfaceDetailA) - { - win_skip("SetupDiCreateDeviceInterfaceA and/or SetupDiGetDeviceInterfaceDetailA are not available\n"); - return; - } SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(NULL, NULL, NULL, 0, NULL, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, - "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); - set = pSetupDiCreateDeviceInfoList(&guid, NULL); - ok(set != NULL, "SetupDiCreateDeviceInfoList failed: %d\n", GetLastError()); - if (set) - { - SP_DEVINFO_DATA devInfo = { sizeof(devInfo), { 0 } }; - SP_DEVICE_INTERFACE_DATA interfaceData = { sizeof(interfaceData), - { 0 } }; - DWORD size = 0; + ret = SetupDiGetDeviceInterfaceDetailA(NULL, NULL, NULL, 0, NULL, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected error %#x.\n", GetLastError());
- SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set, NULL, NULL, 0, NULL, - NULL); - ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - ret = pSetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, - NULL, NULL, 0, &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 = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, NULL, - 0, NULL, NULL); - ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, - "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, NULL, - 100, NULL, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER, - "Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError()); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, NULL, - 0, &size, NULL); - ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, - "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); - if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) - { - static const char path[] = - "\\?\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; - static const char path_w2k[] = - "\\?\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\"; - LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size); - SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail = - (SP_DEVICE_INTERFACE_DETAIL_DATA_A *)buf; - DWORD expectedsize = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath) + sizeof(WCHAR)*(1 + strlen(path)); - - detail->cbSize = 0; - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, detail, - size, &size, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER, - "Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError()); - detail->cbSize = size; - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, detail, - size, &size, NULL); - ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER, - "Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError()); - detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); - SetLastError(0xdeadbeef); - ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, detail, - size, &size, NULL); - ok(ret, "SetupDiGetDeviceInterfaceDetailA failed: %d\n", - GetLastError()); - ok(!lstrcmpiA(path, detail->DevicePath) || - !lstrcmpiA(path_w2k, detail->DevicePath), "Unexpected path %s\n", - detail->DevicePath); - /* Check SetupDiGetDeviceInterfaceDetailW */ - ret = pSetupDiGetDeviceInterfaceDetailW(set, &interfaceData, NULL, 0, &size, NULL); - ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, - "Expected ERROR_INSUFFICIENT_BUFFER, got error code: %d\n", GetLastError()); - ok(expectedsize == size || - (expectedsize + sizeof(WCHAR)) == size /* W2K adds a backslash */, - "SetupDiGetDeviceInterfaceDetailW returned wrong reqsize, got %d\n", - size); - - HeapFree(GetProcessHeap(), 0, buf); - } + set = SetupDiCreateDeviceInfoList(&guid, NULL); + ok(set != NULL, "Failed to create device list, error %#x.\n", GetLastError());
- ret = pSetupDiEnumDeviceInterfaces(set, &devInfo, &guid, 0, &interfaceData); - ok(ret, "SetupDiEnumDeviceInterfaces failed: %08x\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, NULL, NULL, 0, NULL, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError());
- ret = pSetupDiRemoveDeviceInterface(set, &interfaceData); - todo_wine ok(ret, "SetupDiRemoveDeviceInterface failed: %08x\n", GetLastError()); + ret = SetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError());
- ret = pSetupDiRemoveDevice(set, &devInfo); - todo_wine ok(ret, "got %u\n", GetLastError()); - pSetupDiDestroyDeviceInfoList(set); + SetLastError(0xdeadbeef); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &guid, NULL, 0, &iface); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError());
- /* remove once Wine is fixed */ - devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); - devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, devclass); - } + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, NULL, 0, NULL, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, NULL, 100, NULL, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, NULL, 0, &size, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + detail = heap_alloc(size); + expectedsize = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath[strlen(path) + 1]); + + detail->cbSize = 0; + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, size, &size, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + detail->cbSize = size; + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, size, &size, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, size, &size, NULL); + ok(ret, "Failed to get interface detail, error %#x.\n", GetLastError()); + ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath); + + ret = SetupDiGetDeviceInterfaceDetailW(set, &iface, NULL, 0, &size, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + ok(size == expectedsize, "Got unexpected size %d.\n", size); + + heap_free(detail); + SetupDiDestroyDeviceInfoList(set); + + /* remove once Wine is fixed */ + devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); + devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, devclass); }
static void testDevRegKey(void) @@ -1588,7 +1556,7 @@ START_TEST(devinst) test_get_device_instance_id(); test_register_device_info(); test_device_iface(); - testGetDeviceInterfaceDetail(); + test_device_iface_detail(); testDevRegKey(); testRegisterAndGetDetail(); testDeviceRegistryPropertyA();