Author: tkreuzer
Date: Sat Apr  4 15:58:18 2015
New Revision: 67051

URL: http://svn.reactos.org/svn/reactos?rev=67051&view=rev
Log:
[GDI32_APITEST]
Add/fix some tests for CreateDIBPatternBrush, GetDIBits, PatBlt and 
SetWindowExtEx

Modified:
    trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c
    trunk/rostests/apitests/gdi32/GetDIBits.c
    trunk/rostests/apitests/gdi32/PatBlt.c
    trunk/rostests/apitests/gdi32/SetWindowExtEx.c

Modified: trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c?rev=67051&r1=67050&r2=67051&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c       [iso-8859-1] 
(original)
+++ trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c       [iso-8859-1] 
Sat Apr  4 15:58:18 2015
@@ -9,6 +9,9 @@
 
 #include <wingdi.h>
 #include "init.h"
+
+/* New color use parameter. See support.microsoft.com/kb/kbview/108497 */
+#define DIB_PAL_INDICES 2
 
 void Test_CreateDIBPatternBrush()
 {
@@ -30,6 +33,7 @@
     };
     HBRUSH hbr, hbrOld;
     HPALETTE hpalOld;
+    LOGBRUSH logbrush;
 
     SetLastError(0);
     ok_hdl(CreateDIBPatternBrushPt(NULL, 0), NULL);
@@ -58,6 +62,13 @@
     hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
     ok(hbr != 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
     if (!hbr) return;
+
+    /* Check the logbrush */
+    ok(GetObject(hbr, sizeof(logbrush), &logbrush), "GetObject() failed\n");
+    ok_int(logbrush.lbStyle, BS_DIBPATTERN);
+    ok_hex(logbrush.lbColor, 0);
+    ok(logbrush.lbHatch == (ULONG_PTR)&PackedDIB,
+       "invalid lbHatch. Got %p, expected %p\n", (PVOID)logbrush.lbHatch, 
&PackedDIB);
 
     /* Select the brush into the dc */
     hbrOld = SelectObject(ghdcDIB32, hbr);
@@ -100,10 +111,17 @@
     PackedDIB.ajBuffer[2] = 1;
     PackedDIB.ajBuffer[3] = 0;
 
-    /* Create a DIB brush with unkdocumented iUsage == 2 */
-    hbr = CreateDIBPatternBrushPt(&PackedDIB, 2);
+    /* Create a DIB brush with DIB_PAL_INDICES */
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_INDICES);
     ok(hbr != 0, "CreateSolidBrush failed, skipping tests.\n");
     if (!hbr) return;
+
+    /* Check the logbrush */
+    ok(GetObject(hbr, sizeof(logbrush), &logbrush), "GetObject() failed\n");
+    ok_int(logbrush.lbStyle, BS_DIBPATTERN);
+    ok_hex(logbrush.lbColor, 0);
+    ok(logbrush.lbHatch == (ULONG_PTR)&PackedDIB,
+       "invalid lbHatch. Got %p, expected %p\n", (PVOID)logbrush.lbHatch, 
&PackedDIB);
 
     /* Select the brush into the dc */
     hbrOld = SelectObject(ghdcDIB32, hbr);
@@ -155,8 +173,7 @@
 
     /* Create a DIB brush with palette indices */
     hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
-    ok(hbr != 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
-    if (!hbr) return;
+    ok(hbr == 0, "CreateDIBPatternBrushPt should fail.\n");
 
 
 }

