[ros-diffs] [tkreuzer] 56498: [GDI32_APITEST] - Add tests for CreateDIBPatternBrush(Pt) - Add some helper code to initialize a dibsection and a palette, which can be reused by other tests - Add tests for DIB b...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Fri May 4 18:56:43 UTC 2012


Author: tkreuzer
Date: Fri May  4 18:56:43 2012
New Revision: 56498

URL: http://svn.reactos.org/svn/reactos?rev=56498&view=rev
Log:
[GDI32_APITEST]
- Add tests for CreateDIBPatternBrush(Pt)
- Add some helper code to initialize a dibsection and a palette, which can be reused by other tests
- Add tests for DIB brush in GetObject

Added:
    trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c   (with props)
    trunk/rostests/apitests/gdi32/init.c   (with props)
    trunk/rostests/apitests/gdi32/init.h   (with props)
Modified:
    trunk/rostests/apitests/gdi32/CMakeLists.txt
    trunk/rostests/apitests/gdi32/GetObject.c
    trunk/rostests/apitests/gdi32/testlist.c

Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CMakeLists.txt?rev=56498&r1=56497&r2=56498&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] Fri May  4 18:56:43 2012
@@ -12,6 +12,7 @@
     CreateBitmapIndirect.c
     CreateCompatibleDC.c
     CreateDIBitmap.c
+    CreateDIBPatternBrush
     CreateFont.c
     CreateFontIndirect.c
     CreateIconIndirect.c
@@ -57,6 +58,7 @@
     SetSysColors.c
     SetWindowExtEx.c
     SetWorldTransform.c
+    init.c
     testlist.c)
 
 add_executable(gdi32_apitest ${SOURCE})

