oleaut32/tests: Fix the size test in the case of an underflow of Lo.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-04-12 09:17:39 +01:00 committed by Alexandre Julliard
parent fcb9ff957b
commit 9bb541563a
1 changed files with 36 additions and 38 deletions

View File

@ -58,9 +58,8 @@ static HRESULT (WINAPI *pOleCreateFontIndirect)(LPFONTDESC,REFIID,LPVOID*);
/* SetRatio to ratio_logical, ratio_himetric, */
/* check that resulting hfont has height hfont_height. */
/* Various checks along the way. */
static void test_ifont_size(LONG lo_size, LONG hi_size,
LONG ratio_logical, LONG ratio_himetric,
LONG hfont_height, const char * test_name)
static void test_ifont_size(LONGLONG size, LONG ratio_logical, LONG ratio_himetric,
LONG hfont_height, const char * test_name)
{
FONTDESC fd;
LPVOID pvObj = NULL;
@ -73,8 +72,7 @@ static void test_ifont_size(LONG lo_size, LONG hi_size,
fd.cbSizeofstruct = sizeof(FONTDESC);
fd.lpstrName = arial_font; /* using scalable instead of bitmap font reduces errors due to font realization */
S(fd.cySize).Lo = lo_size;
S(fd.cySize).Hi = hi_size;
fd.cySize.int64 = size;
fd.sWeight = 0;
fd.sCharset = 0;
fd.fItalic = FALSE;
@ -99,9 +97,9 @@ static void test_ifont_size(LONG lo_size, LONG hi_size,
test_name, hres);
/* Check returned size - allow for errors due to rounding & font realization. */
ok((abs(S(psize).Lo - lo_size) < 10000) && S(psize).Hi == hi_size,
ok((psize.int64 - size) < 10000 && (psize.int64 - size) > -10000,
"%s: IFont_get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=%d.\n",
test_name, S(psize).Lo, S(psize).Hi, lo_size, hi_size);
test_name, S(psize).Lo, S(psize).Hi, fd.cySize.Lo, fd.cySize.Hi);
/* Check hFont size. */
hres = IFont_get_hFont (ifnt, &hfont);
@ -130,59 +128,59 @@ static void test_ifont_sizes(void)
ReleaseDC(0, hdc);
if(dpi == 96) /* normal resolution display */
{
test_ifont_size(180000, 0, 0, 0, -24, "default"); /* normal font */
test_ifont_size(186000, 0, 0, 0, -25, "rounding"); /* test rounding */
test_ifont_size(180000, 0, 0, -24, "default"); /* normal font */
test_ifont_size(186000, 0, 0, -25, "rounding"); /* test rounding */
} else if(dpi == 72) /* low resolution display */
{
test_ifont_size(180000, 0, 0, 0, -18, "default"); /* normal font */
test_ifont_size(186000, 0, 0, 0, -19, "rounding"); /* test rounding */
test_ifont_size(180000, 0, 0, -18, "default"); /* normal font */
test_ifont_size(186000, 0, 0, -19, "rounding"); /* test rounding */
} else if(dpi == 120) /* high resolution display */
{
test_ifont_size(180000, 0, 0, 0, -30, "default"); /* normal font */
test_ifont_size(186000, 0, 0, 0, -31, "rounding"); /* test rounding */
test_ifont_size(180000, 0, 0, -30, "default"); /* normal font */
test_ifont_size(186000, 0, 0, -31, "rounding"); /* test rounding */
} else
skip("Skipping resolution dependent font size tests - display resolution is %d\n", dpi);
/* Next 4 tests specify a scaling ratio, so display resolution is not a factor. */
test_ifont_size(180000, 0, 72, 2540, -18, "ratio1"); /* change ratio */
test_ifont_size(180000, 0, 144, 2540, -36, "ratio2"); /* another ratio */
test_ifont_size(180000, 0, 72, 1270, -36, "ratio3"); /* yet another ratio */
test_ifont_size(186000, 0, 72, 2540, -19, "rounding+ratio"); /* test rounding with ratio */
test_ifont_size(180000, 72, 2540, -18, "ratio1"); /* change ratio */
test_ifont_size(180000, 144, 2540, -36, "ratio2"); /* another ratio */
test_ifont_size(180000, 72, 1270, -36, "ratio3"); /* yet another ratio */
test_ifont_size(186000, 72, 2540, -19, "rounding+ratio"); /* test rounding with ratio */
/* test various combinations of logical == himetric */
test_ifont_size(180000, 0, 10, 10, -635, "identical ratio 1");
test_ifont_size(240000, 0, 10, 10, -848, "identical ratio 2");
test_ifont_size(300000, 0, 10, 10, -1058, "identical ratio 3");
test_ifont_size(180000, 10, 10, -635, "identical ratio 1");
test_ifont_size(240000, 10, 10, -848, "identical ratio 2");
test_ifont_size(300000, 10, 10, -1058, "identical ratio 3");
/* test various combinations of logical and himetric both set to 1 */
test_ifont_size(180000, 0, 1, 1, -24, "1:1 ratio 1");
test_ifont_size(240000, 0, 1, 1, -32, "1:1 ratio 2");
test_ifont_size(300000, 0, 1, 1, -40, "1:1 ratio 3");
test_ifont_size(180000, 1, 1, -24, "1:1 ratio 1");
test_ifont_size(240000, 1, 1, -32, "1:1 ratio 2");
test_ifont_size(300000, 1, 1, -40, "1:1 ratio 3");
/* test various combinations of logical set to 1 */
test_ifont_size(180000, 0, 1, 0, -24, "1:0 ratio 1");
test_ifont_size(240000, 0, 1, 0, -32, "1:0 ratio 2");
test_ifont_size(300000, 0, 1, 0, -40, "1:0 ratio 3");
test_ifont_size(180000, 1, 0, -24, "1:0 ratio 1");
test_ifont_size(240000, 1, 0, -32, "1:0 ratio 2");
test_ifont_size(300000, 1, 0, -40, "1:0 ratio 3");
/* test various combinations of himetric set to 1 */
test_ifont_size(180000, 0, 0, 1, -24, "0:1 ratio 1");
test_ifont_size(240000, 0, 0, 1, -32, "0:1 ratio 2");
test_ifont_size(300000, 0, 0, 1, -40, "0:1 ratio 3");
test_ifont_size(180000, 0, 1, -24, "0:1 ratio 1");
test_ifont_size(240000, 0, 1, -32, "0:1 ratio 2");
test_ifont_size(300000, 0, 1, -40, "0:1 ratio 3");
/* test various combinations of 2:1 logical:himetric */
test_ifont_size(180000, 0, 2, 1, -1270, "2:1 ratio 1");
test_ifont_size(240000, 0, 2, 1, -1694, "2:1 ratio 2");
test_ifont_size(300000, 0, 2, 1, -2117, "2:1 ratio 3");
test_ifont_size(180000, 2, 1, -1270, "2:1 ratio 1");
test_ifont_size(240000, 2, 1, -1694, "2:1 ratio 2");
test_ifont_size(300000, 2, 1, -2117, "2:1 ratio 3");
/* test various combinations of 1:2 logical:himetric */
test_ifont_size(180000, 0, 1, 2, -318, "1:2 ratio 1");
test_ifont_size(240000, 0, 1, 2, -424, "1:2 ratio 2");
test_ifont_size(300000, 0, 1, 2, -529, "1:2 ratio 3");
test_ifont_size(180000, 1, 2, -318, "1:2 ratio 1");
test_ifont_size(240000, 1, 2, -424, "1:2 ratio 2");
test_ifont_size(300000, 1, 2, -529, "1:2 ratio 3");
/* test various combinations of logical and himetric both set to 2 */
test_ifont_size(180000, 0, 2, 2, -635, "2:2 ratio 1");
test_ifont_size(240000, 0, 2, 2, -848, "2:2 ratio 2");
test_ifont_size(300000, 0, 2, 2, -1058, "2:2 ratio 3");
test_ifont_size(180000, 2, 2, -635, "2:2 ratio 1");
test_ifont_size(240000, 2, 2, -848, "2:2 ratio 2");
test_ifont_size(300000, 2, 2, -1058, "2:2 ratio 3");
}
static void test_QueryInterface(void)