From 45d199023f440209c5753e055db233924664df22 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 15 May 2019 22:56:08 -0500 Subject: [PATCH] setupapi/tests: Add some basic tests for SetupDi{Get, Set}DeviceInstallParams(). Signed-off-by: Zebediah Figura Signed-off-by: Aric Stewart Signed-off-by: Alexandre Julliard --- dlls/setupapi/tests/devinst.c | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 2355f30a355..9107d829452 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -1881,6 +1881,77 @@ static void test_device_interface_key(void) SetupDiDestroyDeviceInfoList(set); } +static void test_device_install_params(void) +{ + SP_DEVINFO_DATA device = {sizeof(device)}; + SP_DEVINSTALL_PARAMS_A params; + HDEVINFO set; + BOOL ret; + + set = SetupDiCreateDeviceInfoList(&guid, NULL); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device 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()); + + params.cbSize = sizeof(params) - 1; + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInstallParamsA(set, &device, ¶ms); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + params.cbSize = sizeof(params) + 1; + SetLastError(0xdeadbeef); + ret = SetupDiGetDeviceInstallParamsA(set, &device, ¶ms); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + params.cbSize = sizeof(params) - 1; + SetLastError(0xdeadbeef); + ret = SetupDiSetDeviceInstallParamsA(set, &device, ¶ms); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + params.cbSize = sizeof(params) + 1; + SetLastError(0xdeadbeef); + ret = SetupDiSetDeviceInstallParamsA(set, &device, ¶ms); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#x.\n", GetLastError()); + + memset(¶ms, 0xcc, sizeof(params)); + params.cbSize = sizeof(params); + ret = SetupDiGetDeviceInstallParamsA(set, &device, ¶ms); + ok(ret, "Failed to get device install params, error %#x.\n", GetLastError()); + ok(!params.Flags, "Got flags %#x.\n", params.Flags); + ok(!params.FlagsEx, "Got extended flags %#x.\n", params.FlagsEx); + ok(!params.hwndParent, "Got parent %p.\n", params.hwndParent); + ok(!params.InstallMsgHandler, "Got callback %p.\n", params.InstallMsgHandler); + ok(!params.InstallMsgHandlerContext, "Got callback context %p.\n", params.InstallMsgHandlerContext); + ok(!params.FileQueue, "Got queue %p.\n", params.FileQueue); + ok(!params.ClassInstallReserved, "Got class installer data %#lx.\n", params.ClassInstallReserved); + ok(!params.DriverPath[0], "Got driver path %s.\n", params.DriverPath); + + params.Flags = DI_INF_IS_SORTED; + params.FlagsEx = DI_FLAGSEX_ALLOWEXCLUDEDDRVS; + strcpy(params.DriverPath, "C:\\windows"); + ret = SetupDiSetDeviceInstallParamsA(set, &device, ¶ms); + ok(ret, "Failed to set device install params, error %#x.\n", GetLastError()); + + memset(¶ms, 0xcc, sizeof(params)); + params.cbSize = sizeof(params); + ret = SetupDiGetDeviceInstallParamsA(set, &device, ¶ms); + ok(ret, "Failed to get device install params, error %#x.\n", GetLastError()); + ok(params.Flags == DI_INF_IS_SORTED, "Got flags %#x.\n", params.Flags); + ok(params.FlagsEx == DI_FLAGSEX_ALLOWEXCLUDEDDRVS, "Got extended flags %#x.\n", params.FlagsEx); + ok(!params.hwndParent, "Got parent %p.\n", params.hwndParent); + ok(!params.InstallMsgHandler, "Got callback %p.\n", params.InstallMsgHandler); + ok(!params.InstallMsgHandlerContext, "Got callback context %p.\n", params.InstallMsgHandlerContext); + ok(!params.FileQueue, "Got queue %p.\n", params.FileQueue); + ok(!params.ClassInstallReserved, "Got class installer data %#lx.\n", params.ClassInstallReserved); + ok(!strcasecmp(params.DriverPath, "C:\\windows"), "Got driver path %s.\n", params.DriverPath); + + SetupDiDestroyDeviceInfoList(set); +} + START_TEST(devinst) { HKEY hkey; @@ -1909,4 +1980,5 @@ START_TEST(devinst) test_get_inf_class(); test_devnode(); test_device_interface_key(); + test_device_install_params(); }