Added: trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c?rev=56498&view=auto
==============================================================================
--- trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c (added)
+++ trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c [iso-8859-1] Fri May  4 18:56:43 2012
@@ -1,0 +1,147 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for CreateDIBPatternBrush
+ * PROGRAMMERS:     Timo Kreuzer
+ */
+
+#include <stdio.h>
+#include <wine/test.h>
+#include <windows.h>
+#include "init.h"
+
+
+void Test_CreateDIBPatternBrush()
+{
+
+}
+
+void Test_CreateDIBPatternBrushPt()
+{
+    struct
+    {
+        BITMAPINFOHEADER bmiHeader;
+        WORD wColors[4];
+        BYTE ajBuffer[16];
+    } PackedDIB =
+    {
+        {sizeof(BITMAPINFOHEADER), 4, -4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
+        {0, 1, 2, 7},
+        {0,1,2,3,  1,2,3,0,  2,3,0,1,  3,0,1,2},
+    };
+    PBITMAPINFO pbmi = (PBITMAPINFO)&PackedDIB;
+    HBRUSH hbr, hbrOld;
+    HPALETTE hpalOld;
+
+    SetLastError(0);
+    ok_hdl(CreateDIBPatternBrushPt(NULL, 0), NULL);
+    ok_hdl(CreateDIBPatternBrushPt(NULL, DIB_PAL_COLORS), NULL);
+    ok_hdl(CreateDIBPatternBrushPt(NULL, 2), NULL);
+    ok_hdl(CreateDIBPatternBrushPt(NULL, 3), NULL);
+    ok_err(0);
+
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, 0);
+    ok(hbr != 0, "Expected success\n");
+    DeleteObject(hbr);
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, 2);
+    ok(hbr != 0, "Expected success\n");
+    DeleteObject(hbr);
+
+    SetLastError(0);
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, 3);
+    ok(hbr == 0, "Expected failure\n");
+    ok_err(ERROR_INVALID_PARAMETER);
+    SetLastError(0);
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, 10);
+    ok(hbr == 0, "Expected failure\n");
+    ok_err(ERROR_INVALID_PARAMETER);
+
+    /* Create a DIB brush with palette indices */
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
+    ok(hbr != 0, "CreateSolidBrush failed, skipping tests.\n");
+    if (!hbr) return;
+
+    /* Select the brush into the dc */
+    hbrOld = SelectObject(ghdcDIB32, hbr);
+
+    /* Copy it on the dib section */
+    ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
+    ok_long(pulDIB32Bits[0], 0x000000); // 0
+    ok_long(pulDIB32Bits[1], 0x800000); // 1
+    ok_long(pulDIB32Bits[2], 0x008000); // 2
+    ok_long(pulDIB32Bits[3], 0xc0c0c0); // 7
+
+    /* Select a logical palette into the DC */
+    hpalOld = SelectPalette(ghdcDIB32, ghpal, FALSE);
+    ok(hpalOld != 0, "Expected success, error %ld\n", GetLastError());
+
+    /* Copy it on the dib section */
+    ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
+    ok_long(pulDIB32Bits[0], 0x102030); // 0
+    ok_long(pulDIB32Bits[1], 0x203040); // 1
+    ok_long(pulDIB32Bits[2], 0x304050); // 2
+    ok_long(pulDIB32Bits[3], 0x8090a0); // 7
+
+    /* Select back old palette and destroy the DIB data */
+    SelectPalette(ghdcDIB32, hpalOld, FALSE);
+    memset(&PackedDIB.ajBuffer, 0x77, 4);
+
+    /* Copy it on the dib section */
+    ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
+    ok_long(pulDIB32Bits[0], 0x000000); // 0
+    ok_long(pulDIB32Bits[1], 0x800000); // 1
+    ok_long(pulDIB32Bits[2], 0x008000); // 2
+    ok_long(pulDIB32Bits[3], 0xc0c0c0); // 7
+
+    SelectObject(ghdcDIB32, hbrOld);
+    DeleteObject(hbr);
+
+    /* Set some different values */
+    PackedDIB.ajBuffer[0] = 3;
+    PackedDIB.ajBuffer[1] = 2;
+    PackedDIB.ajBuffer[2] = 1;
+    PackedDIB.ajBuffer[3] = 0;
+
+    /* Create a DIB brush with unkdocumented iUsage == 2 */
+    hbr = CreateDIBPatternBrushPt(&PackedDIB, 2);
+    ok(hbr != 0, "CreateSolidBrush failed, skipping tests.\n");
+    if (!hbr) return;
+
+    /* Select the brush into the dc */
+    hbrOld = SelectObject(ghdcDIB32, hbr);
+    ok(hbrOld != 0, "CreateSolidBrush failed, skipping tests.\n");
+
+    /* Copy it on a dib section */
+    memset(pulDIB32Bits, 0x77, 64);
+    ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
+    ok_long(pulDIB32Bits[0], 0x77777777);
+    ok_long(pulDIB32Bits[1], 0x77777777);
+    ok_long(pulDIB32Bits[2], 0x77777777);
+    ok_long(pulDIB32Bits[3], 0x77777777);
+
+    /* Select a logical palette into the DC */
+    hpalOld = SelectPalette(ghdcDIB32, ghpal, FALSE);
+    ok(hpalOld != 0, "Expected success, error %ld\n", GetLastError());
+
+    /* Copy it on a dib section */
+    ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
+    ok_long(pulDIB32Bits[0], 0x77777777);
+    ok_long(pulDIB32Bits[1], 0x77777777);
+    ok_long(pulDIB32Bits[2], 0x77777777);
+    ok_long(pulDIB32Bits[3], 0x77777777);
+
+    SelectPalette(ghdcDIB32, hpalOld, FALSE);
+    SelectObject(ghdcDIB32, hbrOld);
+    DeleteObject(hbr);
+
+}
+
+
+START_TEST(CreateDIBPatternBrush)
+{
+    InitStuff();
+
+    Test_CreateDIBPatternBrush();
+    Test_CreateDIBPatternBrushPt();
+}
+

Propchange: trunk/rostests/apitests/gdi32/CreateDIBPatternBrush.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/rostests/apitests/gdi32/GetObject.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/GetObject.c?rev=56498&r1=56497&r2=56498&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/GetObject.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/GetObject.c [iso-8859-1] Fri May  4 18:56:43 2012
@@ -216,7 +216,7 @@
 void
 Test_Dibsection(void)
 {
-	BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 8, BI_RGB, 0, 10, 10, 0,0}};
+	BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
 	HBITMAP hBitmap;
 	BITMAP bitmap;
 	DIBSECTION dibsection;
@@ -233,25 +233,25 @@
 	ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
 
 	SetLastError(ERROR_SUCCESS);
