mirror of
https://github.com/reactos/reactos.git
synced 2025-02-21 16:04:57 +00:00
[GDIPLUS_WINETEST] Sync with Wine Staging 3.9. CORE-14656
This commit is contained in:
parent
6619d0261f
commit
ea2a3922c9
4 changed files with 230 additions and 8 deletions
|
@ -17,6 +17,7 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#include <limits.h>
|
||||
|
||||
#include "objbase.h"
|
||||
#include "gdiplus.h"
|
||||
|
@ -25,6 +26,22 @@
|
|||
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
|
||||
#define expectf(expected, got) ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
|
||||
|
||||
static BOOL compare_float(float f, float g, unsigned int ulps)
|
||||
{
|
||||
int x = *(int *)&f;
|
||||
int y = *(int *)&g;
|
||||
|
||||
if (x < 0)
|
||||
x = INT_MIN - x;
|
||||
if (y < 0)
|
||||
y = INT_MIN - y;
|
||||
|
||||
if (abs(x - y) > ulps)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void test_constructor_destructor(void)
|
||||
{
|
||||
GpCustomLineCap *custom;
|
||||
|
@ -219,21 +236,40 @@ static void test_scale(void)
|
|||
|
||||
static void test_create_adjustable_cap(void)
|
||||
{
|
||||
REAL inset, scale, height, width;
|
||||
GpAdjustableArrowCap *cap;
|
||||
REAL inset, scale;
|
||||
GpLineJoin join;
|
||||
GpStatus stat;
|
||||
GpLineCap base;
|
||||
BOOL ret;
|
||||
|
||||
stat = GdipCreateAdjustableArrowCap(10.0, 10.0, TRUE, NULL);
|
||||
todo_wine
|
||||
ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
|
||||
|
||||
stat = GdipCreateAdjustableArrowCap(17.0, 15.0, TRUE, &cap);
|
||||
todo_wine
|
||||
ok(stat == Ok, "Failed to create adjustable cap, %d\n", stat);
|
||||
if (stat != Ok)
|
||||
return;
|
||||
|
||||
stat = GdipGetAdjustableArrowCapFillState(cap, NULL);
|
||||
ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
|
||||
|
||||
ret = FALSE;
|
||||
stat = GdipGetAdjustableArrowCapFillState(cap, &ret);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
ok(ret, "Unexpected fill state %d\n", ret);
|
||||
|
||||
stat = GdipGetAdjustableArrowCapHeight(cap, NULL);
|
||||
ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
|
||||
|
||||
stat = GdipGetAdjustableArrowCapHeight(cap, &height);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
ok(height == 17.0, "Unexpected cap height %f\n", height);
|
||||
|
||||
stat = GdipGetAdjustableArrowCapWidth(cap, NULL);
|
||||
ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
|
||||
|
||||
stat = GdipGetAdjustableArrowCapWidth(cap, &width);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
ok(width == 15.0, "Unexpected cap width %f\n", width);
|
||||
|
||||
stat = GdipGetAdjustableArrowCapMiddleInset(cap, NULL);
|
||||
ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
|
||||
|
@ -247,14 +283,41 @@ todo_wine
|
|||
ok(base == LineCapTriangle, "Unexpected base cap %d\n", base);
|
||||
|
||||
stat = GdipSetCustomLineCapBaseCap((GpCustomLineCap*)cap, LineCapSquare);
|
||||
todo_wine
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
|
||||
stat = GdipGetCustomLineCapBaseCap((GpCustomLineCap*)cap, &base);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
todo_wine
|
||||
ok(base == LineCapSquare, "Unexpected base cap %d\n", base);
|
||||
|
||||
/* Base inset */
|
||||
stat = GdipGetAdjustableArrowCapWidth(cap, &width);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
|
||||
stat = GdipGetAdjustableArrowCapHeight(cap, &height);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
|
||||
inset = 0.0;
|
||||
stat = GdipGetCustomLineCapBaseInset((GpCustomLineCap*)cap, &inset);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
ok(compare_float(inset, height / width, 1), "Unexpected inset %f\n", inset);
|
||||
|
||||
stat = GdipSetAdjustableArrowCapMiddleInset(cap, 1.0);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
|
||||
inset = 0.0;
|
||||
stat = GdipGetCustomLineCapBaseInset((GpCustomLineCap*)cap, &inset);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
ok(compare_float(inset, height / width, 1), "Unexpected inset %f\n", inset);
|
||||
|
||||
stat = GdipSetAdjustableArrowCapHeight(cap, 2.0 * height);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
|
||||
inset = 0.0;
|
||||
stat = GdipGetCustomLineCapBaseInset((GpCustomLineCap*)cap, &inset);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
ok(compare_float(inset, 2.0 * height / width, 1), "Unexpected inset %f\n", inset);
|
||||
|
||||
stat = GdipGetCustomLineCapWidthScale((GpCustomLineCap*)cap, &scale);
|
||||
ok(stat == Ok, "Unexpected return code, %d\n", stat);
|
||||
|
@ -299,10 +362,7 @@ static void test_captype(void)
|
|||
|
||||
/* arrow cap */
|
||||
stat = GdipCreateAdjustableArrowCap(17.0, 15.0, TRUE, &arrowcap);
|
||||
todo_wine
|
||||
ok(stat == Ok, "Failed to create adjustable cap, %d\n", stat);
|
||||
if (stat != Ok)
|
||||
return;
|
||||
|
||||
stat = GdipGetCustomLineCapType((GpCustomLineCap*)arrowcap, &type);
|
||||
ok(stat == Ok, "Failed to get cap type, %d\n", stat);
|
||||
|
|
|
@ -2060,6 +2060,97 @@ static void test_get_set_clip(void)
|
|||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
|
||||
static void test_clip_xform(void)
|
||||
{
|
||||
GpStatus status;
|
||||
GpGraphics *graphics = NULL;
|
||||
HDC hdc = GetDC( hwnd );
|
||||
GpRegion *clip;
|
||||
COLORREF color;
|
||||
UINT region_data_size;
|
||||
struct {
|
||||
DWORD size;
|
||||
DWORD checksum;
|
||||
DWORD magic;
|
||||
DWORD num_children;
|
||||
DWORD element_type;
|
||||
REAL x;
|
||||
REAL y;
|
||||
REAL width;
|
||||
REAL height;
|
||||
} region_data;
|
||||
|
||||
status = GdipCreateFromHDC(hdc, &graphics);
|
||||
expect(Ok, status);
|
||||
status = GdipCreateRegion(&clip);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGraphicsClear(graphics, 0xff000000);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipSetClipRect(graphics, 10, 10, -10, -10, CombineModeReplace);
|
||||
expect(Ok, status);
|
||||
status = GdipGetClip(graphics, clip);
|
||||
expect(Ok, status);
|
||||
status = GdipGetRegionData(clip, (BYTE*)®ion_data, sizeof(region_data), ®ion_data_size);
|
||||
expect(Ok, status);
|
||||
expect(36, region_data_size);
|
||||
expect(28, region_data.size);
|
||||
expect(0, region_data.num_children);
|
||||
expect(0x10000000 /* RegionDataRect */, region_data.element_type);
|
||||
expectf(0.0, region_data.x);
|
||||
expectf(0.0, region_data.y);
|
||||
expectf(10.0, region_data.width);
|
||||
expectf(10.0, region_data.height);
|
||||
|
||||
/* No effect with negative width/height */
|
||||
status = GdipGraphicsClear(graphics, 0xffff0000);
|
||||
expect(Ok, status);
|
||||
color = GetPixel(hdc, 5, 5);
|
||||
expect(0, color);
|
||||
|
||||
status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderAppend);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGraphicsClear(graphics, 0xffff0000);
|
||||
expect(Ok, status);
|
||||
color = GetPixel(hdc, 5, 5);
|
||||
expect(0, color);
|
||||
|
||||
status = GdipResetClip(graphics);
|
||||
expect(Ok, status);
|
||||
status = GdipResetWorldTransform(graphics);
|
||||
expect(Ok, status);
|
||||
status = GdipGraphicsClear(graphics, 0xff000000);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderAppend);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipSetClipRect(graphics, 5, 5, -5, -5, CombineModeReplace);
|
||||
expect(Ok, status);
|
||||
status = GdipGetClip(graphics, clip);
|
||||
expect(Ok, status);
|
||||
status = GdipGetRegionData(clip, (BYTE*)®ion_data, sizeof(region_data), ®ion_data_size);
|
||||
expect(Ok, status);
|
||||
expect(36, region_data_size);
|
||||
expect(28, region_data.size);
|
||||
expect(0, region_data.num_children);
|
||||
expect(0x10000000 /* RegionDataRect */, region_data.element_type);
|
||||
expectf(0.0, region_data.x);
|
||||
expectf(0.0, region_data.y);
|
||||
expectf(5.0, region_data.width);
|
||||
expectf(5.0, region_data.height);
|
||||
|
||||
status = GdipGraphicsClear(graphics, 0xffff0000);
|
||||
expect(Ok, status);
|
||||
color = GetPixel(hdc, 5, 5);
|
||||
expect(0xff, color);
|
||||
|
||||
GdipDeleteGraphics(graphics);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
|
||||
static void test_isempty(void)
|
||||
{
|
||||
GpStatus status;
|
||||
|
@ -6713,6 +6804,7 @@ START_TEST(graphics)
|
|||
test_BeginContainer2();
|
||||
test_transformpoints();
|
||||
test_get_set_clip();
|
||||
test_clip_xform();
|
||||
test_isempty();
|
||||
test_clear();
|
||||
test_textcontrast();
|
||||
|
|
|
@ -431,6 +431,38 @@ static void test_transform(void)
|
|||
expectf(6.0, values[4]);
|
||||
expectf(3.0, values[5]);
|
||||
|
||||
/* Translate */
|
||||
status = GdipTranslatePenTransform(NULL, 1.0, -2.0, MatrixOrderAppend);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipTranslatePenTransform(pen, 1.0, -2.0, MatrixOrderAppend);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetPenTransform(pen, matrix);
|
||||
expect(Ok, status);
|
||||
status = GdipGetMatrixElements(matrix, values);
|
||||
expect(Ok, status);
|
||||
expectf(3.0, values[0]);
|
||||
expectf(-2.0, values[1]);
|
||||
expectf(5.0, values[2]);
|
||||
expectf(2.0, values[3]);
|
||||
expectf(7.0, values[4]);
|
||||
expectf(1.0, values[5]);
|
||||
|
||||
status = GdipTranslatePenTransform(pen, -3.0, 5.0, MatrixOrderPrepend);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetPenTransform(pen, matrix);
|
||||
expect(Ok, status);
|
||||
status = GdipGetMatrixElements(matrix, values);
|
||||
expect(Ok, status);
|
||||
expectf(3.0, values[0]);
|
||||
expectf(-2.0, values[1]);
|
||||
expectf(5.0, values[2]);
|
||||
expectf(2.0, values[3]);
|
||||
expectf(23.0, values[4]);
|
||||
expectf(17.0, values[5]);
|
||||
|
||||
status = GdipResetPenTransform(pen);
|
||||
expect(Ok, status);
|
||||
|
||||
|
|
|
@ -1441,6 +1441,22 @@ static void test_translate(void)
|
|||
ReleaseDC(0, hdc);
|
||||
}
|
||||
|
||||
static DWORD get_region_type(GpRegion *region)
|
||||
{
|
||||
DWORD *data;
|
||||
DWORD size;
|
||||
DWORD result;
|
||||
DWORD status;
|
||||
status = GdipGetRegionDataSize(region, &size);
|
||||
expect(Ok, status);
|
||||
data = GdipAlloc(size);
|
||||
status = GdipGetRegionData(region, (BYTE*)data, size, NULL);
|
||||
ok(status == Ok || status == InsufficientBuffer, "unexpected status 0x%x\n", status);
|
||||
result = data[4];
|
||||
GdipFree(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void test_transform(void)
|
||||
{
|
||||
GpRegion *region, *region2;
|
||||
|
@ -1451,6 +1467,7 @@ static void test_transform(void)
|
|||
GpStatus status;
|
||||
HDC hdc = GetDC(0);
|
||||
BOOL res;
|
||||
DWORD type;
|
||||
|
||||
status = GdipCreateFromHDC(hdc, &graphics);
|
||||
expect(Ok, status);
|
||||
|
@ -1483,6 +1500,8 @@ static void test_transform(void)
|
|||
status = GdipIsEqualRegion(region, region2, graphics, &res);
|
||||
expect(Ok, status);
|
||||
ok(res, "Expected to be equal.\n");
|
||||
type = get_region_type(region);
|
||||
expect(0x10000003 /* RegionDataInfiniteRect */, type);
|
||||
|
||||
/* empty */
|
||||
status = GdipSetEmpty(region);
|
||||
|
@ -1497,6 +1516,8 @@ static void test_transform(void)
|
|||
status = GdipIsEqualRegion(region, region2, graphics, &res);
|
||||
expect(Ok, status);
|
||||
ok(res, "Expected to be equal.\n");
|
||||
type = get_region_type(region);
|
||||
expect(0x10000002 /* RegionDataEmptyRect */, type);
|
||||
|
||||
/* rect */
|
||||
rectf.X = 10.0;
|
||||
|
@ -1516,6 +1537,8 @@ static void test_transform(void)
|
|||
status = GdipIsEqualRegion(region, region2, graphics, &res);
|
||||
expect(Ok, status);
|
||||
ok(res, "Expected to be equal.\n");
|
||||
type = get_region_type(region);
|
||||
expect(0x10000000 /* RegionDataRect */, type);
|
||||
|
||||
/* path */
|
||||
status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
|
||||
|
@ -1534,6 +1557,21 @@ static void test_transform(void)
|
|||
status = GdipIsEqualRegion(region, region2, graphics, &res);
|
||||
expect(Ok, status);
|
||||
ok(res, "Expected to be equal.\n");
|
||||
type = get_region_type(region);
|
||||
expect(0x10000001 /* RegionDataPath */, type);
|
||||
|
||||
/* rotated rect -> path */
|
||||
rectf.X = 10.0;
|
||||
rectf.Y = 0.0;
|
||||
rectf.Width = rectf.Height = 100.0;
|
||||
status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
|
||||
expect(Ok, status);
|
||||
status = GdipRotateMatrix(matrix, 45.0, MatrixOrderAppend);
|
||||
expect(Ok, status);
|
||||
status = GdipTransformRegion(region, matrix);
|
||||
expect(Ok, status);
|
||||
type = get_region_type(region);
|
||||
expect(0x10000001 /* RegionDataPath */, type);
|
||||
|
||||
status = GdipDeleteRegion(region);
|
||||
expect(Ok, status);
|
||||
|
|
Loading…
Reference in a new issue