Skip to content

Commit

Permalink
Add TextureBrush tests and fix a compat bug (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughbe authored and akoeplinger committed Sep 19, 2017
1 parent 59ad2ec commit 17e3a55
Show file tree
Hide file tree
Showing 5 changed files with 828 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/texturebrush.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,11 @@ GdipMultiplyTextureTransform (GpTexture *texture, GpMatrix *matrix, GpMatrixOrde
BOOL invertible = FALSE;
cairo_matrix_t mat;

if ((texture == NULL) || (matrix == NULL)) {
if (!texture)
return InvalidParameter;
}

if (!matrix)
return Ok;

/* the matrix MUST be invertible to be used */
status = GdipIsMatrixInvertible ((GpMatrix*) matrix, &invertible);
Expand Down
3 changes: 2 additions & 1 deletion tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ testclip
testfont
testgraphics
testgdi
testreversepath
testpen
testpng
testreversepath
testtexturebrush
14 changes: 11 additions & 3 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LDADDS = \
-lm

noinst_PROGRAMS = \
testbits testclip testfont testgraphics testreversepath testpen testpng
testbits testclip testfont testgraphics testpen testpng testreversepath testtexturebrush

if HAS_X11
noinst_PROGRAMS =
Expand Down Expand Up @@ -60,6 +60,12 @@ testreversepath_SOURCES = \
testreversepath_DEPENDENCIES = $(TEST_DEPS)
testreversepath_LDADD = $(LDADDS)

testtexturebrush_SOURCES = \
testtexturebrush.c

testtexturebrush_DEPENDENCIES = $(TEST_DEPS)
testtexturebrush_LDADD = $(LDADDS)

testpen_SOURCES = \
testpen.c

Expand All @@ -79,15 +85,17 @@ EXTRA_DIST = \
$(testfont_SOURCES) \
$(testgraphics_SOURCES) \
$(testpen_SOURCES) \
$(testpng_SOURCES) \
$(testpng_SOURCES) \
$(testtexturebrush_SOURCES) \
$(testreversepath_SOURCES)

TESTS = \
testbits \
testclip \
testfont \
testgraphics \
testreversepath \
testpen \
testpng \
testreversepath \
testtexturebrush \
$(NULL)
24 changes: 24 additions & 0 deletions tests/testhelpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>
#include <math.h>
#include <float.h>

static int floatsEqual(float v1, float v2)
{
return fabs (v1 - v2) < 0.0001;
}

static void verifyMatrix (GpMatrix *matrix, REAL e1, REAL e2, REAL e3, REAL e4, REAL e5, REAL e6)
{
float elements[6];
GdipGetMatrixElements (matrix, elements);

printf ("Actual: %f, %f, %f, %f, %f, %f\n", e1, e2, e3, e4, e5, e6);
printf ("Expected: %f, %f, %f, %f, %f, %f\n\n", elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]);

assert (floatsEqual(elements[0], e1));
assert (floatsEqual(elements[1], e2));
assert (floatsEqual(elements[2], e3));
assert (floatsEqual(elements[3], e4));
assert (floatsEqual(elements[4], e5));
assert (floatsEqual(elements[5], e6));
}
Loading

0 comments on commit 17e3a55

Please sign in to comment.