2006-06-13 19:13:32 +02:00
|
|
|
/*
|
|
|
|
* Devinst tests
|
|
|
|
*
|
|
|
|
* Copyright 2006 Christian Gmeiner
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
2006-09-09 13:25:30 +02:00
|
|
|
#include "guiddef.h"
|
2006-06-13 19:13:32 +02:00
|
|
|
#include "setupapi.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2006-08-15 17:40:31 +02:00
|
|
|
/* function pointers */
|
|
|
|
static HMODULE hSetupAPI;
|
|
|
|
static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID);
|
|
|
|
static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO);
|
2006-09-09 13:25:30 +02:00
|
|
|
static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID);
|
2006-08-15 17:40:31 +02:00
|
|
|
|
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
hSetupAPI = LoadLibraryA("setupapi.dll");
|
|
|
|
|
|
|
|
if (hSetupAPI)
|
|
|
|
{
|
|
|
|
pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW");
|
|
|
|
pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList");
|
2006-09-09 13:25:30 +02:00
|
|
|
pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA");
|
2006-08-15 17:40:31 +02:00
|
|
|
}
|
|
|
|
}
|
2006-06-13 19:13:32 +02:00
|
|
|
|
2006-07-20 15:08:32 +02:00
|
|
|
static void test_SetupDiCreateDeviceInfoListEx(void)
|
2006-06-13 19:13:32 +02:00
|
|
|
{
|
|
|
|
HDEVINFO devlist;
|
|
|
|
BOOL ret;
|
|
|
|
DWORD error;
|
2006-08-05 18:28:04 +02:00
|
|
|
static CHAR notnull[] = "NotNull";
|
2006-06-13 19:13:32 +02:00
|
|
|
static const WCHAR machine[] = { 'd','u','m','m','y',0 };
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
/* create empty DeviceInfoList, but set Reserved to a value, which is not NULL */
|
2006-08-15 17:40:31 +02:00
|
|
|
devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, notnull);
|
2006-06-13 19:13:32 +02:00
|
|
|
|
|
|
|
error = GetLastError();
|
|
|
|
ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %ld (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE);
|
2006-06-30 19:15:10 +02:00
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "GetLastError returned wrong value : %ld, (expected %d)\n", error, ERROR_INVALID_PARAMETER);
|
2006-06-13 19:13:32 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
/* create empty DeviceInfoList, but set MachineName to something */
|
2006-08-15 17:40:31 +02:00
|
|
|
devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, machine, NULL);
|
2006-06-13 19:13:32 +02:00
|
|
|
|
|
|
|
error = GetLastError();
|
|
|
|
ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %ld (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE);
|
2006-06-30 19:15:10 +02:00
|
|
|
ok(error == ERROR_INVALID_MACHINENAME, "GetLastError returned wrong value : %ld, (expected %d)\n", error, ERROR_INVALID_MACHINENAME);
|
2006-06-13 19:13:32 +02:00
|
|
|
|
|
|
|
/* create empty DeviceInfoList */
|
2006-08-15 17:40:31 +02:00
|
|
|
devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
|
2006-06-13 19:13:32 +02:00
|
|
|
ok(devlist && devlist != INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %ld (expected != %p)\n", devlist, error, INVALID_HANDLE_VALUE);
|
|
|
|
|
|
|
|
/* destroy DeviceInfoList */
|
2006-08-15 17:40:31 +02:00
|
|
|
ret = pSetupDiDestroyDeviceInfoList(devlist);
|
2006-06-30 19:15:10 +02:00
|
|
|
ok(ret, "SetupDiDestroyDeviceInfoList failed : %ld\n", error);
|
2006-06-13 19:13:32 +02:00
|
|
|
}
|
|
|
|
|
2006-09-09 13:25:30 +02:00
|
|
|
static void test_SetupDiOpenClassRegKeyExA(void)
|
|
|
|
{
|
|
|
|
/* This is a unique guid for testing purposes */
|
|
|
|
GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,
|
|
|
|
0x00,0x11,0x95,0x5c,0x2b,0xdb}};
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
/* Check return value for non-existent key */
|
|
|
|
hkey = SetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS,
|
|
|
|
DIOCR_INSTALLER, NULL, NULL);
|
|
|
|
ok(hkey == INVALID_HANDLE_VALUE,
|
|
|
|
"returned %p (expected INVALID_HANDLE_VALUE)\n", hkey);
|
|
|
|
}
|
|
|
|
|
2006-06-13 19:13:32 +02:00
|
|
|
START_TEST(devinst)
|
|
|
|
{
|
2006-08-15 17:40:31 +02:00
|
|
|
init_function_pointers();
|
|
|
|
if (!hSetupAPI)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pSetupDiCreateDeviceInfoListExW && pSetupDiDestroyDeviceInfoList)
|
|
|
|
test_SetupDiCreateDeviceInfoListEx();
|
|
|
|
else
|
2006-09-09 13:25:30 +02:00
|
|
|
trace("Needed calls for SetupDiCreateDeviceInfoListEx not all available, skipping test.\n");
|
|
|
|
|
|
|
|
if (pSetupDiOpenClassRegKeyExA)
|
|
|
|
test_SetupDiOpenClassRegKeyExA();
|
|
|
|
else
|
|
|
|
trace("Needed call for SetupDiOpenClassRegKeyExA not available, skipping test.\n");
|
2006-06-13 19:13:32 +02:00
|
|
|
}
|