From: Vijay Kiran Kamuju Subject: [PATCH 1/4] setupapi/tests: Add more tests for SPFILENOTIFY_FILEINCABINET handler. Message-Id: Date: Thu, 2 Jul 2020 17:38:57 +0200 Signed-off-by: Vijay Kiran Kamuju From 8066ad83cb8fe19bb1a463d65d8ece6859b75775 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 20 Apr 2017 17:08:11 +0800 Subject: [PATCH 1/4] setupapi/tests: Add more tests for SPFILENOTIFY_FILEINCABINET handler. Signed-off-by: Vijay Kiran Kamuju --- dlls/setupapi/tests/setupcab.c | 46 ++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/dlls/setupapi/tests/setupcab.c b/dlls/setupapi/tests/setupcab.c index bb9add035d..37254aa962 100644 --- a/dlls/setupapi/tests/setupcab.c +++ b/dlls/setupapi/tests/setupcab.c @@ -299,11 +299,17 @@ static void test_invalid_callbackW(void) static const char *expected_files[] = {"tristram", "wine", "shandy"}; +struct contextA +{ + int count; + const char *cabinet; +}; + static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2) { static int index; - int *file_count = Context; + struct contextA *ctx = Context; switch (Notification) { @@ -313,14 +319,19 @@ static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification, case SPFILENOTIFY_FILEINCABINET: { FILE_IN_CABINET_INFO_A *info = (FILE_IN_CABINET_INFO_A *)Param1; + const char *cabinet_file = (const char *)Param2; - (*file_count)++; + ctx->count++; if (index < ARRAY_SIZE(expected_files)) { ok(!strcmp(expected_files[index], info->NameInCabinet), "[%d] Expected file \"%s\", got \"%s\"\n", index, expected_files[index], info->NameInCabinet); +todo_wine + ok(!strcmp(ctx->cabinet, cabinet_file), + "[%d] Expected cabinet \"%s\", got \"%s\"\n", + index, ctx->cabinet, cabinet_file); index++; return FILEOP_SKIP; } @@ -339,16 +350,18 @@ static void test_simple_enumerationA(void) { BOOL ret; char source[MAX_PATH], temp[MAX_PATH]; - int enum_count = 0; + struct contextA ctx; GetTempPathA(sizeof(temp), temp); GetTempFileNameA(temp, "doc", 0, source); create_source_fileA(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi)); - ret = SetupIterateCabinetA(source, 0, simple_callbackA, &enum_count); + ctx.count = 0; + ctx.cabinet = source; + ret = SetupIterateCabinetA(source, 0, simple_callbackA, &ctx); ok(ret == 1, "Expected SetupIterateCabinetA to return 1, got %d\n", ret); - ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count); + ok(ctx.count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", ctx.count); DeleteFileA(source); } @@ -358,11 +371,17 @@ static const WCHAR wineW[] = {'w','i','n','e',0}; static const WCHAR shandyW[] = {'s','h','a','n','d','y',0}; static const WCHAR *expected_filesW[] = {tristramW, wineW, shandyW}; +struct contextW +{ + int count; + const WCHAR *cabinet; +}; + static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2) { static int index; - int *file_count = Context; + struct contextW *ctx = Context; switch (Notification) { @@ -372,14 +391,19 @@ static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification, case SPFILENOTIFY_FILEINCABINET: { FILE_IN_CABINET_INFO_W *info = (FILE_IN_CABINET_INFO_W *)Param1; + const WCHAR *cabinet_file = (const WCHAR *)Param2; - (*file_count)++; + ctx->count++; if (index < ARRAY_SIZE(expected_filesW)) { ok(!lstrcmpW(expected_filesW[index], info->NameInCabinet), "[%d] Expected file %s, got %s\n", index, wine_dbgstr_w(expected_filesW[index]), wine_dbgstr_w(info->NameInCabinet)); +todo_wine + ok(!lstrcmpW(ctx->cabinet, cabinet_file), + "[%d] Expected cabinet %s, got %s\n", + index, wine_dbgstr_w(ctx->cabinet), wine_dbgstr_w(cabinet_file)); index++; return FILEOP_SKIP; } @@ -398,7 +422,7 @@ static void test_simple_enumerationW(void) { BOOL ret; WCHAR source[MAX_PATH], temp[MAX_PATH]; - int enum_count = 0; + struct contextW ctx; ret = SetupIterateCabinetW(NULL, 0, NULL, NULL); if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) @@ -412,9 +436,11 @@ static void test_simple_enumerationW(void) create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi)); - ret = SetupIterateCabinetW(source, 0, simple_callbackW, &enum_count); + ctx.count = 0; + ctx.cabinet = source; + ret = SetupIterateCabinetW(source, 0, simple_callbackW, &ctx); ok(ret == 1, "Expected SetupIterateCabinetW to return 1, got %d\n", ret); - ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count); + ok(ctx.count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", ctx.count); DeleteFileW(source); } -- 2.27.0