Add a basic GDI LOGFONT test, fix a couple of failures
Dmitry Timoshkov
dmitry at baikal.ru
Wed Sep 1 03:43:46 CDT 2004
Hello,
Changelog:
Mike McCormack <mike at codeweavers.com>
Add a basic GDI LOGFONT test, fix a couple of failures.
diff -u cvs/hq/wine/dlls/gdi/font.c wine/dlls/gdi/font.c
--- cvs/hq/wine/dlls/gdi/font.c Wed Jul 21 13:07:28 2004
+++ wine/dlls/gdi/font.c Wed Sep 1 17:21:06 2004
@@ -213,6 +213,7 @@ static void FONT_LogFontAToW( const LOGF
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 LOGF
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 )
diff -u cvs/hq/wine/dlls/gdi/tests/.cvsignore wine/dlls/gdi/tests/.cvsignore
--- cvs/hq/wine/dlls/gdi/tests/.cvsignore Wed Mar 10 12:12:28 2004
+++ wine/dlls/gdi/tests/.cvsignore Wed Sep 1 14:37:09 2004
@@ -1,4 +1,5 @@
Makefile
+gdiobj.ok
generated.ok
metafile.ok
testlist.c
diff -u cvs/hq/wine/dlls/gdi/tests/Makefile.in wine/dlls/gdi/tests/Makefile.in
--- cvs/hq/wine/dlls/gdi/tests/Makefile.in Wed Mar 10 12:12:28 2004
+++ wine/dlls/gdi/tests/Makefile.in Wed Sep 1 14:37:34 2004
@@ -6,6 +6,7 @@ TESTDLL = gdi32.dll
IMPORTS = user32 gdi32
CTESTS = \
+ gdiobj.c \
generated.c \
metafile.c
diff -u cvs/hq/wine/dlls/gdi/tests/gdiobj.c wine/dlls/gdi/tests/gdiobj.c
--- cvs/hq/wine/dlls/gdi/tests/gdiobj.c Thu Jan 1 08:00:00 1970
+++ wine/dlls/gdi/tests/gdiobj.c Wed Sep 1 17:25:07 2004
@@ -0,0 +1,82 @@
+/*
+ * 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
+ */
+
+#define STRICT
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+
+#include "wine/test.h"
+
+#define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
+
+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, STRUCTOFFSET(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, STRUCTOFFSET(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();
+}
More information about the wine-patches
mailing list