winspool/tests: Add tests for GetFormA().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-05-19 14:43:13 +01:00 committed by Alexandre Julliard
parent 0cddf6fe21
commit 837660e04b
1 changed files with 31 additions and 14 deletions

View File

@ -866,29 +866,46 @@ static void test_EnumForms(LPSTR pName)
ok(res, "(%d) returned %d with %d (expected '!=0')\n", ok(res, "(%d) returned %d with %d (expected '!=0')\n",
level, res, GetLastError()); level, res, GetLastError());
if (winetest_debug > 1) {
trace("dumping %d forms level %d\n", pcReturned, level);
pFI_1a = (PFORM_INFO_1A)buffer; pFI_1a = (PFORM_INFO_1A)buffer;
pFI_2a = (PFORM_INFO_2A)buffer; pFI_2a = (PFORM_INFO_2A)buffer;
for (i = 0; i < pcReturned; i++) for (i = 0; i < pcReturned; i++)
{ {
/* first part is same in FORM_INFO_1 and FORM_INFO_2 */ /* first part is same in FORM_INFO_1 and FORM_INFO_2 */
formtype = (pFI_1a->Flags <= FORMTYPE_MAX) ? formtypes[pFI_1a->Flags] : formtypes[3]; 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, 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); (float)pFI_1a->Size.cx/1000, (float)pFI_1a->Size.cy/1000, formtype);
if (level == 1) pFI_1a ++; if (level == 1) pFI_1a++;
else { else
{
BYTE get_buffer[1000];
FORM_INFO_2A *get_form = (FORM_INFO_2A *)get_buffer;
DWORD get_needed;
/* output additional FORM_INFO_2 fields */ /* output additional FORM_INFO_2 fields */
if (winetest_debug > 1)
trace("\tkeyword=%s strtype=%u muidll=%s resid=%u dispname=%s langid=%u\n", 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->pKeyword, pFI_2a->StringType, pFI_2a->pMuiDll,
pFI_2a->dwResourceId, pFI_2a->pDisplayName, pFI_2a->wLangId); pFI_2a->dwResourceId, pFI_2a->pDisplayName, pFI_2a->wLangId);
/* offset pointer pFI_1a by 1*sizeof(FORM_INFO_2A) Bytes */ if (pName && i == 0) /* GetForm() appears only to work on a printer handle */
pFI_2a ++; {
pFI_1a = (PFORM_INFO_1A)pFI_2a; 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;
}
} }
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);