[COM_APITEST] Add a test for CLSID_ActiveDesktop
[reactos.git] / modules / rostests / apitests / gdi32 / SetSysColors.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetSysColors
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include "precomp.h"
9
10 #define NUM_SYSCOLORS 31
11
12 void Test_SetSysColors()
13 {
14 INT i;
15 INT nElements[NUM_SYSCOLORS+1];
16 COLORREF crOldColors[NUM_SYSCOLORS];
17 COLORREF crColors[NUM_SYSCOLORS+1];
18
19 /* First save the Old colors */
20 for (i = 0; i < NUM_SYSCOLORS; i++)
21 {
22 nElements[i] = i;
23 crOldColors[i] = GetSysColor(i);
24 }
25
26 for (i = 0; i < NUM_SYSCOLORS+1; i++)
27 crColors[i] = RGB(i, 255-i, i*3);
28 nElements[NUM_SYSCOLORS] = nElements[0];
29
30 SetLastError(0xdeadbeef);
31 ok(SetSysColors(-1, nElements, crColors) == FALSE, "Expected FALSE, got TRUE\n");
32 ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
33 ok(SetSysColors(0, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
34 ok(SetSysColors(0, NULL, crColors) == TRUE, "Expected TRUE, got FALSE\n");
35 ok(SetSysColors(0, nElements, NULL) == TRUE, "Expected TRUE, got FALSE\n");
36 ok(SetSysColors(1, NULL, crColors) == FALSE, "Expected FALSE, got TRUE\n");
37 ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
38 ok(SetSysColors(1, nElements, NULL) == FALSE, "Expected FALSE, got TRUE\n");
39 ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
40 ok(SetSysColors(1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
41 ok(SetSysColors(NUM_SYSCOLORS, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
42 for (i = 0; i < NUM_SYSCOLORS; i++)
43 ok(GetSysColor(nElements[i]) == crColors[i], "Expected %06lx, got %06lx\n", crColors[i], GetSysColor(nElements[i]));
44
45 /* try more than NUM_SYSCOLORS */
46 ok(SetSysColors(NUM_SYSCOLORS+1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
47 nElements[NUM_SYSCOLORS] = 10000;
48 ok(SetSysColors(NUM_SYSCOLORS+1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n");
49
50 /* restore old SysColors */
51 SetSysColors(NUM_SYSCOLORS, nElements, crOldColors);
52 }
53
54 START_TEST(SetSysColors)
55 {
56 Test_SetSysColors();
57 }
58