Juan Lang : setupapi: Test SetupDiInstallClass.
Alexandre Julliard
julliard at winehq.org
Fri Oct 12 05:22:59 CDT 2007
Module: wine
Branch: master
Commit: caae01f8becfd8df94edf4cdc8f51c41485f4610
URL: http://source.winehq.org/git/wine.git/?a=commit;h=caae01f8becfd8df94edf4cdc8f51c41485f4610
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Oct 11 14:06:06 2007 -0700
setupapi: Test SetupDiInstallClass.
---
dlls/setupapi/tests/devinst.c | 90 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 89 insertions(+), 1 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 0b58e4e..a27fa5b 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -20,7 +20,7 @@
#include <assert.h>
#include <stdarg.h>
-
+#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
@@ -39,6 +39,7 @@ static BOOL (WINAPI *pSetupDiCreateDeviceInterfaceA)(HDEVINFO, PSP_DEVINFO_D
static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO);
static BOOL (WINAPI *pSetupDiEnumDeviceInfo)(HDEVINFO, DWORD, PSP_DEVINFO_DATA);
static BOOL (WINAPI *pSetupDiEnumDeviceInterfaces)(HDEVINFO, PSP_DEVINFO_DATA, const GUID *, DWORD, PSP_DEVICE_INTERFACE_DATA);
+static BOOL (WINAPI *pSetupDiInstallClassA)(HWND, PCSTR, DWORD, HSPFILEQ);
static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID);
static BOOL (WINAPI *pSetupDiCreateDeviceInfoA)(HDEVINFO, PCSTR, GUID *, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA);
static BOOL (WINAPI *pSetupDiGetDeviceInstanceIdA)(HDEVINFO, PSP_DEVINFO_DATA, PSTR, DWORD, PDWORD);
@@ -58,6 +59,7 @@ static void init_function_pointers(void)
pSetupDiEnumDeviceInterfaces = (void *)GetProcAddress(hSetupAPI, "SetupDiEnumDeviceInterfaces");
pSetupDiGetDeviceInstanceIdA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInstanceIdA");
pSetupDiGetDeviceInterfaceDetailA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetDeviceInterfaceDetailA");
+ pSetupDiInstallClassA = (void *)GetProcAddress(hSetupAPI, "SetupDiInstallClassA");
pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA");
pSetupDiRegisterDeviceInfo = (void *)GetProcAddress(hSetupAPI, "SetupDiRegisterDeviceInfo");
}
@@ -139,6 +141,91 @@ static void test_SetupDiOpenClassRegKeyExA(void)
trace("failed to open classes key\n");
}
+static void append_str(char **str, const char *data)
+{
+ sprintf(*str, data);
+ *str += strlen(*str);
+}
+
+static void create_inf_file(LPCSTR filename)
+{
+ char data[1024];
+ char *ptr = data;
+ DWORD dwNumberOfBytesWritten;
+ HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ append_str(&ptr, "[Version]\n");
+ append_str(&ptr, "Signature=\"$Chicago$\"\n");
+ append_str(&ptr, "Class=Bogus\n");
+ append_str(&ptr, "ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}\n");
+ append_str(&ptr, "[ClassInstall32]\n");
+ append_str(&ptr, "AddReg=BogusClass.NT.AddReg\n");
+ append_str(&ptr, "[BogusClass.NT.AddReg]\n");
+ append_str(&ptr, "HKR,,,,\"Wine test devices\"\n");
+
+ WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL);
+ CloseHandle(hf);
+}
+
+static void get_temp_filename(LPSTR path)
+{
+ static char curr[MAX_PATH] = { 0 };
+ char temp[MAX_PATH];
+ LPSTR ptr;
+
+ if (!*curr)
+ GetCurrentDirectoryA(MAX_PATH, curr);
+ GetTempFileNameA(curr, "set", 0, temp);
+ ptr = strrchr(temp, '\\');
+
+ lstrcpyA(path, ptr + 1);
+}
+
+static void testInstallClass(void)
+{
+ static const WCHAR classKey[] = {'S','y','s','t','e','m','\\',
+ 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
+ 'C','o','n','t','r','o','l','\\','C','l','a','s','s','\\',
+ '{','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};
+ char tmpfile[MAX_PATH], dstfile[MAX_PATH * 2];
+ BOOL ret;
+
+ if (!pSetupDiInstallClassA)
+ {
+ skip("No SetupDiInstallClassA\n");
+ return;
+ }
+ tmpfile[0] = '.';
+ tmpfile[1] = '\\';
+ get_temp_filename(tmpfile + 2);
+ create_inf_file(tmpfile + 2);
+
+ ret = pSetupDiInstallClassA(NULL, NULL, 0, NULL);
+ todo_wine
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+ ret = pSetupDiInstallClassA(NULL, NULL, DI_NOVCP, NULL);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+ ret = pSetupDiInstallClassA(NULL, tmpfile + 2, DI_NOVCP, NULL);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+ ret = pSetupDiInstallClassA(NULL, tmpfile + 2, 0, NULL);
+ ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
+ "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+ ret = pSetupDiInstallClassA(NULL, tmpfile, 0, NULL);
+ ok(ret, "SetupDiInstallClassA failed: %08x\n", GetLastError());
+ RegDeleteKeyW(HKEY_LOCAL_MACHINE, classKey);
+ GetWindowsDirectoryA(dstfile, MAX_PATH);
+ lstrcatA(dstfile, "inf\\");
+ lstrcatA(dstfile, tmpfile + 2);
+ DeleteFile(dstfile);
+ DeleteFile(tmpfile);
+}
+
static void testCreateDeviceInfo(void)
{
BOOL ret;
@@ -510,6 +597,7 @@ START_TEST(devinst)
test_SetupDiOpenClassRegKeyExA();
else
skip("SetupDiOpenClassRegKeyExA is not available\n");
+ testInstallClass();
testCreateDeviceInfo();
testGetDeviceInstanceId();
testRegisterDeviceInfo();
More information about the wine-cvs
mailing list