-	ok(GetObject(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP), "\n");
-	ok(GetObject(hBitmap, 0, NULL) == sizeof(BITMAP), "\n");
-	ok(GetObject(hBitmap, 5, NULL) == sizeof(BITMAP), "\n");
-	ok(GetObject(hBitmap, -5, NULL) == sizeof(BITMAP), "\n");
-	ok(GetObject(hBitmap, 0, &dibsection) == 0, "\n");
-	ok(GetObject(hBitmap, 5, &dibsection) == 0, "\n");
-	ok(GetObject(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP), "\n");
-	ok(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP), "\n");
-	ok(bitmap.bmType == 0, "\n");
-	ok(bitmap.bmWidth == 10, "\n");
-	ok(bitmap.bmHeight == 9, "\n");
-	ok(bitmap.bmWidthBytes == 12, "\n");
-	ok(bitmap.bmPlanes == 1, "\n");
-	ok(bitmap.bmBitsPixel == 8, "\n");
+	ok_long(GetObject(hBitmap, sizeof(DIBSECTION), NULL), sizeof(BITMAP));
+	ok_long(GetObject(hBitmap, 0, NULL), sizeof(BITMAP));
+	ok_long(GetObject(hBitmap, 5, NULL), sizeof(BITMAP));
+	ok_long(GetObject(hBitmap, -5, NULL), sizeof(BITMAP));
+	ok_long(GetObject(hBitmap, 0, &dibsection), 0);
+	ok_long(GetObject(hBitmap, 5, &dibsection), 0);
+	ok_long(GetObject(hBitmap, sizeof(BITMAP), &bitmap), sizeof(BITMAP));
+	ok_long(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap), sizeof(BITMAP));
+	ok_long(bitmap.bmType, 0);
+	ok_long(bitmap.bmWidth, 10);
+	ok_long(bitmap.bmHeight, 9);
+	ok_long(bitmap.bmWidthBytes, 20);
+	ok_long(bitmap.bmPlanes, 1);
+	ok_long(bitmap.bmBitsPixel, 16);
 	ok(bitmap.bmBits == pData, "\n");
-	ok(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(DIBSECTION), "\n");
-	ok(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection) == sizeof(DIBSECTION), "\n");
-	ok(GetObject(hBitmap, -5, &dibsection) == sizeof(DIBSECTION), "\n");
-	ok(GetLastError() == ERROR_SUCCESS, "\n");
+	ok_long(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION));
+	ok_long(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection), sizeof(DIBSECTION));
+	ok_long(GetObject(hBitmap, -5, &dibsection), sizeof(DIBSECTION));
+	ok_err(ERROR_SUCCESS);
 	DeleteObject(hBitmap);
 	ReleaseDC(0, hDC);
 }
@@ -333,6 +333,59 @@
 
 	ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, sizeof(LOGBRUSH), &logbrush) == 0, "\n");
 	ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+}
