Commit 9bb54156 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

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

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