Module: wine Branch: master Commit: 17f66b7086b01b889d71ed1c8adb714aabb6bb8d URL: http://source.winehq.org/git/wine.git/?a=commit;h=17f66b7086b01b889d71ed1c8a...
Author: Hans Leidekker hans@it.vu.nl Date: Fri Nov 17 13:48:38 2006 +0100
setupapi: Add tests for SetupGet{SourceFileLocation, SourceInfo, TargetPath}.
---
dlls/setupapi/tests/query.c | 130 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 130 insertions(+), 0 deletions(-)
diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c index a1d3e3e..50d341b 100644 --- a/dlls/setupapi/tests/query.c +++ b/dlls/setupapi/tests/query.c @@ -29,6 +29,9 @@ static void (WINAPI *pSetupCloseInfFile) static BOOL (WINAPI *pSetupGetInfInformationA)(LPCVOID,DWORD,PSP_INF_INFORMATION,DWORD,PDWORD); static HINF (WINAPI *pSetupOpenInfFileA)(PCSTR,PCSTR,DWORD,PUINT); 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 WIN_DIR[MAX_PATH]; @@ -43,6 +46,9 @@ static void init_function_pointers(void) pSetupGetInfInformationA = (void *)GetProcAddress(hSetupAPI, "SetupGetInfInformationA"); pSetupOpenInfFileA = (void *)GetProcAddress(hSetupAPI, "SetupOpenInfFileA"); 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 filena append_str(&ptr, "[Version]\n"); append_str(&ptr, "Signature="$Chicago$"\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); CloseHandle(hf); @@ -251,10 +267,124 @@ static void test_SetupGetInfInformation( 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) { init_function_pointers(); get_directories();
test_SetupGetInfInformation(); + test_SetupGetSourceFileLocation(); + test_SetupGetSourceInfo(); + test_SetupGetTargetPath(); }