- another test for NtGdiBitBlt
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 30 Nov 2007 00:09:28 +0000 (00:09 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 30 Nov 2007 00:09:28 +0000 (00:09 +0000)
- Add tests for NtGdiSelectBitmap, NtGdiSelectBrush, NtGdiSelectFont and NtGdiSelectPen

svn path=/trunk/; revision=30904

rostests/apitests/w32knapi/ntgdi/NtGdiBitBlt.c
rostests/apitests/w32knapi/ntgdi/NtGdiSelectBitmap.c [new file with mode: 0644]
rostests/apitests/w32knapi/ntgdi/NtGdiSelectBrush.c [new file with mode: 0644]
rostests/apitests/w32knapi/ntgdi/NtGdiSelectFont.c [new file with mode: 0644]
rostests/apitests/w32knapi/ntgdi/NtGdiSelectPen.c [new file with mode: 0644]
rostests/apitests/w32knapi/testlist.c

index 6ce74bf..14b9114 100644 (file)
@@ -4,6 +4,12 @@ Test_NtGdiBitBlt(PTESTINFO pti)
 {
        BOOL bRet;
 
+       /* Test NULL dc */
+       SetLastError(ERROR_SUCCESS);
+       bRet = NtGdiBitBlt((HDC)0, 0, 0, 10, 10, (HDC)0, 10, 10, SRCCOPY, 0, 0);
+       TEST(bRet == FALSE);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
        /* Test invalid dc */
        SetLastError(ERROR_SUCCESS);
        bRet = NtGdiBitBlt((HDC)0x123456, 0, 0, 10, 10, (HDC)0x123456, 10, 10, SRCCOPY, 0, 0);
diff --git a/rostests/apitests/w32knapi/ntgdi/NtGdiSelectBitmap.c b/rostests/apitests/w32knapi/ntgdi/NtGdiSelectBitmap.c
new file mode 100644 (file)
index 0000000..2e99071
--- /dev/null
@@ -0,0 +1,49 @@
+INT
+Test_NtGdiSelectBitmap(PTESTINFO pti)
+{
+       HDC hDC;
+       HBITMAP hBmp, hOldBmp;
+
+       hDC = CreateCompatibleDC(GetDC(NULL));
+       ASSERT(hDC);
+
+       hBmp = CreateBitmap(2,2,1,1,NULL);
+
+       /* Test NULL DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldBmp = NtGdiSelectBitmap(NULL, hBmp);
+       TEST(hOldBmp == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldBmp = NtGdiSelectBitmap((HDC)((ULONG_PTR)hDC & 0x0000ffff), hBmp);
+       TEST(hOldBmp == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test NULL bitmap */
+       SetLastError(ERROR_SUCCESS);
+       hOldBmp = NtGdiSelectBitmap(hDC, NULL);
+       TEST(hOldBmp == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test NULL bitmap */
+       SetLastError(ERROR_SUCCESS);
+       hOldBmp = NtGdiSelectBitmap(hDC, (HBITMAP)((ULONG_PTR)hBmp & 0x0000ffff));
+       TEST(hOldBmp == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid bitmap */
+       SetLastError(ERROR_SUCCESS);
+       hOldBmp = NtGdiSelectBitmap(hDC, hBmp);
+       TEST(hOldBmp != NULL);
+       hOldBmp = NtGdiSelectBitmap(hDC, hOldBmp);
+       TEST(hOldBmp == hBmp);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       DeleteObject(hBmp);
+       DeleteDC(hDC);
+
+       return APISTATUS_NORMAL;
+}
+
diff --git a/rostests/apitests/w32knapi/ntgdi/NtGdiSelectBrush.c b/rostests/apitests/w32knapi/ntgdi/NtGdiSelectBrush.c
new file mode 100644 (file)
index 0000000..d332e9a
--- /dev/null
@@ -0,0 +1,47 @@
+INT
+Test_NtGdiSelectBrush(PTESTINFO pti)
+{
+       HDC hDC;
+       HBRUSH hBrush, hOldBrush;
+
+       hDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
+
+       hBrush = GetStockObject(GRAY_BRUSH);
+
+       /* Test NULL DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldBrush = NtGdiSelectBrush(NULL, hBrush);
+       TEST(hOldBrush == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldBrush = NtGdiSelectBrush((HDC)((ULONG_PTR)hDC & 0x0000ffff), hBrush);
+       TEST(hOldBrush == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test NULL brush */
+       SetLastError(ERROR_SUCCESS);
+       hOldBrush = NtGdiSelectBrush(hDC, NULL);
+       TEST(hOldBrush == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid brush */
+       SetLastError(ERROR_SUCCESS);
+       hOldBrush = NtGdiSelectBrush(hDC, (HBRUSH)((ULONG_PTR)hBrush & 0x0000ffff));
+       TEST(hOldBrush == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       SetLastError(ERROR_SUCCESS);
+       hOldBrush = NtGdiSelectBrush(hDC, hBrush);
+       TEST(hOldBrush != NULL);
+       hOldBrush = NtGdiSelectBrush(hDC, hOldBrush);
+       TEST(hOldBrush == hBrush);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+
+       DeleteDC(hDC);
+
+       return APISTATUS_NORMAL;
+}
+
diff --git a/rostests/apitests/w32knapi/ntgdi/NtGdiSelectFont.c b/rostests/apitests/w32knapi/ntgdi/NtGdiSelectFont.c
new file mode 100644 (file)
index 0000000..acba727
--- /dev/null
@@ -0,0 +1,47 @@
+INT
+Test_NtGdiSelectFont(PTESTINFO pti)
+{
+       HDC hDC;
+       HFONT hFont, hOldFont;
+
+       hDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
+
+       hFont = GetStockObject(DEFAULT_GUI_FONT);
+
+       /* Test NULL DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldFont = NtGdiSelectFont(NULL, hFont);
+       TEST(hOldFont == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldFont = NtGdiSelectFont((HDC)((ULONG_PTR)hDC & 0x0000ffff), hFont);
+       TEST(hOldFont == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test NULL font */
+       SetLastError(ERROR_SUCCESS);
+       hOldFont = NtGdiSelectFont(hDC, NULL);
+       TEST(hOldFont == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid font */
+       SetLastError(ERROR_SUCCESS);
+       hOldFont = NtGdiSelectFont(hDC, (HFONT)((ULONG_PTR)hFont & 0x0000ffff));
+       TEST(hOldFont == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       SetLastError(ERROR_SUCCESS);
+       hOldFont = NtGdiSelectFont(hDC, hFont);
+       TEST(hOldFont != NULL);
+       hOldFont = NtGdiSelectFont(hDC, hOldFont);
+       TEST(hOldFont == hFont);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+
+       DeleteDC(hDC);
+
+       return APISTATUS_NORMAL;
+}
+
diff --git a/rostests/apitests/w32knapi/ntgdi/NtGdiSelectPen.c b/rostests/apitests/w32knapi/ntgdi/NtGdiSelectPen.c
new file mode 100644 (file)
index 0000000..7731dc6
--- /dev/null
@@ -0,0 +1,46 @@
+INT
+Test_NtGdiSelectPen(PTESTINFO pti)
+{
+       HDC hDC;
+       HPEN hPen, hOldPen;
+
+       hDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
+
+       hPen = GetStockObject(WHITE_PEN);
+
+       /* Test NULL DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldPen = NtGdiSelectPen(NULL, hPen);
+       TEST(hOldPen == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test invalid DC */
+       SetLastError(ERROR_SUCCESS);
+       hOldPen = NtGdiSelectPen((HDC)((ULONG_PTR)hDC & 0x0000ffff), hPen);
+       TEST(hOldPen == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test NULL pen */
+       SetLastError(ERROR_SUCCESS);
+       hOldPen = NtGdiSelectPen(hDC, NULL);
+       TEST(hOldPen == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       /* Test NULL pen */
+       SetLastError(ERROR_SUCCESS);
+       hOldPen = NtGdiSelectPen(hDC, (HPEN)((ULONG_PTR)hPen & 0x0000ffff));
+       TEST(hOldPen == NULL);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+       SetLastError(ERROR_SUCCESS);
+       hOldPen = NtGdiSelectPen(hDC, hPen);
+       TEST(hOldPen != NULL);
+       hOldPen = NtGdiSelectPen(hDC, hOldPen);
+       TEST(hOldPen == hPen);
+       TEST(GetLastError() == ERROR_SUCCESS);
+
+
+       DeleteDC(hDC);
+
+       return APISTATUS_NORMAL;
+}
index f05ac37..80d9dab 100644 (file)
 #include "ntgdi/NtGdiEnumFontOpen.c"\r
 #include "ntgdi/NtGdiGetBitmapBits.c"\r
 #include "ntgdi/NtGdiGetRandomRgn.c"\r
+#include "ntgdi/NtGdiSelectBitmap.c"\r
+#include "ntgdi/NtGdiSelectBrush.c"\r
+#include "ntgdi/NtGdiSelectFont.c"\r
+#include "ntgdi/NtGdiSelectPen.c"\r
 #include "ntgdi/NtGdiSetBitmapBits.c"\r
 //#include "ntgdi/NtGdiSTROBJ_vEnumStart.c"\r
 #include "ntgdi/NtGdiGetDIBits.c"\r
@@ -46,6 +50,10 @@ TESTENTRY TestList[] =
        { L"NtGdiGetBitmapBits", Test_NtGdiGetBitmapBits },\r
        { L"NtGdiGetRandomRgn", Test_NtGdiGetRandomRgn },\r
        { L"NtGdiSetBitmapBits", Test_NtGdiSetBitmapBits },\r
+       { L"NtGdiSelectBitmap", Test_NtGdiSelectBitmap },\r
+       { L"NtGdiSelectBrush", Test_NtGdiSelectBrush },\r
+       { L"NtGdiSelectFont", Test_NtGdiSelectFont },\r
+       { L"NtGdiSelectPen", Test_NtGdiSelectPen },\r
 //     { L"NtGdiSTROBJ_vEnumStart", Test_NtGdiSTROBJ_vEnumStart },\r
        { L"NtGdiGetDIBitsInternal", Test_NtGdiGetDIBitsInternal },\r
 \r