2010-08-24 13:54:10 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for SetSysColors
|
|
|
|
* PROGRAMMERS: Timo Kreuzer
|
|
|
|
*/
|
|
|
|
|
2013-09-22 17:52:42 +00:00
|
|
|
#include <apitest.h>
|
|
|
|
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2010-08-24 13:54:10 +00:00
|
|
|
|
2010-10-17 14:50:02 +00:00
|
|
|
#define TEST(x) ok(x, #x"\n")
|
2010-08-24 13:54:10 +00:00
|
|
|
|
2008-06-01 18:06:22 +00:00
|
|
|
#define NUM_SYSCOLORS 31
|
|
|
|
|
2010-08-24 13:54:10 +00:00
|
|
|
void Test_SetSysColors()
|
2008-06-01 18:06:22 +00:00
|
|
|
{
|
|
|
|
INT i;
|
2011-03-21 14:36:32 +00:00
|
|
|
INT nElements[NUM_SYSCOLORS+1];
|
2008-06-01 18:06:22 +00:00
|
|
|
COLORREF crOldColors[NUM_SYSCOLORS];
|
2011-03-21 14:36:32 +00:00
|
|
|
COLORREF crColors[NUM_SYSCOLORS+1];
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* First save the Old colors */
|
|
|
|
for (i = 0; i < NUM_SYSCOLORS; i++)
|
|
|
|
{
|
|
|
|
nElements[i] = i;
|
|
|
|
crOldColors[i] = GetSysColor(i);
|
|
|
|
}
|
2011-10-13 12:52:25 +00:00
|
|
|
|
2011-03-21 14:36:32 +00:00
|
|
|
for (i = 0; i < NUM_SYSCOLORS+1; i++)
|
|
|
|
crColors[i] = RGB(i, 255-i, i*3);
|
|
|
|
nElements[NUM_SYSCOLORS] = nElements[0];
|
2011-10-13 12:52:25 +00:00
|
|
|
|
2011-03-21 14:36:32 +00:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(SetSysColors(-1, nElements, crColors) == FALSE, "Expected FALSE, got TRUE\n");
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
|
2011-03-21 14:36:32 +00:00
|
|
|
ok(SetSysColors(0, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
|
|
|
|
ok(SetSysColors(0, NULL, crColors) == TRUE, "Expected TRUE, got FALSE\n");
|
|
|
|
ok(SetSysColors(0, nElements, NULL) == TRUE, "Expected TRUE, got FALSE\n");
|
|
|
|
ok(SetSysColors(1, NULL, crColors) == FALSE, "Expected FALSE, got TRUE\n");
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
|
2011-03-21 14:36:32 +00:00
|
|
|
ok(SetSysColors(1, nElements, NULL) == FALSE, "Expected FALSE, got TRUE\n");
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
|
2011-03-21 14:36:32 +00:00
|
|
|
ok(SetSysColors(1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
|
|
|
|
ok(SetSysColors(NUM_SYSCOLORS, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
|
|
|
|
for (i = 0; i < NUM_SYSCOLORS; i++)
|
|
|
|
ok(GetSysColor(nElements[i]) == crColors[i], "Expected %06lx, got %06lx\n", crColors[i], GetSysColor(nElements[i]));
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* try more than NUM_SYSCOLORS */
|
2011-03-21 14:36:32 +00:00
|
|
|
ok(SetSysColors(NUM_SYSCOLORS+1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
|
|
|
|
nElements[NUM_SYSCOLORS] = 10000;
|
|
|
|
ok(SetSysColors(NUM_SYSCOLORS+1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* restore old SysColors */
|
|
|
|
SetSysColors(NUM_SYSCOLORS, nElements, crOldColors);
|
2010-08-24 13:54:10 +00:00
|
|
|
}
|
2008-06-01 18:06:22 +00:00
|
|
|
|
2010-08-24 13:54:10 +00:00
|
|
|
START_TEST(SetSysColors)
|
|
|
|
{
|
|
|
|
Test_SetSysColors();
|
2008-06-01 18:06:22 +00:00
|
|
|
}
|
2010-08-24 13:54:10 +00:00
|
|
|
|