setupapi/tests: Make tests pass on Vista and W2K8.

This commit is contained in:
Ge van Geldorp 2009-01-26 01:26:52 +01:00 committed by Alexandre Julliard
parent b7ac6cb01d
commit 115805f12e
1 changed files with 30 additions and 22 deletions

View File

@ -271,7 +271,7 @@ static void test_SetupDiCreateDeviceInfoListEx(void)
error = GetLastError(); error = GetLastError();
ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE); ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE);
ok(error == ERROR_INVALID_MACHINENAME, "GetLastError returned wrong value : %d, (expected %d)\n", error, ERROR_INVALID_MACHINENAME); ok(error == ERROR_INVALID_MACHINENAME || error == ERROR_MACHINE_UNAVAILABLE, "GetLastError returned wrong value : %d, (expected %d or %d)\n", error, ERROR_INVALID_MACHINENAME, ERROR_MACHINE_UNAVAILABLE);
/* create empty DeviceInfoList */ /* create empty DeviceInfoList */
devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL); devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
@ -887,6 +887,7 @@ static void testDevRegKey(void)
BOOL ret; BOOL ret;
HDEVINFO set; HDEVINFO set;
HKEY key = NULL; HKEY key = NULL;
BOOL classKeyCreated;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
key = pSetupDiCreateDevRegKeyW(NULL, NULL, 0, 0, 0, NULL, NULL); key = pSetupDiCreateDevRegKeyW(NULL, NULL, 0, 0, 0, NULL, NULL);
@ -974,26 +975,33 @@ static void testDevRegKey(void)
/* Create the device reg key */ /* Create the device reg key */
key = pSetupDiCreateDevRegKeyW(set, &devInfo, DICS_FLAG_GLOBAL, 0, key = pSetupDiCreateDevRegKeyW(set, &devInfo, DICS_FLAG_GLOBAL, 0,
DIREG_DRV, NULL, NULL); DIREG_DRV, NULL, NULL);
ok(key != INVALID_HANDLE_VALUE, "SetupDiCreateDevRegKey failed: %08x\n", /* Vista and higher don't actually create the key */
GetLastError()); ok(key != INVALID_HANDLE_VALUE || GetLastError() == ERROR_KEY_DOES_NOT_EXIST,
RegCloseKey(key); "SetupDiCreateDevRegKey failed: %08x\n", GetLastError());
/* The class key should have been created */ if (key != INVALID_HANDLE_VALUE)
ok(!RegOpenKeyW(HKEY_LOCAL_MACHINE, classKey, &key), {
"Expected registry key to exist\n"); classKeyCreated = TRUE;
RegCloseKey(key); RegCloseKey(key);
SetLastError(0xdeadbeef); /* The class key should have been created */
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, ok(!RegOpenKeyW(HKEY_LOCAL_MACHINE, classKey, &key),
DIREG_DRV, 0); "Expected registry key to exist\n");
todo_wine RegCloseKey(key);
ok(key == INVALID_HANDLE_VALUE && SetLastError(0xdeadbeef);
(GetLastError() == ERROR_INVALID_DATA || key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0,
GetLastError() == ERROR_ACCESS_DENIED), /* win2k3 */ DIREG_DRV, 0);
"Expected ERROR_INVALID_DATA or ERROR_ACCESS_DENIED, got %08x\n", GetLastError()); todo_wine
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0, ok(key == INVALID_HANDLE_VALUE &&
DIREG_DRV, KEY_READ); (GetLastError() == ERROR_INVALID_DATA ||
ok(key != INVALID_HANDLE_VALUE, "SetupDiOpenDevRegKey failed: %08x\n", GetLastError() == ERROR_ACCESS_DENIED), /* win2k3 */
GetLastError()); "Expected ERROR_INVALID_DATA or ERROR_ACCESS_DENIED, got %08x\n", GetLastError());
pSetupDiDestroyDeviceInfoList(set); key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0,
DIREG_DRV, KEY_READ);
ok(key != INVALID_HANDLE_VALUE, "SetupDiOpenDevRegKey failed: %08x\n",
GetLastError());
pSetupDiDestroyDeviceInfoList(set);
}
else
classKeyCreated = FALSE;
/* Cleanup */ /* Cleanup */
ret = remove_device(); ret = remove_device();
@ -1008,7 +1016,7 @@ static void testDevRegKey(void)
devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus); devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, bogus);
devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey); devinst_RegDeleteTreeW(HKEY_LOCAL_MACHINE, classKey);
} }
else else if (classKeyCreated)
{ {
/* There should only be a class key entry, so a simple /* There should only be a class key entry, so a simple
* RegDeleteKey should work * RegDeleteKey should work