Commit 17f66b70 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

setupapi: Add tests for SetupGet{SourceFileLocation, SourceInfo, TargetPath}.

parent 7f9a5fac
...@@ -29,6 +29,9 @@ static void (WINAPI *pSetupCloseInfFile)(HINF); ...@@ -29,6 +29,9 @@ static void (WINAPI *pSetupCloseInfFile)(HINF);
static BOOL (WINAPI *pSetupGetInfInformationA)(LPCVOID,DWORD,PSP_INF_INFORMATION,DWORD,PDWORD); static BOOL (WINAPI *pSetupGetInfInformationA)(LPCVOID,DWORD,PSP_INF_INFORMATION,DWORD,PDWORD);
static HINF (WINAPI *pSetupOpenInfFileA)(PCSTR,PCSTR,DWORD,PUINT); static HINF (WINAPI *pSetupOpenInfFileA)(PCSTR,PCSTR,DWORD,PUINT);
static BOOL (WINAPI *pSetupQueryInfFileInformationA)(PSP_INF_INFORMATION,UINT,PSTR,DWORD,PDWORD); static BOOL (WINAPI *pSetupQueryInfFileInformationA)(PSP_INF_INFORMATION,UINT,PSTR,DWORD,PDWORD);
static BOOL (WINAPI *pSetupGetSourceFileLocationA)(HINF,PINFCONTEXT,PCSTR,PUINT,PSTR,DWORD,PDWORD);
static BOOL (WINAPI *pSetupGetSourceInfoA)(HINF,UINT,UINT,PSTR,DWORD,PDWORD);
static BOOL (WINAPI *pSetupGetTargetPathA)(HINF,PINFCONTEXT,PCSTR,PSTR,DWORD,PDWORD);
CHAR CURR_DIR[MAX_PATH]; CHAR CURR_DIR[MAX_PATH];
CHAR WIN_DIR[MAX_PATH]; CHAR WIN_DIR[MAX_PATH];
...@@ -43,6 +46,9 @@ static void init_function_pointers(void) ...@@ -43,6 +46,9 @@ static void init_function_pointers(void)
pSetupGetInfInformationA = (void *)GetProcAddress(hSetupAPI, "SetupGetInfInformationA"); pSetupGetInfInformationA = (void *)GetProcAddress(hSetupAPI, "SetupGetInfInformationA");
pSetupOpenInfFileA = (void *)GetProcAddress(hSetupAPI, "SetupOpenInfFileA"); pSetupOpenInfFileA = (void *)GetProcAddress(hSetupAPI, "SetupOpenInfFileA");
pSetupQueryInfFileInformationA = (void *)GetProcAddress(hSetupAPI, "SetupQueryInfFileInformationA"); pSetupQueryInfFileInformationA = (void *)GetProcAddress(hSetupAPI, "SetupQueryInfFileInformationA");
pSetupGetSourceFileLocationA = (void *)GetProcAddress(hSetupAPI, "SetupGetSourceFileLocationA");
pSetupGetSourceInfoA = (void *)GetProcAddress(hSetupAPI, "SetupGetSourceInfoA");
pSetupGetTargetPathA = (void *)GetProcAddress(hSetupAPI, "SetupGetTargetPathA");
} }
} }
...@@ -80,6 +86,16 @@ static void create_inf_file(LPSTR filename) ...@@ -80,6 +86,16 @@ static void create_inf_file(LPSTR filename)
append_str(&ptr, "[Version]\n"); append_str(&ptr, "[Version]\n");
append_str(&ptr, "Signature=\"$Chicago$\"\n"); append_str(&ptr, "Signature=\"$Chicago$\"\n");
append_str(&ptr, "AdvancedINF=2.5\n"); append_str(&ptr, "AdvancedINF=2.5\n");
append_str(&ptr, "[SourceDisksNames]\n");
append_str(&ptr, "2 = %%SrcDiskName%%, LANCOM\\LANtools\\lanconf.cab\n");
append_str(&ptr, "[SourceDisksFiles]\n");
append_str(&ptr, "lanconf.exe = 2\n");
append_str(&ptr, "[DestinationDirs]\n");
append_str(&ptr, "DefaultDestDir = 24, %%DefaultDest%%\n");
append_str(&ptr, "[Strings]\n");
append_str(&ptr, "LangDir = english\n");
append_str(&ptr, "DefaultDest = LANCOM\n");
append_str(&ptr, "SrcDiskName = \"LANCOM Software CD\"\n");
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf); CloseHandle(hf);
...@@ -251,10 +267,124 @@ static void test_SetupGetInfInformation(void) ...@@ -251,10 +267,124 @@ static void test_SetupGetInfInformation(void)
DeleteFileA(inf_two); DeleteFileA(inf_two);
} }
static void test_SetupGetSourceFileLocation(void)
{
char buffer[MAX_PATH] = "not empty", inf_filename[MAX_PATH];
UINT source_id;
DWORD required;
HINF hinf;
BOOL ret;
lstrcpyA(inf_filename, CURR_DIR);
lstrcatA(inf_filename, "\\");
lstrcatA(inf_filename, "test.inf");
create_inf_file(inf_filename);
hinf = pSetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
required = 0;
source_id = 0;
ret = pSetupGetSourceFileLocationA(hinf, NULL, "lanconf.exe", &source_id, buffer, sizeof(buffer), &required);
ok(ret, "SetupGetSourceFileLocation failed\n");
ok(required == 1, "unexpected required size: %d\n", required);
ok(source_id == 2, "unexpected source id: %d\n", source_id);
ok(!lstrcmpA("", buffer), "unexpected result string: %s\n", buffer);
pSetupCloseInfFile(hinf);
DeleteFileA(inf_filename);
}
static void test_SetupGetSourceInfo(void)
{
char buffer[MAX_PATH], inf_filename[MAX_PATH];
DWORD required;
HINF hinf;
BOOL ret;
lstrcpyA(inf_filename, CURR_DIR);
lstrcatA(inf_filename, "\\");
lstrcatA(inf_filename, "test.inf");
create_inf_file(inf_filename);
hinf = pSetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
required = 0;
ret = pSetupGetSourceInfoA(hinf, 2, SRCINFO_PATH, buffer, sizeof(buffer), &required);
ok(ret, "SetupGetSourceInfoA failed\n");
ok(required == 1, "unexpected required size: %d\n", required);
ok(!lstrcmpA("", buffer), "unexpected result string: %s\n", buffer);
required = 0;
buffer[0] = 0;
ret = pSetupGetSourceInfoA(hinf, 2, SRCINFO_TAGFILE, buffer, sizeof(buffer), &required);
ok(ret, "SetupGetSourceInfoA failed\n");
ok(required == 28, "unexpected required size: %d\n", required);
ok(!lstrcmpA("LANCOM\\LANtools\\lanconf.cab", buffer), "unexpected result string: %s\n", buffer);
required = 0;
buffer[0] = 0;
ret = pSetupGetSourceInfoA(hinf, 2, SRCINFO_DESCRIPTION, buffer, sizeof(buffer), &required);
ok(ret, "SetupGetSourceInfoA failed\n");
ok(required == 19, "unexpected required size: %d\n", required);
ok(!lstrcmpA("LANCOM Software CD", buffer), "unexpected result string: %s\n", buffer);
pSetupCloseInfFile(hinf);
DeleteFileA(inf_filename);
}
static void test_SetupGetTargetPath(void)
{
char buffer[MAX_PATH], inf_filename[MAX_PATH];
DWORD required;
HINF hinf;
INFCONTEXT ctx;
BOOL ret;
lstrcpyA(inf_filename, CURR_DIR);
lstrcatA(inf_filename, "\\");
lstrcatA(inf_filename, "test.inf");
create_inf_file(inf_filename);
hinf = pSetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
ctx.Inf = hinf;
ctx.CurrentInf = hinf;
ctx.Section = 7;
ctx.Line = 0;
required = 0;
ret = pSetupGetTargetPathA(hinf, &ctx, NULL, buffer, sizeof(buffer), &required);
ok(ret, "SetupGetTargetPathA failed\n");
ok(required == 10, "unexpected required size: %d\n", required);
ok(!lstrcmpiA("C:\\LANCOM", buffer), "unexpected result string: %s\n", buffer);
pSetupCloseInfFile(hinf);
DeleteFileA(inf_filename);
}
START_TEST(query) START_TEST(query)
{ {
init_function_pointers(); init_function_pointers();
get_directories(); get_directories();
test_SetupGetInfInformation(); test_SetupGetInfInformation();
test_SetupGetSourceFileLocation();
test_SetupGetSourceInfo();
test_SetupGetTargetPath();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment