From: Benjamin Otte Date: Tue, 24 Aug 2010 10:17:18 +0000 (+0200) Subject: region: Add a new test region-translate X-Git-Tag: 1.0_branch~514 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d8fb1bc01654ba0d331e6aea8127920e8cdf0b8;p=profile%2Fivi%2Fpixman.git region: Add a new test region-translate This test exercises a bug in pixman_region32_translate(). The function clips the region to int16 coordinates SHRT_MIN/SHRT_MAX. --- diff --git a/.gitignore b/.gitignore index 96d222b..aaeb75f 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ test/fetch-test test/gradient-test test/oob-test test/region-test +test/region-translate test/scaling-test test/screen-test test/trap-crasher diff --git a/test/Makefile.am b/test/Makefile.am index 5273bec..3d98e17 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -7,6 +7,7 @@ INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman TESTPROGRAMS = \ a1-trap-test \ region-test \ + region-translate-test \ fetch-test \ oob-test \ window-test \ @@ -27,6 +28,7 @@ trap_crasher_LDADD = $(TEST_LDADD) oob_test_LDADD = $(TEST_LDADD) window_test_LDADD = $(TEST_LDADD) scaling_crash_test_LDADD = $(TEST_LDADD) +region_translate_test_LDADD = $(TEST_LDADD) region_test_LDADD = $(TEST_LDADD) region_test_SOURCES = region-test.c utils.c utils.h diff --git a/test/region-translate-test.c b/test/region-translate-test.c new file mode 100644 index 0000000..0e96a5e --- /dev/null +++ b/test/region-translate-test.c @@ -0,0 +1,30 @@ +#include +#include + +/* Pixman had a bug where 32bit regions where clipped to 16bit sizes when + * pixman_region32_translate() was called. This test exercises that bug. + */ + +#define LARGE 32000 + +int +main (int argc, char **argv) +{ + pixman_box32_t rect = { -LARGE, -LARGE, LARGE, LARGE }; + pixman_region32_t r1, r2; + + pixman_region32_init_rects (&r1, &rect, 1); + pixman_region32_init_rect (&r2, rect.x1, rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1); + + assert (pixman_region32_equal (&r1, &r2)); + + pixman_region32_translate (&r1, -LARGE, LARGE); + pixman_region32_translate (&r1, LARGE, -LARGE); + + assert (pixman_region32_equal (&r1, &r2)); + + pixman_region32_fini (&r1); + pixman_region32_fini (&r2); + + return 0; +}