Patrick Gauthier : user32/tests: Check effect of magic font height value 0x7fff in dialog template.
Alexandre Julliard
julliard at winehq.org
Wed Mar 25 10:31:32 CDT 2009
Module: wine
Branch: master
Commit: 08c0ddec80f557bba109c908389e25bf9cddab39
URL: http://source.winehq.org/git/wine.git/?a=commit;h=08c0ddec80f557bba109c908389e25bf9cddab39
Author: Patrick Gauthier <webmaster at korosoft.net>
Date: Fri Mar 20 19:23:39 2009 -0400
user32/tests: Check effect of magic font height value 0x7fff in dialog template.
---
dlls/user32/tests/dialog.c | 95 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index 84929e3..7f8dfae 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -36,6 +36,7 @@
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
+#include "wingdi.h"
#include "winuser.h"
#define MAXHWNDS 1024
@@ -926,6 +927,99 @@ static void test_DisabledDialogTest(void)
ok(FALSE == g_terminated, "dialog with disabled ok button has been terminated\n");
}
+static INT_PTR CALLBACK messageBoxFontDlgWinProc (HWND hDlg, UINT uiMsg, WPARAM wParam,
+ LPARAM lParam)
+{
+ return (uiMsg == WM_INITDIALOG);
+}
+
+static void test_MessageBoxFontTest(void)
+{
+ /* This dialog template defines a dialog template which got 0x7fff as its
+ * font size and omits the other font members. On WinNT, passing such a
+ * dialog template to CreateDialogIndirectParamW will result in a dialog
+ * being created which uses the message box font. We test that here.
+ */
+
+ static unsigned char dlgTemplate[] =
+ {
+ /* Dialog header */
+ 0x01,0x00, /* Version */
+ 0xff,0xff, /* Extended template marker */
+ 0x00,0x00,0x00,0x00, /* Context Help ID */
+ 0x00,0x00,0x00,0x00, /* Extended style */
+ 0xc0,0x00,0xc8,0x80, /* Style (WS_SYSMENU|WS_CAPTION|WS_POPUP|DS_SETFONT|DS_MODALFRAME) */
+ 0x01,0x00, /* Control count */
+ 0x00,0x00, /* X */
+ 0x00,0x00, /* Y */
+ 0x80,0x00, /* Width */
+ 0x80,0x00, /* Height */
+ 0x00,0x00, /* Menu name */
+ 0x00,0x00, /* Class name */
+ 'T',0x00,'e',0x00, /* Caption (unicode) */
+ 's',0x00,'t',0x00,
+ 0x00,0x00,
+ 0xff,0x7f, /* Font height (0x7fff = message box font) */
+
+ /* Control #1 */
+ 0x00,0x00, /* Align to DWORD (header is 42 bytes) */
+ 0x00,0x00,0x00,0x00, /* Context Help ID */
+ 0x00,0x00,0x00,0x00, /* Extended style */
+ 0x00,0x00,0x00,0x50, /* Style (WS_CHILD|WS_VISIBLE) */
+ 0x00,0x00, /* X */
+ 0x00,0x00, /* Y */
+ 0x80,0x00, /* Width */
+ 0x80,0x00, /* Height */
+ 0x00,0x01,0x00,0x00, /* Control ID (256) */
+ 0xff,0xff,0x82,0x00, /* Class (Static) */
+ 'W',0x00,'I',0x00, /* Caption (unicode) */
+ 'N',0x00,'E',0x00,
+ ' ',0x00,'d',0x00,
+ 'i',0x00,'a',0x00,
+ 'l',0x00,'o',0x00,
+ 'g',0x00,' ',0x00,
+ 't',0x00,'e',0x00,
+ 's',0x00,'t',0x00,
+ '.',0x00,0x00,0x00,
+ 0x00,0x00, /* Size of extended data */
+
+ 0x00,0x00 /* Align to DWORD */
+ };
+
+ HWND hDlg;
+ HFONT hFont;
+ LOGFONTW lfStaticFont;
+ NONCLIENTMETRICSW ncMetrics;
+
+ /* Check if the dialog can be created from the template. On Win9x, this should fail
+ * because we are calling the W function which is not implemented, but that's what
+ * we want, because passing such a template to CreateDialogIndirectParamA would crash
+ * anyway.
+ */
+ hDlg = CreateDialogIndirectParamW(g_hinst, (LPCDLGTEMPLATE)dlgTemplate, NULL, messageBoxFontDlgWinProc, 0);
+ if (!hDlg)
+ {
+ todo_wine win_skip("dialog wasn't created\n");
+ return;
+ }
+
+ hFont = (HFONT) SendDlgItemMessageW(hDlg, 256, WM_GETFONT, 0, 0);
+ if (!hFont)
+ {
+ skip("dialog uses system font\n");
+ DestroyWindow(hDlg);
+ return;
+ }
+ GetObjectW(hFont, sizeof(LOGFONTW), &lfStaticFont);
+
+ ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncMetrics, 0);
+ ok( !memcmp(&lfStaticFont, &ncMetrics.lfMessageFont, FIELD_OFFSET(LOGFONTW, lfFaceName)) &&
+ !lstrcmpW(lfStaticFont.lfFaceName, ncMetrics.lfMessageFont.lfFaceName),
+ "dialog doesn't use message box font\n");
+ DestroyWindow(hDlg);
+}
+
START_TEST(dialog)
{
g_hinst = GetModuleHandleA (0);
@@ -939,4 +1033,5 @@ START_TEST(dialog)
test_GetDlgItemText();
test_DialogBoxParamA();
test_DisabledDialogTest();
+ test_MessageBoxFontTest();
}
More information about the wine-cvs
mailing list