Modified: trunk/rostests/apitests/gdi32/GetDIBits.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/GetDIBits.c?rev=67051&r1=67050&r2=67051&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/GetDIBits.c   [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/GetDIBits.c   [iso-8859-1] Sat Apr  4 
15:58:18 2015
@@ -271,10 +271,24 @@
 
     /* Test with different biBitCount set */
     pbi->bmiHeader.biBitCount = 4;
-    pbi->bmiHeader.biSizeImage = 0;
+    pbi->bmiHeader.biSizeImage = 1;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
     ok_int(pbi->bmiHeader.biSizeImage, 36);
     ok_int(pbi->bmiHeader.biBitCount, 4);
+
+    /* Test with different biBitCount set */
+    pbi->bmiHeader.biBitCount = 8;
+    pbi->bmiHeader.biSizeImage = 1000;
+    ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
+    ok_int(pbi->bmiHeader.biSizeImage, 60);
+    ok_int(pbi->bmiHeader.biBitCount, 8);
+
+    /* Test with invalid biBitCount set */
+    pbi->bmiHeader.biBitCount = 123;
+    pbi->bmiHeader.biSizeImage = -12;
+    ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
+    ok_int(pbi->bmiHeader.biSizeImage, -12);
+    ok_int(pbi->bmiHeader.biBitCount, 123);
 
     /* Set bitmap dimensions */
     ok_int(SetBitmapDimensionEx(hbmp, 110, 220, NULL), 1);
@@ -320,16 +334,21 @@
     ok_int(pbi->bmiHeader.biCompression, 0);
     ok_int(pbi->bmiHeader.biSizeImage, 0);
 
-    /* Get the bitmap bits */
+    /* Get the bitmap info */
     pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
     pbi->bmiHeader.biWidth = 4;
     pbi->bmiHeader.biHeight = 4;
-    pbi->bmiHeader.biPlanes = 1;
+    pbi->bmiHeader.biPlanes = 3;
     pbi->bmiHeader.biBitCount = 32;
     pbi->bmiHeader.biCompression = BI_RGB;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
+    ok_int(pbi->bmiHeader.biSizeImage, 64);
+    ok_int(pbi->bmiHeader.biPlanes, 1);
     pbi->bmiHeader.biWidth = 0;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
+    pbi->bmiHeader.biWidth = 2;
+    ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
+    ok_int(pbi->bmiHeader.biSizeImage, 32);
     pbi->bmiHeader.biWidth = -3;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
     pbi->bmiHeader.biWidth = 4;
@@ -343,11 +362,23 @@
     pbi->bmiHeader.biPlanes = 23;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
     ok_int(pbi->bmiHeader.biPlanes, 1);
+    SetLastError(0xdeadbabe);
+    ok_int(GetDIBits((HDC)0xff00ff00, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 
0);
+    ok_err(0x57);
+    SetLastError(0xdeadbabe);
+    ok_int(GetDIBits(hdcScreen, (HBITMAP)0xff00ff00, 0, 5, NULL, pbi, 
DIB_RGB_COLORS), 0);
+    ok_err(0xdeadbabe);
+    SetLastError(0xdeadbabe);
+    ok_int(GetDIBits((HDC)0xff00ff00, (HBITMAP)0xff00ff00, 0, 5, NULL, pbi, 
DIB_RGB_COLORS), 0);
+    ok_err(0x57);
+    SetLastError(0xdeadbabe);
+    ok_int(GetDIBits(NULL, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
+    ok_err(0x57);
+
     pbi->bmiHeader.biCompression = BI_JPEG;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
     pbi->bmiHeader.biCompression = BI_PNG;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
-
 
     /* Get the bitmap bits */
     pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -364,10 +395,22 @@
     cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 
32) * 4 * pbi->bmiHeader.biHeight;
     pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 512);
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
+    ok_int(pbi->bmiHeader.biSize, sizeof(BITMAPINFOHEADER));
+    ok_int(pbi->bmiHeader.biWidth, 4);
+    ok_int(pbi->bmiHeader.biHeight, 4);
+    ok_int(pbi->bmiHeader.biPlanes, 1);
+    ok_int(pbi->bmiHeader.biBitCount, 32);
+    ok_int(pbi->bmiHeader.biCompression, BI_RGB);
+    ok_int(pbi->bmiHeader.biSizeImage, 64);
+    ok_int(pbi->bmiHeader.biXPelsPerMeter, 0);
+    ok_int(pbi->bmiHeader.biYPelsPerMeter, 0);
+    ok_int(pbi->bmiHeader.biClrUsed, 0);
+    ok_int(pbi->bmiHeader.biClrImportant, 0);
 
     /* Set biBitCount to 0 */
     pbi->bmiHeader.biBitCount = 0;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
+    ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, (PVOID)(LONG_PTR)-1, pbi, 
DIB_RGB_COLORS), 0);
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 1);
     ok_int(GetDIBits(NULL, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 0);
 
@@ -381,6 +424,10 @@
     pbi->bmiHeader.biWidth = 3;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
 
+    /* Try invalid biBitCount */
+    pbi->bmiHeader.biBitCount = 17;
+    ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
+
     /* Set only biBitCount and pjInit */
     ZeroMemory(pbi, bisize);
     pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -405,19 +452,19 @@
     pbi->bmiHeader.biSizeImage = 0;
     ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
 
+    /* Calculate bitmap size and allocate a buffer */
     cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 
32) * 4 * pbi->bmiHeader.biHeight;
+    ok_int(cjSizeImage, 20);
     pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cjSizeImage);
 
+    /* Test using a compatible DC */
     hdcMem = CreateCompatibleDC(0);
     ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
     if (hdcMem == NULL) return;
-
-    // FIXME: broken
-    //ok(SelectObject(hdcMem, ghbmpDIB4) != 0, "Failed to select 4bpp DIB %p 
into DC %p\n", ghbmpDIB4, hdcMem);;
-    //ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
-    //ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 
3);
-
-
+    ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
+    ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
+
+    HeapFree(GetProcessHeap(), 0, pvBits);
     DeleteDC(hdcMem);
     ReleaseDC(NULL, hdcScreen);
 }

Modified: trunk/rostests/apitests/gdi32/PatBlt.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/PatBlt.c?rev=67051&r1=67050&r2=67051&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/PatBlt.c      [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/PatBlt.c      [iso-8859-1] Sat Apr  4 
15:58:18 2015
@@ -22,6 +22,10 @@
 
     /* Test a rop that contains only the operation index */
     ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
+    ok_long(ret, 1);
+
+    /* Test a rop that contains arbitrary values outside the operation index */
+    ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
     ok_long(ret, 1);
 
     /* Test an invalid rop  */

Modified: trunk/rostests/apitests/gdi32/SetWindowExtEx.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/SetWindowExtEx.c?rev=67051&r1=67050&r2=67051&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/SetWindowExtEx.c      [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/SetWindowExtEx.c      [iso-8859-1] Sat Apr  4 
15:58:18 2015
@@ -96,7 +96,14 @@
        //pDC_Attr = pEntry->UserData;
        //ASSERT(pDC_Attr);
 
-    /* Test setting it without changing the map mode (MM_TEXT) */
+    /* Test setting 0 extents without changing the map mode (MM_TEXT) */
+    ret = SetWindowExtEx(hDC, 0, 0, &WindowExt);
+    TEST(ret == 1);
+    TEST(WindowExt.cx == 1);
+    TEST(WindowExt.cy == 1);
+
+    /* Test setting proper extents without changing the map mode (MM_TEXT) */
+    WindowExt.cx = WindowExt.cy = 0;
     ret = SetWindowExtEx(hDC, 10, 20, &WindowExt);
     TEST(ret == 1);
     TEST(WindowExt.cx == 1);


Reply via email to