[GDI32_WINETEST] Sync everything except dib.c with Wine Staging 3.3. CORE-14434

This commit is contained in:
Amine Khaldi 2018-04-03 13:28:13 +01:00
parent a84a503c62
commit ff449c5f6f
16 changed files with 709 additions and 70 deletions

View file

@ -19,11 +19,23 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmsystem.h"
#include "wine/winternl.h"
#ifndef __REACTOS__ /* CORE-11331 */
#include "wine/ddk/d3dkmthk.h"
#endif
#include "wine/test.h"
#ifndef __REACTOS__ /* CORE-11331 */
static NTSTATUS (WINAPI *pD3DKMTCreateDCFromMemory)( D3DKMT_CREATEDCFROMMEMORY *desc );

View file

@ -18,7 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
typedef struct _STOCK_BRUSH {
COLORREF color;

View file

@ -19,7 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
static void test_GetRandomRgn(void)
{

View file

@ -19,9 +19,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#ifndef __REACTOS__
#define WINVER 0x0501 /* request latest DEVMODE */
#endif
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include <winspool.h>
#include <assert.h>
#include <stdio.h>
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winspool.h"
#include "winerror.h"
#ifndef LAYOUT_LTR
#define LAYOUT_LTR 0
@ -389,6 +401,12 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale
case LOGPIXELSY:
hdc_caps *= scale;
break;
case VREFRESH:
if (GetDeviceCaps( hdc, TECHNOLOGY ) == DT_RASDISPLAY)
ok( hdc_caps > 0, "expected a positive value on %s, got %d\n", descr, hdc_caps );
else
ok( hdc_caps == 0, "expected 0 on %s, got %d\n", descr, hdc_caps );
break;
}
ok( abs(hdc_caps - GetDeviceCaps( ref_dc, caps[i] )) <= precision,

View file

@ -19,9 +19,17 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include <assert.h>
#include <winnls.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/heap.h"
#include "wine/test.h"
static inline BOOL match_off_by_n(int a, int b, unsigned int n)
{
@ -102,22 +110,6 @@ static void init(void)
system_lang_id = PRIMARYLANGID(GetSystemDefaultLangID());
}
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
{
return HeapAlloc(GetProcessHeap(), 0, size);
}
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
{
if (!mem) return heap_alloc(size);
return HeapReAlloc(GetProcessHeap(), 0, mem, size);
}
static inline BOOL heap_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
static INT CALLBACK is_truetype_font_installed_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
{
if (type != TRUETYPE_FONTTYPE) return 1;
@ -1136,7 +1128,7 @@ static int CALLBACK create_font_proc(const LOGFONTA *lpelfe,
return 1;
}
static void ABCWidths_helper(const char* description, HDC hdc, WORD *glyphs, ABC *base_abci, ABC *base_abcw, ABCFLOAT *base_abcf, INT todo)
static void ABCWidths_helper(const char* description, HDC hdc, WORD *glyphs, const ABC *base_abci, const ABC *base_abcw, const ABCFLOAT *base_abcf)
{
ABC abc[1];
ABCFLOAT abcf[1];
@ -1145,26 +1137,20 @@ static void ABCWidths_helper(const char* description, HDC hdc, WORD *glyphs, ABC
ret = pGetCharABCWidthsI(hdc, 0, 1, glyphs, abc);
ok(ret, "%s: GetCharABCWidthsI should have succeeded\n", description);
ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
todo_wine_if (todo)
ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
todo_wine_if (todo)
ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
ret = pGetCharABCWidthsW(hdc, 'i', 'i', abc);
ok(ret, "%s: GetCharABCWidthsW should have succeeded\n", description);
ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
todo_wine_if (todo)
ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
todo_wine_if (todo)
ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
ret = pGetCharABCWidthsFloatW(hdc, 'i', 'i', abcf);
ok(ret, "%s: GetCharABCWidthsFloatW should have succeeded\n", description);
ok (abcf->abcfB > 0.0, "%s: abcfB should be positive\n", description);
todo_wine_if (todo)
ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's sign should be unchanged\n", description);
todo_wine_if (todo)
ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's sign should be unchanged\n", description);
ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
}
static void test_GetCharABCWidths(void)
@ -1354,6 +1340,56 @@ static void test_GetCharABCWidths(void)
"got %d, expected %d (C)\n", abc[0].abcC, abcw[0].abcC);
DeleteObject(SelectObject(hdc, hfont));
/* test abcA == gmptGlyphOrigin.x && abcB == gmBlackBoxX
in various widths. */
for (i = 1; i <= 2; i++)
{
UINT j;
UINT code;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = 20;
switch(i)
{
case 1:
strcpy(lf.lfFaceName, "Tahoma");
code = 'a';
break;
case 2:
strcpy(lf.lfFaceName, "Times New Roman");
lf.lfItalic = TRUE;
code = 'f';
break;
}
if (!is_truetype_font_installed(lf.lfFaceName))
{
skip("%s is not installed\n", lf.lfFaceName);
continue;
}
for (j = 1; j <= 80; j++)
{
GLYPHMETRICS gm;
lf.lfWidth = j;
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
nb = GetGlyphOutlineA(hdc, code, GGO_METRICS, &gm, 0, NULL, &mat);
ok(nb, "GetGlyphOutlineA should have succeeded at width %d\n", i);
ret = GetCharABCWidthsA(hdc, code, code, abc);
ok(ret, "GetCharABCWidthsA should have succeeded at width %d\n", i);
ok(abc[0].abcA == gm.gmptGlyphOrigin.x,
"abcA(%d) and gmptGlyphOrigin.x(%d) values are different at width %d\n",
abc[0].abcA, gm.gmptGlyphOrigin.x, i);
ok(abc[0].abcB == gm.gmBlackBoxX,
"abcB(%d) and gmBlackBoxX(%d) values are different at width %d\n",
abc[0].abcB, gm.gmBlackBoxX, i);
DeleteObject(SelectObject(hdc, hfont));
}
}
ReleaseDC(NULL, hdc);
trace("ABC sign test for a variety of transforms:\n");
@ -1377,17 +1413,17 @@ static void test_GetCharABCWidths(void)
ret = pGetCharABCWidthsFloatW(hdc, 'i', 'i', abcf);
ok(ret, "GetCharABCWidthsFloatW should have succeeded\n");
ABCWidths_helper("LTR", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("LTR", hdc, glyphs, abc, abcw, abcf);
SetWindowExtEx(hdc, -1, -1, NULL);
SetGraphicsMode(hdc, GM_COMPATIBLE);
ABCWidths_helper("LTR -1 compatible", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("LTR -1 compatible", hdc, glyphs, abc, abcw, abcf);
SetGraphicsMode(hdc, GM_ADVANCED);
ABCWidths_helper("LTR -1 advanced", hdc, glyphs, abc, abcw, abcf, 1);
ABCWidths_helper("LTR -1 advanced", hdc, glyphs, abc, abcw, abcf);
SetWindowExtEx(hdc, 1, 1, NULL);
SetGraphicsMode(hdc, GM_COMPATIBLE);
ABCWidths_helper("LTR 1 compatible", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("LTR 1 compatible", hdc, glyphs, abc, abcw, abcf);
SetGraphicsMode(hdc, GM_ADVANCED);
ABCWidths_helper("LTR 1 advanced", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("LTR 1 advanced", hdc, glyphs, abc, abcw, abcf);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
@ -1399,17 +1435,17 @@ static void test_GetCharABCWidths(void)
SetMapMode(hdc, MM_ANISOTROPIC);
SelectObject(hdc, hfont);
ABCWidths_helper("RTL", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("RTL", hdc, glyphs, abc, abcw, abcf);
SetWindowExtEx(hdc, -1, -1, NULL);
SetGraphicsMode(hdc, GM_COMPATIBLE);
ABCWidths_helper("RTL -1 compatible", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("RTL -1 compatible", hdc, glyphs, abc, abcw, abcf);
SetGraphicsMode(hdc, GM_ADVANCED);
ABCWidths_helper("RTL -1 advanced", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("RTL -1 advanced", hdc, glyphs, abc, abcw, abcf);
SetWindowExtEx(hdc, 1, 1, NULL);
SetGraphicsMode(hdc, GM_COMPATIBLE);
ABCWidths_helper("RTL 1 compatible", hdc, glyphs, abc, abcw, abcf, 0);
ABCWidths_helper("RTL 1 compatible", hdc, glyphs, abc, abcw, abcf);
SetGraphicsMode(hdc, GM_ADVANCED);
ABCWidths_helper("RTL 1 advanced", hdc, glyphs, abc, abcw, abcf, 1);
ABCWidths_helper("RTL 1 advanced", hdc, glyphs, abc, abcw, abcf);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
@ -1783,17 +1819,17 @@ static void test_GetKerningPairs(void)
kd[i].otmMacDescent, otm.otmMacDescent);
ok(near_match(kd[i].otmMacAscent, otm.otmMacAscent), "expected %d, got %d\n",
kd[i].otmMacAscent, otm.otmMacAscent);
todo_wine {
todo_wine
ok(kd[i].otmsCapEmHeight == otm.otmsCapEmHeight, "expected %u, got %u\n",
kd[i].otmsCapEmHeight, otm.otmsCapEmHeight);
todo_wine
ok(kd[i].otmsXHeight == otm.otmsXHeight, "expected %u, got %u\n",
kd[i].otmsXHeight, otm.otmsXHeight);
/* FIXME: this one sometimes succeeds due to expected 0, enable it when removing todo */
if (0) ok(kd[i].otmMacLineGap == otm.otmMacLineGap, "expected %u, got %u\n",
ok(kd[i].otmMacLineGap == otm.otmMacLineGap, "expected %u, got %u\n",
kd[i].otmMacLineGap, otm.otmMacLineGap);
todo_wine
ok(kd[i].otmusMinimumPPEM == otm.otmusMinimumPPEM, "expected %u, got %u\n",
kd[i].otmusMinimumPPEM, otm.otmusMinimumPPEM);
}
total_kern_pairs = GetKerningPairsW(hdc, 0, NULL);
trace("total_kern_pairs %u\n", total_kern_pairs);
@ -5924,7 +5960,7 @@ static void check_vertical_metrics(const char *face)
GLYPHMETRICS rgm, vgm;
const UINT code = 0x5EAD, height = 1000;
WORD idx;
ABC abc;
ABC abc, vabc;
OUTLINETEXTMETRICA otm;
USHORT numOfLongVerMetrics;
@ -5952,6 +5988,15 @@ static void check_vertical_metrics(const char *face)
hfont_prev = SelectObject(hdc, hfont);
ret = GetGlyphOutlineW(hdc, code, GGO_METRICS, &vgm, 0, NULL, &mat);
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
ret = GetCharABCWidthsW(hdc, code, code, &vabc);
ok(ret, "GetCharABCWidthsW failed\n");
ok(vabc.abcA == vgm.gmptGlyphOrigin.x, "expected %d, got %d\n",
vabc.abcA, vgm.gmptGlyphOrigin.x);
ok(vabc.abcB == vgm.gmBlackBoxX, "expected %d, got %d\n",
vabc.abcB, vgm.gmBlackBoxX);
ok(vabc.abcA + vabc.abcB + vabc.abcC == vgm.gmCellIncX,
"expected %d, got %d\n",
vabc.abcA + vabc.abcB + vabc.abcC, vgm.gmCellIncX);
memset(&otm, 0, sizeof(otm));
otm.otmSize = sizeof(otm);
@ -6411,7 +6456,7 @@ static void test_GetCharWidth32(void)
SetGraphicsMode(hdc, GM_ADVANCED);
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
ok(ret, "GetCharWidth32W should have succeeded\n");
todo_wine ok (bufferW > 0," Width should be greater than zero\n");
ok (bufferW > 0," Width should be greater than zero\n");
SetWindowExtEx(hdc, 1,1,NULL);
SetGraphicsMode(hdc, GM_COMPATIBLE);
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
@ -6451,7 +6496,7 @@ static void test_GetCharWidth32(void)
SetGraphicsMode(hdc, GM_ADVANCED);
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
ok(ret, "GetCharWidth32W should have succeeded\n");
todo_wine ok (bufferW > 0," Width should be greater than zero\n");
ok (bufferW > 0," Width should be greater than zero\n");
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
@ -6469,7 +6514,7 @@ static void test_fake_bold_font(void)
ABC abc;
INT w;
GLYPHMETRICS gm;
} data[2];
} data[4];
int i;
DWORD r;
@ -6526,6 +6571,60 @@ static void test_fake_bold_font(void)
"expected %d, got %d\n", data[0].gm.gmCellIncX + 1, data[1].gm.gmCellIncX);
ok(data[0].gm.gmCellIncY == data[1].gm.gmCellIncY,
"expected %d, got %d\n", data[0].gm.gmCellIncY, data[1].gm.gmCellIncY);
/* Test bitmap font */
memset(&data, 0xaa, sizeof(data));
memset(&lf, 0, sizeof(lf));
strcpy(lf.lfFaceName, "Courier");
lf.lfCharSet = ANSI_CHARSET;
hdc = GetDC(NULL);
for (i = 0; i < 4; i++)
{
HFONT hfont, hfont_old;
lf.lfWeight = (i % 2) ? FW_BOLD : FW_NORMAL;
lf.lfHeight = (i > 1) ? data[0].tm.tmHeight * x2_mat.eM11.value : 0;
hfont = CreateFontIndirectA(&lf);
hfont_old = SelectObject(hdc, hfont);
ret = GetTextMetricsA(hdc, &data[i].tm);
ok(ret, "got %d\n", ret);
ret = pGetCharWidth32A(hdc, 0x76, 0x76, &data[i].w);
ok(ret, "got %d\n", ret);
SelectObject(hdc, hfont_old);
DeleteObject(hfont);
}
ReleaseDC(NULL, hdc);
/* compare results (bitmap) */
for (i = 0; i < 4; i+=2)
{
int diff = (i > 1) ? x2_mat.eM11.value : 1;
if (data[i].tm.tmPitchAndFamily & TMPF_TRUETYPE)
{
skip("TrueType font is selected (expected a bitmap one)\n");
continue;
}
ok(data[i].tm.tmHeight == data[i+1].tm.tmHeight,
"expected %d, got %d\n", data[i].tm.tmHeight, data[i+1].tm.tmHeight);
ok(data[i].tm.tmAscent == data[i+1].tm.tmAscent,
"expected %d, got %d\n", data[i].tm.tmAscent, data[i+1].tm.tmAscent);
ok(data[i].tm.tmDescent == data[i+1].tm.tmDescent,
"expected %d, got %d\n", data[i].tm.tmDescent, data[i+1].tm.tmDescent);
ok(data[i+1].tm.tmAveCharWidth - data[i].tm.tmAveCharWidth == diff,
"expected %d, got %d\n", diff, data[i+1].tm.tmAveCharWidth - data[i].tm.tmAveCharWidth);
ok(data[i+1].tm.tmMaxCharWidth - data[i].tm.tmMaxCharWidth == diff,
"expected %d, got %d\n", diff, data[i+1].tm.tmMaxCharWidth - data[i].tm.tmMaxCharWidth);
ok(data[i].tm.tmOverhang == 0,
"expected 0, got %d\n", data[i].tm.tmOverhang);
ok(data[i+1].tm.tmOverhang == 1,
"expected 1, got %d\n", data[i+1].tm.tmOverhang);
ok(data[i].w + 1 == data[i+1].w,
"expected %d, got %d\n", data[i].w + 1, data[i+1].w);
}
}
static void test_bitmap_font_glyph_index(void)
@ -6703,6 +6802,59 @@ static void test_GetCharWidthI(void)
ReleaseDC(0, hdc);
}
static INT CALLBACK long_enum_proc(const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lparam)
{
BOOL *found_font = (BOOL *)lparam;
*found_font = TRUE;
return 1;
}
static void test_long_names(void)
{
char ttf_name[MAX_PATH];
LOGFONTA font = {0};
HFONT handle_font;
BOOL found_font;
int ret;
HDC dc;
if (!write_ttf_file("wine_longname.ttf", ttf_name))
{
skip("Failed to create ttf file for testing\n");
return;
}
dc = GetDC(NULL);
ret = AddFontResourceExA(ttf_name, FR_PRIVATE, 0);
ok(ret, "AddFontResourceEx() failed\n");
strcpy(font.lfFaceName, "wine_3_this_is_a_very_long_name");
found_font = FALSE;
EnumFontFamiliesExA(dc, &font, long_enum_proc, (LPARAM)&found_font, 0);
ok(found_font == TRUE, "EnumFontFamiliesExA didn't find font.\n");
strcpy(font.lfFaceName, "wine_2_this_is_a_very_long_name");
found_font = FALSE;
EnumFontFamiliesExA(dc, &font, long_enum_proc, (LPARAM)&found_font, 0);
ok(found_font == TRUE, "EnumFontFamiliesExA didn't find font.\n");
strcpy(font.lfFaceName, "wine_1_this_is_a_very_long_name");
found_font = FALSE;
EnumFontFamiliesExA(dc, &font, long_enum_proc, (LPARAM)&found_font, 0);
ok(found_font == FALSE, "EnumFontFamiliesExA must not find font.\n");
handle_font = CreateFontIndirectA(&font);
ok(handle_font != NULL, "CreateFontIndirectA failed\n");
DeleteObject(handle_font);
ret = RemoveFontResourceExA(ttf_name, FR_PRIVATE, 0);
ok(ret, "RemoveFontResourceEx() failed\n");
DeleteFileA(ttf_name);
ReleaseDC(NULL, dc);
}
START_TEST(font)
{
init();
@ -6767,6 +6919,7 @@ START_TEST(font)
test_fake_bold_font();
test_bitmap_font_glyph_index();
test_GetCharWidthI();
test_long_names();
/* These tests should be last test until RemoveFontResource
* is properly implemented.

View file

@ -19,7 +19,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
static void test_gdi_objects(void)
{

View file

@ -5,7 +5,17 @@
* Unit tests for data structure packing
*/
#include "precomp.h"
#ifndef __REACTOS__
#define WINVER 0x0501
#define _WIN32_IE 0x0501
#define _WIN32_WINNT 0x0501
#endif
#define WINE_NOWINSOCK
#include "windows.h"
#include "wine/test.h"
/***********************************************************************
* Compatibility macros

View file

@ -18,7 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/test.h"
static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};

View file

@ -19,7 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdio.h>
#include <math.h>
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
static DWORD (WINAPI *pGetLayout)(HDC hdc);

View file

@ -18,7 +18,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static LOGFONTA orig_lf;
static BOOL emr_processed = FALSE;
@ -1114,6 +1126,44 @@ static const unsigned char EMF_TEXTOUT_ON_PATH_BITS[] =
0x14, 0x00, 0x00, 0x00
};
static const unsigned char EMF_TEXTOUT_OUTLINE_ON_PATH_BITS[] =
{
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xdd, 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff,
0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
0x0c, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x90, 0x06, 0x00, 0x00, 0x1a, 0x04, 0x00, 0x00,
0x51, 0x02, 0x00, 0x00, 0x72, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1a, 0x0b, 0x09, 0x00,
0xf0, 0xa6, 0x05, 0x00, 0x25, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x80,
0x3b, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x54, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x01, 0x00, 0x00, 0x00, 0xc3, 0x30, 0x0d, 0x42,
0xcf, 0xf3, 0x0c, 0x42, 0x0b, 0x00, 0x00, 0x00,
0x16, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x65, 0x00,
0x73, 0x00, 0x74, 0x00, 0x03, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x80,
0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00
};
static const unsigned char MF_LINETO_BITS[] = {
0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
@ -2376,6 +2426,8 @@ static void test_emf_ExtTextOut_on_path(void)
HDC hdcDisplay, hdcMetafile;
HENHMETAFILE hMetafile;
BOOL ret;
LOGFONTA lf;
HFONT hFont;
static const INT dx[4] = { 3, 5, 8, 12 };
/* Win9x doesn't play EMFs on invisible windows */
@ -2386,6 +2438,19 @@ static void test_emf_ExtTextOut_on_path(void)
hdcDisplay = GetDC(hwnd);
ok(hdcDisplay != 0, "GetDC error %d\n", GetLastError());
/* with default font */
ret = BeginPath(hdcDisplay);
ok(ret, "BeginPath error %d\n", GetLastError());
ret = ExtTextOutA(hdcDisplay, 11, 22, 0, NULL, "Test", 4, dx);
ok(ret, "ExtTextOut error %d\n", GetLastError());
ret = EndPath(hdcDisplay);
ok(ret, "EndPath error %d\n", GetLastError());
ret = GetPath(hdcDisplay, NULL, NULL, 0);
ok(!ret, "expected 0, got %d\n", ret);
hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
@ -2393,11 +2458,14 @@ static void test_emf_ExtTextOut_on_path(void)
ok(ret, "BeginPath error %d\n", GetLastError());
ret = ExtTextOutA(hdcMetafile, 11, 22, 0, NULL, "Test", 4, dx);
todo_wine ok(ret, "ExtTextOut error %d\n", GetLastError());
ok(ret, "ExtTextOut error %d\n", GetLastError());
ret = EndPath(hdcMetafile);
ok(ret, "EndPath error %d\n", GetLastError());
ret = GetPath(hdcMetafile, NULL, NULL, 0);
ok(!ret, "expected 0, got %d\n", ret);
hMetafile = CloseEnhMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
@ -2413,6 +2481,66 @@ static void test_emf_ExtTextOut_on_path(void)
ret = DeleteEnhMetaFile(hMetafile);
ok(ret, "DeleteEnhMetaFile error %d\n", GetLastError());
/* with outline font */
memset(&lf, 0, sizeof(lf));
lf.lfCharSet = ANSI_CHARSET;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfWeight = FW_DONTCARE;
lf.lfHeight = 7;
lf.lfQuality = DEFAULT_QUALITY;
lstrcpyA(lf.lfFaceName, "Tahoma");
hFont = CreateFontIndirectA(&lf);
ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
hFont = SelectObject(hdcDisplay, hFont);
ret = BeginPath(hdcDisplay);
ok(ret, "BeginPath error %d\n", GetLastError());
ret = ExtTextOutA(hdcDisplay, 11, 22, 0, NULL, "Test", 4, dx);
ok(ret, "ExtTextOut error %d\n", GetLastError());
ret = EndPath(hdcDisplay);
ok(ret, "EndPath error %d\n", GetLastError());
ret = GetPath(hdcDisplay, NULL, NULL, 0);
ok(ret != 0, "expected != 0\n");
SelectObject(hdcDisplay, hFont);
hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
hFont = SelectObject(hdcMetafile, hFont);
ret = BeginPath(hdcMetafile);
ok(ret, "BeginPath error %d\n", GetLastError());
ret = ExtTextOutA(hdcMetafile, 11, 22, 0, NULL, "Test", 4, dx);
ok(ret, "ExtTextOut error %d\n", GetLastError());
ret = EndPath(hdcMetafile);
ok(ret, "EndPath error %d\n", GetLastError());
ret = GetPath(hdcMetafile, NULL, NULL, 0);
ok(!ret, "expected 0, got %d\n", ret);
hFont = SelectObject(hdcMetafile, hFont);
DeleteObject(hFont);
hMetafile = CloseEnhMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
if (compare_emf_bits(hMetafile, EMF_TEXTOUT_OUTLINE_ON_PATH_BITS, sizeof(EMF_TEXTOUT_OUTLINE_ON_PATH_BITS),
"emf_TextOut_on_path", FALSE) != 0)
{
dump_emf_bits(hMetafile, "emf_TextOut_outline_on_path");
dump_emf_records(hMetafile, "emf_TextOut_outline_on_path");
}
ret = DeleteEnhMetaFile(hMetafile);
ok(ret, "DeleteEnhMetaFile error %d\n", GetLastError());
ret = ReleaseDC(hwnd, hdcDisplay);
ok(ret, "ReleaseDC error %d\n", GetLastError());
DestroyWindow(hwnd);
@ -2839,7 +2967,8 @@ static void test_mf_GetPath(void)
hdc = CreateMetaFileA(NULL);
ok(hdc != 0, "CreateMetaFileA error %d\n", GetLastError());
BeginPath(hdc);
ret = BeginPath(hdc);
ok(!ret, "BeginPath on metafile DC should fail\n");
ret = MoveToEx(hdc, 50, 50, NULL);
ok( ret, "MoveToEx error %d.\n", GetLastError());
ret = LineTo(hdc, 50, 150);
@ -3727,7 +3856,8 @@ static void test_emf_paths(void)
hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
BeginPath(hdcMetafile);
ret = BeginPath(hdcMetafile);
ok(ret, "BeginPath error %d\n", GetLastError());
ret = MoveToEx(hdcMetafile, 50, 50, NULL);
ok( ret, "MoveToEx error %d.\n", GetLastError());
ret = LineTo(hdcMetafile, 50, 150);
@ -3904,6 +4034,258 @@ static void test_emf_GradientFill(void)
DeleteEnhMetaFile( hemf );
}
static void set_rotation_xform(XFORM *out, float rad, int dx, int dy)
{
out->eM11 = cosf(rad);
out->eM12 = -1.f * sinf(rad);
out->eM21 = sinf(rad);
out->eM22 = cosf(rad);
out->eDx = dx;
out->eDy = dy;
}
struct emf_WorldTransform_test_data
{
const char *name;
BOOL do_modify;
BOOL do_playback;
XFORM expected;
XFORM scale;
XFORM stored; /* this is the "hidden" world transform used in PlayEnhMetaFileRecord */
};
static BOOL xform_eq(const XFORM *a, const XFORM *b)
{
return fabs(a->eM11 - b->eM11) < 0.001f &&
fabs(a->eM12 - b->eM12) < 0.001f &&
fabs(a->eM21 - b->eM21) < 0.001f &&
fabs(a->eM22 - b->eM22) < 0.001f &&
fabs(a->eDx - b->eDx) < 0.001f &&
fabs(a->eDy - b->eDy) < 0.001f;
}
static INT CALLBACK enum_emf_WorldTransform(HDC hdc, HANDLETABLE *ht,
const ENHMETARECORD *emr, INT nobj, LPARAM param)
{
XFORM xform = {0};
struct emf_WorldTransform_test_data *test_data = (struct emf_WorldTransform_test_data *)param;
BOOL ret;
switch(emr->iType)
{
case EMR_SETWORLDTRANSFORM:
{
const EMRSETWORLDTRANSFORM *lpXfrm = (const EMRSETWORLDTRANSFORM *)emr;
/* get scale factors with an identity world transform */
GetWorldTransform(hdc, &test_data->scale);
/* play back record */
ret = PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
ok(ret == TRUE, "%s: PlayEnhMetaFileRecord failed\n", test_data->name);
test_data->stored = lpXfrm->xform;
CombineTransform(&test_data->expected, &test_data->stored, &test_data->scale);
/* verify it is updated immediately */
ret = GetWorldTransform(hdc, &xform);
ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
ok(xform_eq(&xform, &test_data->expected),
"%s: After SWT playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
test_data->name,
xform.eM11, xform.eM12,
xform.eM21, xform.eM22,
xform.eDx, xform.eDy,
test_data->expected.eM11, test_data->expected.eM12,
test_data->expected.eM21, test_data->expected.eM22,
test_data->expected.eDx, test_data->expected.eDy);
break;
}
case EMR_MODIFYWORLDTRANSFORM:
{
const EMRMODIFYWORLDTRANSFORM *lpXfrm = (const EMRMODIFYWORLDTRANSFORM *)emr;
/* transform persists across calls */
ret = GetWorldTransform(hdc, &xform);
ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
ok(xform_eq(&xform, &test_data->expected),
"%s: On MWT entry, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
test_data->name,
xform.eM11, xform.eM12,
xform.eM21, xform.eM22,
xform.eDx, xform.eDy,
test_data->expected.eM11, test_data->expected.eM12,
test_data->expected.eM21, test_data->expected.eM22,
test_data->expected.eDx, test_data->expected.eDy);
if(test_data->do_playback)
{
/* play back record */
ret = PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
ok(ret == TRUE, "%s: PlayEnhMetaFileRecord failed\n", test_data->name);
if(lpXfrm->iMode == MWT_LEFTMULTIPLY)
{
/* left multiply does not discard direct modifications */
CombineTransform(&test_data->expected, &lpXfrm->xform, &test_data->expected);
/* and updates the stored matrix separately */
CombineTransform(&test_data->stored, &lpXfrm->xform, &test_data->stored);
}
else if(lpXfrm->iMode == MWT_RIGHTMULTIPLY)
{
/* but right multiply does discard */
CombineTransform(&test_data->stored, &test_data->stored, &lpXfrm->xform);
CombineTransform(&test_data->expected, &test_data->stored, &test_data->scale);
}
/* verify it is updated immediately */
ret = GetWorldTransform(hdc, &xform);
ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
ok(xform_eq(&xform, &test_data->expected),
"%s: After MWT playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
test_data->name,
xform.eM11, xform.eM12,
xform.eM21, xform.eM22,
xform.eDx, xform.eDy,
test_data->expected.eM11, test_data->expected.eM12,
test_data->expected.eM21, test_data->expected.eM22,
test_data->expected.eDx, test_data->expected.eDy);
}
if(test_data->do_modify)
{
/* modify directly */
set_rotation_xform(&xform, M_PI / 4.f, 1, -1);
ret = ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
ok(ret == TRUE, "%s: ModifyWorldTransform failed\n", test_data->name);
/* the modified transform persists across callback calls */
CombineTransform(&test_data->expected, &xform, &test_data->expected);
ret = GetWorldTransform(hdc, &xform);
ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
ok(xform_eq(&xform, &test_data->expected),
"%s: After ModifyWT, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
test_data->name,
xform.eM11, xform.eM12,
xform.eM21, xform.eM22,
xform.eDx, xform.eDy,
test_data->expected.eM11, test_data->expected.eM12,
test_data->expected.eM21, test_data->expected.eM22,
test_data->expected.eDx, test_data->expected.eDy);
}
break;
}
case EMR_LINETO:
ret = GetWorldTransform(hdc, &xform);
ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
ok(xform_eq(&xform, &test_data->expected),
"%s: Before LINETO playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
test_data->name,
xform.eM11, xform.eM12,
xform.eM21, xform.eM22,
xform.eDx, xform.eDy,
test_data->expected.eM11, test_data->expected.eM12,
test_data->expected.eM21, test_data->expected.eM22,
test_data->expected.eDx, test_data->expected.eDy);
ret = PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
ok(ret == TRUE, "%s: PlayEnhMetaFileRecord failed\n", test_data->name);
/* transform doesn't change during LINETO playback */
ret = GetWorldTransform(hdc, &xform);
ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
ok(xform_eq(&xform, &test_data->expected),
"%s: After LINETO playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
test_data->name,
xform.eM11, xform.eM12,
xform.eM21, xform.eM22,
xform.eDx, xform.eDy,
test_data->expected.eM11, test_data->expected.eM12,
test_data->expected.eM21, test_data->expected.eM22,
test_data->expected.eDx, test_data->expected.eDy);
break;
default:
PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
break;
}
return 1;
}
static void test_emf_WorldTransform(void)
{
HDC hdcMetafile, hdc;
HWND hwnd;
HENHMETAFILE hemf;
XFORM xform;
BOOL ret;
RECT rect = { 0, 0, 100, 100 };
int i;
struct emf_WorldTransform_test_data test_data[] = {
{ "normal", FALSE, TRUE },
{ "playback and modify", TRUE, TRUE },
{ "manual modify", TRUE, FALSE }
};
for(i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
{
hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
ret = SetGraphicsMode(hdcMetafile, GM_ADVANCED);
ok(ret == TRUE, "SetGraphicsMode failed\n");
set_rotation_xform(&xform, M_PI / 4.f, 2, 3);
ret = SetWorldTransform(hdcMetafile, &xform); /* EMR_SETWORLDTRANSFORM */
ok(ret == TRUE, "SetWorldTransform failed\n");
set_rotation_xform(&xform, M_PI / 2.f, -2, -3);
ret = ModifyWorldTransform(hdcMetafile, &xform, MWT_LEFTMULTIPLY); /* EMR_MODIFYWORLDTRANSFORM */
ok(ret == TRUE, "ModifyWorldTransform failed\n");
set_rotation_xform(&xform, M_PI / 3.f, -2, 3);
ret = ModifyWorldTransform(hdcMetafile, &xform, MWT_LEFTMULTIPLY); /* EMR_MODIFYWORLDTRANSFORM */
ok(ret == TRUE, "ModifyWorldTransform failed\n");
set_rotation_xform(&xform, M_PI, 2, -3);
ret = ModifyWorldTransform(hdcMetafile, &xform, MWT_RIGHTMULTIPLY); /* EMR_MODIFYWORLDTRANSFORM */
ok(ret == TRUE, "ModifyWorldTransform failed\n");
ret = LineTo(hdcMetafile, 1, 1);
ok(ret == TRUE, "LineTo failed\n");
hemf = CloseEnhMetaFile(hdcMetafile);
ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
0, 0, 200, 200, 0, 0, 0, NULL);
ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
hdc = GetDC(hwnd);
ok(hdc != 0, "GetDC failed\n");
ret = EnumEnhMetaFile(hdc, hemf, enum_emf_WorldTransform, &test_data[i], &rect);
ok(ret == TRUE, "EnumEnhMetaFile failed: %u\n", GetLastError());
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
DeleteEnhMetaFile(hemf);
}
}
START_TEST(metafile)
{
init_function_pointers();
@ -3920,6 +4302,7 @@ START_TEST(metafile)
test_emf_paths();
test_emf_PolyPolyline();
test_emf_GradientFill();
test_emf_WorldTransform();
/* For win-format metafiles (mfdrv) */
test_mf_SaveDC();

View file

@ -18,7 +18,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmsystem.h"
#include "wine/test.h"
static const PALETTEENTRY logpalettedata[8] = {
{ 0x10, 0x20, 0x30, PC_NOCOLLAPSE },

View file

@ -19,7 +19,17 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/test.h"
#include "winuser.h"
#include "winerror.h"
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)

View file

@ -18,7 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "precomp.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
#define expect2(expected, alt, got) ok(got == expected || got == alt, \

View file

@ -1,16 +1,19 @@
#ifndef _GDI32_WINETEST_PRECOMP_H_
#define _GDI32_WINETEST_PRECOMP_H_
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define NONAMELESSUNION
#include <assert.h>
#include <stdio.h>
#include <math.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define NONAMELESSUNION
#include <wine/test.h>
#include <wingdi.h>
#include <winuser.h>
#include <mmsystem.h>

View file

@ -28,3 +28,6 @@ wine_vdmx.ttf RCDATA wine_vdmx.ttf
/* @makedep: vertical.ttf */
vertical.ttf RCDATA vertical.ttf
/* @makedep: wine_longname.ttf */
wine_longname.ttf RCDATA wine_longname.ttf

Binary file not shown.