Commit 9bb6932e authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

comdlg32: Add a test showing the font dialog ignores printer dpi.

parent 11a01507
......@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = comdlg32.dll
IMPORTS = comdlg32 user32 gdi32 kernel32
IMPORTS = comdlg32 winspool user32 gdi32 kernel32
C_SRCS = \
filedlg.c \
......
......@@ -25,6 +25,7 @@
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winspool.h"
#include "winuser.h"
#include "objbase.h"
......@@ -44,6 +45,30 @@ static int get_dpiy(void)
return result;
}
static HDC get_printer_ic(void)
{
PRINTER_INFO_2A *info;
DWORD info_size, num_printers=0;
BOOL ret;
HDC result=NULL;
EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &info_size, &num_printers);
if (info_size == 0)
return NULL;
info = HeapAlloc(GetProcessHeap(), 0, info_size);
ret = EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)info, info_size, &info_size, &num_printers);
if (ret)
result = CreateICA(info->pDriverName, info->pPrinterName, NULL, NULL);
HeapFree(GetProcessHeap(), 0, info);
return result;
}
static UINT_PTR CALLBACK CFHookProcOK(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
......@@ -63,6 +88,7 @@ static void test_ChooseFontA(void)
BOOL ret;
int dpiy = get_dpiy();
int expected_pointsize, expected_lfheight;
HDC printer_ic;
memset(&lfa, 0, sizeof(LOGFONTA));
lfa.lfHeight = -16;
......@@ -85,6 +111,37 @@ static void test_ChooseFontA(void)
ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName);
printer_ic = get_printer_ic();
if (!printer_ic)
skip("can't get a DC for a local printer\n");
else
{
memset(&lfa, 0, sizeof(LOGFONTA));
lfa.lfHeight = -16;
lfa.lfWeight = FW_NORMAL;
strcpy(lfa.lfFaceName, "Symbol");
memset(&cfa, 0, sizeof(CHOOSEFONTA));
cfa.lStructSize = sizeof(cfa);
cfa.lpLogFont = &lfa;
cfa.Flags = CF_ENABLEHOOK|CF_INITTOLOGFONTSTRUCT|CF_PRINTERFONTS;
cfa.hDC = printer_ic;
cfa.lpfnHook = CFHookProcOK;
ret = ChooseFontA(&cfa);
expected_pointsize = MulDiv(16, 72, dpiy) * 10;
expected_lfheight = -MulDiv(expected_pointsize, dpiy, 720);
ok(ret == TRUE, "ChooseFontA returned FALSE\n");
todo_wine ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize);
todo_wine ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName);
DeleteDC(printer_ic);
}
}
START_TEST(fontdlg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment