Module: wine Branch: master Commit: 7876234e3ad3f664bdc02e976458dc87fb00f0a5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=7876234e3ad3f664bdc02e976...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Fri Mar 15 11:42:18 2019 +0800
setupapi/tests: Add more SetupDiCreateDeviceInfo() tests.
SetupDiCreateDeviceInfo() should report last error ERROR_DEVINST_ALREADY_EXISTS when an registered instance exists when creating a device for an empty set.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/setupapi/tests/devinst.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index de4d00e..01891b1 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -212,6 +212,7 @@ static void test_device_info(void) char id[MAX_DEVICE_ID_LEN + 2]; HDEVINFO set; BOOL ret; + INT i = 0;
SetLastError(0xdeadbeef); ret = SetupDiCreateDeviceInfoA(NULL, NULL, NULL, NULL, NULL, 0, NULL); @@ -344,6 +345,31 @@ static void test_device_info(void) ok(ret, "Failed to create device, error %#x.\n", GetLastError());
SetupDiDestroyDeviceInfoList(set); + + set = SetupDiCreateDeviceInfoList(&guid, NULL); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device info list, error %#x.\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 = SetupDiRegisterDeviceInfo(set , &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\0000"); + check_device_info(set, 1, NULL, NULL); + SetupDiDestroyDeviceInfoList(set); + + set = SetupDiCreateDeviceInfoList(&guid, NULL); + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\0000", &guid, NULL, NULL, 0, &device); + todo_wine ok(!ret, "Expect failure\n"); + todo_wine ok(GetLastError() == ERROR_DEVINST_ALREADY_EXISTS, "Got error %#x\n", GetLastError()); + todo_wine check_device_info(set, 0, NULL, NULL); + SetupDiDestroyDeviceInfoList(set); + + set = SetupDiGetClassDevsA(&guid, NULL, NULL, 0); + while (SetupDiEnumDeviceInfo(set, i++, &device)) + { + ret = SetupDiRemoveDevice(set, &device); + ok(ret, "Failed to remove device, error %#x.\n", GetLastError()); + } + SetupDiDestroyDeviceInfoList(set); }
static void test_device_property(void)