Improve GetClipRgn and SetSysColors apitests
authorRafal Harabien <rafalh@reactos.org>
Mon, 21 Mar 2011 14:36:32 +0000 (14:36 +0000)
committerRafal Harabien <rafalh@reactos.org>
Mon, 21 Mar 2011 14:36:32 +0000 (14:36 +0000)
svn path=/trunk/; revision=51107

rostests/apitests/gdi32/GetClipRgn.c
rostests/apitests/gdi32/SetSysColors.c

index 7ca8187..3522148 100644 (file)
@@ -14,6 +14,7 @@ void Test_GetClipRgn()
        HWND hWnd;
        HDC hDC;
        HRGN hrgn;//, hrgn2;
+       int ret;
 
        /* Create a window */
        hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
@@ -25,13 +26,15 @@ void Test_GetClipRgn()
 
        /* Test invalid DC */
        SetLastError(ERROR_SUCCESS);
-       ok(GetClipRgn((HDC)0x12345, hrgn) == -1, "\n");
-       ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
+       ret = GetClipRgn((HDC)0x12345, hrgn);
+       ok(ret == -1, "Expected -1, got %d\n", ret);
+       ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
        /* Test invalid hrgn */
        SetLastError(ERROR_SUCCESS);
-       ok(GetClipRgn(hDC, (HRGN)0x12345) == 0, "\n");
-       ok(GetLastError() == ERROR_SUCCESS, "\n");
+       ret = GetClipRgn(hDC, (HRGN)0x12345);
+       ok(ret == 0, "Expected 0, got %d\n", ret);
+       ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", GetLastError());
 
        ReleaseDC(hWnd, hDC);
        DestroyWindow(hWnd);
index 1c75fbf..26a7185 100644 (file)
 #include <windows.h>
 
 #define TEST(x) ok(x, #x"\n")
-#define RTEST(x) ok(x, #x"\n")
 
 #define NUM_SYSCOLORS 31
 
 void Test_SetSysColors()
 {
        INT i;
-       INT nElements[NUM_SYSCOLORS];
+       INT nElements[NUM_SYSCOLORS+1];
        COLORREF crOldColors[NUM_SYSCOLORS];
-       COLORREF crColors[3] = {RGB(212, 208, 200),2,3};
+       COLORREF crColors[NUM_SYSCOLORS+1];
 
        /* First save the Old colors */
        for (i = 0; i < NUM_SYSCOLORS; i++)
@@ -27,13 +26,30 @@ void Test_SetSysColors()
                nElements[i] = i;
                crOldColors[i] = GetSysColor(i);
        }
-
-       TEST((UINT)SetSysColors(0, nElements, crColors) == 1);
-       RTEST((UINT)SetSysColors(1, nElements, crColors) == 1);
-       RTEST((UINT)SetSysColors(2, nElements, crColors) == 1);
+       
+       for (i = 0; i < NUM_SYSCOLORS+1; i++)
+               crColors[i] = RGB(i, 255-i, i*3);
+       nElements[NUM_SYSCOLORS] = nElements[0];
+       
+       SetLastError(0xdeadbeef);
+       ok(SetSysColors(-1, nElements, crColors) == FALSE, "Expected FALSE, got TRUE\n");
+       ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+       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");
+       ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+       ok(SetSysColors(1, nElements, NULL) == FALSE, "Expected FALSE, got TRUE\n");
+       ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+       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]));
 
        /* try more than NUM_SYSCOLORS */
-       RTEST((UINT)SetSysColors(55, nElements, crColors) == 1);
+       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");
 
        /* restore old SysColors */
        SetSysColors(NUM_SYSCOLORS, nElements, crOldColors);