reactos/rostests/apitests/gdi32/CombineRgn.c
Timo Kreuzer 65873aaab9 [GDI32_APITEST]
- Add tests for CombineRgn

svn path=/trunk/; revision=56408
2012-04-24 17:11:08 +00:00

199 lines
6.9 KiB
C

/*
* PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: Test for ...
* PROGRAMMERS: Timo Kreuzer
*/
#include <stdio.h>
#include <wine/test.h>
#include <windows.h>
#define ok_long(expression, result) \
{ \
int _value = (expression); \
ok(_value == (result), "Wrong value for %s, expected " #result " (0x%x), got 0x%x\n", \
#expression, (int)(result), _value); \
}
void Test_CombineRgn_COPY()
{
HRGN hrgn1, hrgn2, hrgn3;
hrgn1 = CreateRectRgn(0, 0, 0, 0);
hrgn2 = CreateRectRgn(0, 0, 10, 10);
hrgn3 = CreateRectRgn(5, 5, 20, 20);
SetLastError(0xbadbabe);
ok_long(CombineRgn(NULL, NULL, NULL, RGN_COPY), ERROR);
ok_long(CombineRgn(NULL, hrgn1, NULL, RGN_COPY), ERROR);
ok_long(CombineRgn(NULL, NULL, hrgn1, RGN_COPY), ERROR);
ok_long(CombineRgn(NULL, hrgn1, hrgn2, RGN_COPY), ERROR);
ok_long(GetLastError(), 0xbadbabe);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_COPY), SIMPLEREGION);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, hrgn1, NULL, RGN_COPY), SIMPLEREGION);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, hrgn3, GetStockObject(BLACK_PEN), RGN_COPY), SIMPLEREGION);
ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_COPY), ERROR);
ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_COPY), ERROR);
ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_COPY), ERROR);
ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
ok_long(GetLastError(), 0xbadbabe);
}
void Test_CombineRgn_AND()
{
HRGN hrgn1, hrgn2, hrgn3;
hrgn1 = CreateRectRgn(0, 0, 0, 0);
hrgn2 = CreateRectRgn(0, 0, 10, 10);
hrgn3 = CreateRectRgn(5, 5, 20, 20);
SetLastError(0xbadbabe);
ok_long(CombineRgn(NULL, NULL, NULL, RGN_AND), ERROR);
ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_AND), ERROR);
ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_AND), ERROR);
ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_AND), ERROR);
ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_AND), ERROR);
ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_AND), ERROR);
ok_long(GetLastError(), 0xbadbabe);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION);
SetRectRgn(hrgn2, 5, 5, 10, 10);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
SetRectRgn(hrgn2, 0, 0, 5, 5);
SetRectRgn(hrgn3, 5, 0, 10, 5);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), NULLREGION);
SetRectRgn(hrgn2, 0, 0, 0, 0);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
SetRectRgn(hrgn2, 0, 0, 20, 20);
SetRectRgn(hrgn3, 5, 5, 10, 10);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION);
SetRectRgn(hrgn2, 5, 5, 10, 10);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
SetRectRgn(hrgn2, 0, 0, 30, 10);
SetRectRgn(hrgn3, 10, 10, 20, 30);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
SetRectRgn(hrgn2, 10, 0, 30, 30);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), COMPLEXREGION);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), COMPLEXREGION);
SetRectRgn(hrgn2, 10, 10, 30, 30);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), SIMPLEREGION);
SetRectRgn(hrgn2, 0, 0, 10, 10);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), NULLREGION);
SetRectRgn(hrgn1, 0, 0, 30, 10);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), SIMPLEREGION);
}
void Test_CombineRgn_OR()
{
HRGN hrgn1, hrgn2, hrgn3;
hrgn1 = CreateRectRgn(0, 0, 0, 0);
hrgn2 = CreateRectRgn(0, 0, 5, 5);
hrgn3 = CreateRectRgn(5, 0, 10, 5);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), SIMPLEREGION);
SetRectRgn(hrgn2, 0, 0, 10, 5);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
SetRectRgn(hrgn2, 0, 0, 10, 10);
SetRectRgn(hrgn3, 10, 10, 20, 20);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
SetRectRgn(hrgn2, 10, 0, 20, 10);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), COMPLEXREGION);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_OR), COMPLEXREGION);
SetRectRgn(hrgn2, 0, 10, 10, 20);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), SIMPLEREGION);
SetRectRgn(hrgn2, 0, 0, 20, 20);
ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
}
void Test_CombineRgn_DIFF()
{
HRGN hrgn1, hrgn2, hrgn3;
hrgn1 = CreateRectRgn(0, 0, 0, 0);
hrgn2 = CreateRectRgn(0, 0, 10, 10);
hrgn3 = CreateRectRgn(5, 0, 10, 5);
SetLastError(0xbadbabe);
ok_long(CombineRgn(NULL, NULL, NULL, RGN_DIFF), ERROR);
ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_DIFF), ERROR);
ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_DIFF), ERROR);
ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_DIFF), ERROR);
ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_DIFF), ERROR);
ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_DIFF), ERROR);
ok_long(GetLastError(), 0xbadbabe);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_DIFF), NULLREGION);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn2, RGN_DIFF), NULLREGION);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn1, RGN_DIFF), SIMPLEREGION);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_DIFF), COMPLEXREGION);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_DIFF), COMPLEXREGION);
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION);
}
void Test_CombineRgn_XOR()
{
HRGN hrgn1, hrgn2, hrgn3, hrgn4;
hrgn1 = CreateRectRgn(0, 0, 0, 0);
hrgn2 = CreateRectRgn(0, 0, 5, 5);
hrgn3 = CreateRectRgn(5, 5, 10, 10);
hrgn4 = CreateRectRgn(0, 0, 0, 0);
SetLastError(0xbadbabe);
ok_long(CombineRgn(NULL, NULL, NULL, RGN_XOR), ERROR);
ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_XOR), ERROR);
ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_XOR), ERROR);
ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_XOR), ERROR);
ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_XOR), ERROR);
ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_XOR), ERROR);
ok_long(GetLastError(), 0xbadbabe);
ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_XOR), COMPLEXREGION);
ok_long(CombineRgn(hrgn4, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
ok(EqualRgn(hrgn1, hrgn4), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), SIMPLEREGION);
ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_XOR), NULLREGION);
}
START_TEST(CombineRgn)
{
Test_CombineRgn_COPY();
Test_CombineRgn_AND();
Test_CombineRgn_OR();
Test_CombineRgn_DIFF();
Test_CombineRgn_XOR();
}