Add a basic GDI LOGFONT test, fix a couple of failures.

This commit is contained in:
Mike McCormack 2004-09-01 17:29:28 +00:00 committed by Alexandre Julliard
parent 7db2149f65
commit 642180d3c9
4 changed files with 82 additions and 0 deletions

View File

@ -213,6 +213,7 @@ static void FONT_LogFontAToW( const LOGFONTA *fontA, LPLOGFONTW fontW )
memcpy(fontW, fontA, sizeof(LOGFONTA) - LF_FACESIZE);
MultiByteToWideChar(CP_ACP, 0, fontA->lfFaceName, -1, fontW->lfFaceName,
LF_FACESIZE);
fontW->lfFaceName[LF_FACESIZE-1] = 0;
}
static void FONT_LogFontWToA( const LOGFONTW *fontW, LPLOGFONTA fontA )
@ -220,6 +221,7 @@ static void FONT_LogFontWToA( const LOGFONTW *fontW, LPLOGFONTA fontA )
memcpy(fontA, fontW, sizeof(LOGFONTA) - LF_FACESIZE);
WideCharToMultiByte(CP_ACP, 0, fontW->lfFaceName, -1, fontA->lfFaceName,
LF_FACESIZE, NULL, NULL);
fontA->lfFaceName[LF_FACESIZE-1] = 0;
}
static void FONT_EnumLogFontExWTo16( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEX16 font16 )

View File

@ -1,4 +1,5 @@
Makefile
gdiobj.ok
generated.ok
metafile.ok
testlist.c

View File

@ -6,6 +6,7 @@ TESTDLL = gdi32.dll
IMPORTS = user32 gdi32
CTESTS = \
gdiobj.c \
generated.c \
metafile.c

78
dlls/gdi/tests/gdiobj.c Normal file
View File

@ -0,0 +1,78 @@
/*
* Unit test suite for GDI objects
*
* Copyright 2002 Mike McCormack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
static void test_logfont(void)
{
LOGFONTA lf, lfout;
HFONT hfont;
memset(&lf, 0, sizeof lf);
lf.lfCharSet = ANSI_CHARSET;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfWeight = FW_DONTCARE;
lf.lfHeight = 16;
lf.lfWidth = 16;
lf.lfQuality = DEFAULT_QUALITY;
lstrcpyA(lf.lfFaceName, "Arial");
hfont = CreateFontIndirectA(&lf);
ok(hfont != 0, "CreateFontIndirect failed\n");
ok(GetObjectA(hfont, sizeof(lfout), &lfout) == sizeof(lfout),
"GetObject returned wrong size\n");
ok(!memcmp(&lfout, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "fonts don't match\n");
ok(!lstrcmpA(lfout.lfFaceName, lf.lfFaceName),
"font names don't match: %s != %s\n", lfout.lfFaceName, lf.lfFaceName);
DeleteObject(hfont);
memset(&lf, 'A', sizeof(lf));
hfont = CreateFontIndirectA(&lf);
ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
ok(GetObjectA(hfont, sizeof(lfout), NULL) == sizeof(lfout),
"GetObjectA with NULL failed\n");
ok(GetObjectA(hfont, sizeof(lfout), &lfout) == sizeof(lfout),
"GetObjectA failed\n");
ok(!memcmp(&lfout, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "fonts don't match\n");
lf.lfFaceName[LF_FACESIZE - 1] = 0;
ok(!lstrcmpA(lfout.lfFaceName, lf.lfFaceName),
"font names don't match: %s != %s\n", lfout.lfFaceName, lf.lfFaceName);
DeleteObject(hfont);
}
START_TEST(gdiobj)
{
test_logfont();
}