mirror of
https://github.com/reactos/wine.git
synced 2025-02-14 01:31:43 +00:00
gdi32/tests: Demonstrate issues in wine with SaveDC and RestoreDC in metafiles and enhmetafiles.
This commit is contained in:
parent
b4a962bbb2
commit
cac6b96de4
@ -330,6 +330,7 @@ static int CALLBACK savedc_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
|
||||
SIZE size;
|
||||
static int save_state;
|
||||
static int restore_no;
|
||||
static int select_no;
|
||||
|
||||
trace("hdc %p, emr->iType %d, emr->nSize %d, param %p\n",
|
||||
hdc, emr->iType, emr->nSize, (void *)param);
|
||||
@ -375,6 +376,7 @@ static int CALLBACK savedc_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
|
||||
|
||||
save_state = 0;
|
||||
restore_no = 0;
|
||||
select_no = 0;
|
||||
check_dc_state(hdc, restore_no, 0, 0, 1, 1, 0, 0, 1, 1);
|
||||
break;
|
||||
}
|
||||
@ -438,8 +440,16 @@ static int CALLBACK savedc_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
|
||||
save_state += restoredc->iRelative;
|
||||
break;
|
||||
}
|
||||
case EMR_SELECTOBJECT:
|
||||
{
|
||||
const EMRSELECTOBJECT *selectobj = (const EMRSELECTOBJECT*)emr;
|
||||
trace("EMR_SELECTOBJECT: %x\n",selectobj->ihObject);
|
||||
select_no ++;
|
||||
break;
|
||||
}
|
||||
case EMR_EOF:
|
||||
ok(save_state == 0, "EOF save_state %d\n", save_state);
|
||||
ok(select_no == 2, "Too many/few selects %i\n",select_no);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -472,6 +482,9 @@ static void test_SaveDC(void)
|
||||
HENHMETAFILE hMetafile;
|
||||
HWND hwnd;
|
||||
int ret;
|
||||
POINT pt;
|
||||
SIZE size;
|
||||
HFONT hFont,hFontOld,hFontCheck;
|
||||
static const RECT rc = { 0, 0, 150, 150 };
|
||||
|
||||
/* Win9x doesn't play EMFs on invisible windows */
|
||||
@ -498,6 +511,167 @@ static void test_SaveDC(void)
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 0,"Extecting ViewportOrg x of 0, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 120,"Extecting ViewportExt cx of 120, got %i\n",size.cx);
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -1, -1, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 10, 10, NULL);
|
||||
SetWindowExtEx(hdcMetafile, 150, 150, NULL );
|
||||
SetViewportExtEx(hdcMetafile, 200, 200, NULL );
|
||||
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 10,"Extecting ViewportOrg x of 10, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 200,"Extecting ViewportExt cx of 200, got %i\n",size.cx);
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -2, -2, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 20, 20, NULL);
|
||||
SetWindowExtEx(hdcMetafile, 120, 120, NULL );
|
||||
SetViewportExtEx(hdcMetafile, 300, 300, NULL );
|
||||
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 20,"Extecting ViewportOrg x of 20, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 300,"Extecting ViewportExt cx of 300, got %i\n",size.cx);
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -3, -3, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 30, 30, NULL);
|
||||
SetWindowExtEx(hdcMetafile, 200, 200, NULL );
|
||||
SetViewportExtEx(hdcMetafile, 400, 400, NULL );
|
||||
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 30,"Extecting ViewportOrg x of 30, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 400,"Extecting ViewportExt cx of 400, got %i\n",size.cx);
|
||||
ret = RestoreDC(hdcMetafile, -1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
todo_wine ok(pt.x == 20,"Extecting ViewportOrg x of 20, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
todo_wine ok(size.cx == 300,"Extecting ViewportExt cx of 300, got %i\n",size.cx);
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
todo_wine ok(pt.x == 20,"Extecting ViewportOrg x of 20, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
todo_wine ok(size.cx == 300,"Extecting ViewportExt cx of 300, got %i\n",size.cx);
|
||||
ret = RestoreDC(hdcMetafile, 1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
todo_wine ok(pt.x == 0,"Extecting ViewportOrg x of 0, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
todo_wine ok(size.cx == 120,"Extecting ViewportExt cx of 120, got %i\n",size.cx);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -4, -4, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 40, 40, NULL);
|
||||
SetWindowExtEx(hdcMetafile, 500, 500, NULL );
|
||||
SetViewportExtEx(hdcMetafile, 50, 50, NULL );
|
||||
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 40,"Extecting ViewportOrg x of 40, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 50,"Extecting ViewportExt cx of 50, got %i\n",size.cx);
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 40,"Extecting ViewportOrg x of 40, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 50,"Extecting ViewportExt cx of 50, got %i\n",size.cx);
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
|
||||
memset(&orig_lf, 0, sizeof(orig_lf));
|
||||
orig_lf.lfCharSet = ANSI_CHARSET;
|
||||
orig_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
orig_lf.lfWeight = FW_DONTCARE;
|
||||
orig_lf.lfHeight = 7;
|
||||
orig_lf.lfQuality = DEFAULT_QUALITY;
|
||||
lstrcpyA(orig_lf.lfFaceName, "Arial");
|
||||
hFont = CreateFontIndirectA(&orig_lf);
|
||||
ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
|
||||
|
||||
hFontOld = SelectObject(hdcMetafile, hFont);
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = RestoreDC(hdcMetafile, 1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
ok(pt.x == 40,"Extecting ViewportOrg x of 40, got %i\n",pt.x);
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
ok(size.cx == 50,"Extecting ViewportExt cx of 50, got %i\n",size.cx);
|
||||
|
||||
hFontCheck = SelectObject(hdcMetafile, hFontOld);
|
||||
todo_wine ok(hFontOld == hFontCheck && hFontCheck != hFont, "Font not reverted with DC Restore\n");
|
||||
|
||||
hMetafile = CloseEnhMetaFile(hdcMetafile);
|
||||
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
|
||||
|
||||
ret = EnumEnhMetaFile(hdcDisplay, hMetafile, savedc_emf_enum_proc, 0, &rc);
|
||||
ok( ret == 1, "EnumEnhMetaFile rets %d\n", ret);
|
||||
|
||||
ret = DeleteObject(hFont);
|
||||
ok( ret, "DeleteObject error %d\n", GetLastError());
|
||||
ret = DeleteEnhMetaFile(hMetafile);
|
||||
ok( ret, "DeleteEnhMetaFile error %d\n", GetLastError());
|
||||
ret = ReleaseDC(hwnd, hdcDisplay);
|
||||
ok( ret, "ReleaseDC error %d\n", GetLastError());
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
static void test_mf_SaveDC(void)
|
||||
{
|
||||
HDC hdcMetafile;
|
||||
HMETAFILE hMetafile;
|
||||
int ret;
|
||||
POINT pt;
|
||||
SIZE size;
|
||||
HFONT hFont,hFontOld,hFontCheck;
|
||||
|
||||
hdcMetafile = CreateMetaFileA(NULL);
|
||||
ok(hdcMetafile != 0, "CreateMetaFileA error %d\n", GetLastError());
|
||||
|
||||
ret = SetMapMode(hdcMetafile, MM_ANISOTROPIC);
|
||||
ok (ret, "SetMapMode should not fail\n");
|
||||
|
||||
/* Need to write something to the emf, otherwise Windows won't play it back */
|
||||
LineTo(hdcMetafile, 150, 150);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, 0, 0, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 0, 0, NULL);
|
||||
SetWindowExtEx(hdcMetafile, 110, 110, NULL );
|
||||
SetViewportExtEx(hdcMetafile, 120, 120, NULL );
|
||||
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = GetViewportOrgEx(hdcMetafile, &pt);
|
||||
todo_wine ok (!ret, "GetViewportOrgEx should fail\n");
|
||||
ret = GetViewportExtEx(hdcMetafile, &size);
|
||||
todo_wine ok (!ret, "GetViewportExtEx should fail\n");
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
@ -510,7 +684,7 @@ static void test_SaveDC(void)
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
todo_wine ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -2, -2, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 20, 20, NULL);
|
||||
@ -521,7 +695,7 @@ static void test_SaveDC(void)
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
todo_wine ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -3, -3, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 30, 30, NULL);
|
||||
@ -535,10 +709,10 @@ static void test_SaveDC(void)
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
todo_wine ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
ret = RestoreDC(hdcMetafile, 1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
todo_wine ok(ret, "ret = %d\n", ret);
|
||||
|
||||
SetWindowOrgEx(hdcMetafile, -4, -4, NULL);
|
||||
SetViewportOrgEx(hdcMetafile, 40, 40, NULL);
|
||||
@ -549,24 +723,40 @@ static void test_SaveDC(void)
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
todo_wine ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
ret = SaveDC(hdcMetafile);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
todo_wine ok(ret == 1, "ret = %d\n", ret);
|
||||
|
||||
hMetafile = CloseEnhMetaFile(hdcMetafile);
|
||||
memset(&orig_lf, 0, sizeof(orig_lf));
|
||||
orig_lf.lfCharSet = ANSI_CHARSET;
|
||||
orig_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
orig_lf.lfWeight = FW_DONTCARE;
|
||||
orig_lf.lfHeight = 7;
|
||||
orig_lf.lfQuality = DEFAULT_QUALITY;
|
||||
lstrcpyA(orig_lf.lfFaceName, "Arial");
|
||||
hFont = CreateFontIndirectA(&orig_lf);
|
||||
ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
|
||||
|
||||
hFontOld = SelectObject(hdcMetafile, hFont);
|
||||
/* Force Win9x to update DC state */
|
||||
SetPixelV(hdcMetafile, 50, 50, 0);
|
||||
|
||||
ret = RestoreDC(hdcMetafile, 1);
|
||||
|
||||
hFontCheck = SelectObject(hdcMetafile, hFontOld);
|
||||
ok(hFontOld != hFontCheck && hFontCheck == hFont, "Font incorrectly reverted with DC Restore\n");
|
||||
|
||||
hMetafile = CloseMetaFile(hdcMetafile);
|
||||
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
|
||||
|
||||
ret = EnumEnhMetaFile(hdcDisplay, hMetafile, savedc_emf_enum_proc, 0, &rc);
|
||||
ok( ret == 1, "EnumEnhMetaFile rets %d\n", ret);
|
||||
|
||||
ret = DeleteEnhMetaFile(hMetafile);
|
||||
ok( ret, "DeleteEnhMetaFile error %d\n", GetLastError());
|
||||
ret = ReleaseDC(hwnd, hdcDisplay);
|
||||
ok( ret, "ReleaseDC error %d\n", GetLastError());
|
||||
DestroyWindow(hwnd);
|
||||
ret = DeleteMetaFile(hMetafile);
|
||||
ok( ret, "DeleteMetaFile error %d\n", GetLastError());
|
||||
ret = DeleteObject(hFont);
|
||||
ok( ret, "DeleteObject error %d\n", GetLastError());
|
||||
}
|
||||
|
||||
|
||||
/* Win-format metafile (mfdrv) tests */
|
||||
/* These tests compare the generated metafiles byte-by-byte */
|
||||
/* with the nominal results. */
|
||||
@ -2137,6 +2327,7 @@ START_TEST(metafile)
|
||||
test_SaveDC();
|
||||
|
||||
/* For win-format metafiles (mfdrv) */
|
||||
test_mf_SaveDC();
|
||||
test_mf_Blank();
|
||||
test_mf_Graphics();
|
||||
test_mf_PatternBrush();
|
||||
|
Loading…
x
Reference in New Issue
Block a user