+
+void
+Test_DIBBrush(void)
+{
+    struct
+    {
+        BITMAPINFOHEADER bmiHeader;
+        WORD wColors[4];
+        BYTE jBuffer[16];
+    } PackedDIB =
+    {
+        {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
+        {1, 7, 3, 1},
+        {0,1,2,3,  1,2,3,0,  2,3,0,1,  3,0,1,2},
+    };
+    PBITMAPINFO pbmi = (PBITMAPINFO)&PackedDIB;
+	LOGBRUSH logbrush;
+	HBRUSH hBrush;
+
+    /* Create a DIB brush */
+    hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
+	ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
+	if (!hBrush) return;
+
+	FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
+	SetLastError(ERROR_SUCCESS);
+
+	ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
+	ok_long(logbrush.lbStyle, BS_DIBPATTERN);
+	ok_long(logbrush.lbColor, 0);
+	ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
+
+	ok_err(ERROR_SUCCESS);
+	DeleteObject(hBrush);
+
+
+    /* Create a DIB brush with undocumented iUsage 2 */
+    hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
+	ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
+	if (!hBrush) return;
+
+	FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
+	SetLastError(ERROR_SUCCESS);
+
+	ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
+	ok_long(logbrush.lbStyle, BS_DIBPATTERN);
+	ok_long(logbrush.lbColor, 0);
+	ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
+
+	ok_err(ERROR_SUCCESS);
+	DeleteObject(hBrush);
+
 }
 
 void
@@ -632,6 +685,7 @@
 	Test_Dibsection();
 	Test_Palette();
 	Test_Brush();
+	Test_DIBBrush();
 	Test_Pen();
 	Test_ExtPen(); // not implemented yet in ROS
 	Test_MetaDC();

Added: trunk/rostests/apitests/gdi32/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/init.c?rev=56498&view=auto
==============================================================================
--- trunk/rostests/apitests/gdi32/init.c (added)
+++ trunk/rostests/apitests/gdi32/init.c [iso-8859-1] Fri May  4 18:56:43 2012
@@ -1,0 +1,51 @@
+
+#include <stdio.h>
+#include <windows.h>
+
+HBITMAP ghbmpDIB32;
+HDC ghdcDIB32;
+PULONG pulDIB32Bits;
+HPALETTE ghpal;
+
+struct
+{
+    WORD palVersion;
+    WORD palNumEntries;
+    PALETTEENTRY logpalettedata[8];
+} gpal =
+{
+    0x300, 8,
+    {
+        { 0x10, 0x20, 0x30, PC_NOCOLLAPSE },
+        { 0x20, 0x30, 0x40, PC_NOCOLLAPSE },
+        { 0x30, 0x40, 0x50, PC_NOCOLLAPSE },
+        { 0x40, 0x50, 0x60, PC_NOCOLLAPSE },
+        { 0x50, 0x60, 0x70, PC_NOCOLLAPSE },
+        { 0x60, 0x70, 0x80, PC_NOCOLLAPSE },
+        { 0x70, 0x80, 0x90, PC_NOCOLLAPSE },
+        { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE },
+    }
+};
+
+BOOL InitStuff(void)
+{
+    BITMAPINFO bmi32 =
+        {{sizeof(BITMAPINFOHEADER), 4, -4, 1, 32, BI_RGB, 0, 1, 1, 0, 0}, {0}};
+
+    ghdcDIB32 = CreateCompatibleDC(0);
+
+    ghbmpDIB32 = CreateDIBSection(ghdcDIB32, &bmi32, DIB_PAL_COLORS, (PVOID*)&pulDIB32Bits, 0, 0 );
+    if (!ghbmpDIB32) return FALSE;
+
+    SelectObject(ghdcDIB32, ghbmpDIB32);
+
+    /* Initialize a logical palette */
+    ghpal = CreatePalette((LOGPALETTE*)&gpal);
+    if (!ghpal)
+    {
+        printf("failed to create a palette \n");
+        return FALSE;
+    }
+
+    return TRUE;
+}

Propchange: trunk/rostests/apitests/gdi32/init.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/rostests/apitests/gdi32/init.h
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/init.h?rev=56498&view=auto
==============================================================================
--- trunk/rostests/apitests/gdi32/init.h (added)
+++ trunk/rostests/apitests/gdi32/init.h [iso-8859-1] Fri May  4 18:56:43 2012
@@ -1,0 +1,13 @@
+
+extern HBITMAP ghbmpDIB32;
+extern HDC ghdcDIB32;
+extern PULONG pulDIB32Bits;
+extern HPALETTE ghpal;
+extern struct
+{
+    LOGPALETTE logpal;
+    PALETTEENTRY logpalettedata[8];
+} gpal;
+
+BOOL InitStuff(void);
+

Propchange: trunk/rostests/apitests/gdi32/init.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/rostests/apitests/gdi32/testlist.c
URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/testlist.c?rev=56498&r1=56497&r2=56498&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] Fri May  4 18:56:43 2012
@@ -14,6 +14,7 @@
 extern void func_CreateBitmapIndirect(void);
 extern void func_CreateCompatibleDC(void);
 extern void func_CreateDIBitmap(void);
+extern void func_CreateDIBPatternBrush(void);
 extern void func_CreateFont(void);
 extern void func_CreateFontIndirect(void);
 extern void func_CreateIconIndirect(void);
@@ -71,6 +72,7 @@
     { "CreateBitmapIndirect", func_CreateBitmapIndirect },
     { "CreateCompatibleDC", func_CreateCompatibleDC },
     { "CreateDIBitmap", func_CreateDIBitmap },
+    { "CreateDIBPatternBrush", func_CreateDIBPatternBrush },
     { "CreateFont", func_CreateFont },
     { "CreateFontIndirect", func_CreateFontIndirect },
     { "CreateIconIndirect", func_CreateFontIndirect },




More information about the Ros-diffs mailing list