From 837660e04bac18ffda78e6727dc7b03405b65184 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 19 May 2021 14:43:13 +0100 Subject: [PATCH] winspool/tests: Add tests for GetFormA(). Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/winspool.drv/tests/info.c | 45 +++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c index b95180ee558..a9fbe727453 100644 --- a/dlls/winspool.drv/tests/info.c +++ b/dlls/winspool.drv/tests/info.c @@ -866,28 +866,45 @@ static void test_EnumForms(LPSTR pName) ok(res, "(%d) returned %d with %d (expected '!=0')\n", level, res, GetLastError()); - if (winetest_debug > 1) { - trace("dumping %d forms level %d\n", pcReturned, level); - pFI_1a = (PFORM_INFO_1A)buffer; - pFI_2a = (PFORM_INFO_2A)buffer; - for (i = 0; i < pcReturned; i++) - { - /* first part is same in FORM_INFO_1 and FORM_INFO_2 */ - formtype = (pFI_1a->Flags <= FORMTYPE_MAX) ? formtypes[pFI_1a->Flags] : formtypes[3]; + pFI_1a = (PFORM_INFO_1A)buffer; + pFI_2a = (PFORM_INFO_2A)buffer; + for (i = 0; i < pcReturned; i++) + { + /* first part is same in FORM_INFO_1 and FORM_INFO_2 */ + formtype = (pFI_1a->Flags <= FORMTYPE_MAX) ? formtypes[pFI_1a->Flags] : formtypes[3]; + if (winetest_debug > 1) trace("%u (%s): %.03fmm x %.03fmm, %s\n", i, pFI_1a->pName, (float)pFI_1a->Size.cx/1000, (float)pFI_1a->Size.cy/1000, formtype); - if (level == 1) pFI_1a ++; - else { - /* output additional FORM_INFO_2 fields */ + if (level == 1) pFI_1a++; + else + { + BYTE get_buffer[1000]; + FORM_INFO_2A *get_form = (FORM_INFO_2A *)get_buffer; + DWORD get_needed; + + /* output additional FORM_INFO_2 fields */ + if (winetest_debug > 1) trace("\tkeyword=%s strtype=%u muidll=%s resid=%u dispname=%s langid=%u\n", pFI_2a->pKeyword, pFI_2a->StringType, pFI_2a->pMuiDll, pFI_2a->dwResourceId, pFI_2a->pDisplayName, pFI_2a->wLangId); - /* offset pointer pFI_1a by 1*sizeof(FORM_INFO_2A) Bytes */ - pFI_2a ++; - pFI_1a = (PFORM_INFO_1A)pFI_2a; + if (pName && i == 0) /* GetForm() appears only to work on a printer handle */ + { + res = GetFormA( hprinter, pFI_1a->pName, level, NULL, 0, &get_needed ); + ok( !res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d gle %d\n", res, GetLastError() ); + if (get_needed <= sizeof(get_buffer)) + { + res = GetFormA( hprinter, pFI_1a->pName, level, get_buffer, get_needed, &get_needed ); + ok( res, "got %d\n", res ); + ok( !strcmp( pFI_2a->pName, get_form->pName ), "name mismatch\n" ); + res = GetFormA( hprinter, pFI_1a->pName, level, get_buffer, get_needed - 1, &get_needed ); + ok( !res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d gle %d\n", res, GetLastError() ); + } } + /* offset pointer pFI_1a by 1*sizeof(FORM_INFO_2A) Bytes */ + pFI_2a++; + pFI_1a = (PFORM_INFO_1A)pFI_2a; } }