[GDI32_APITEST] Create StretchBlt Regression Test (#3109)

* Add gdi32_apitest:StretchBlt regression test.
* Give Wine proper credit for base code.
This commit is contained in:
Doug Lyons 2020-09-10 11:15:12 -05:00 committed by GitHub
parent c8e3ef7894
commit e06ec0a594
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 111 additions and 0 deletions

View file

@ -74,6 +74,7 @@ list(APPEND SOURCE
SetSysColors.c
SetWindowExtEx.c
SetWorldTransform.c
StretchBlt.c
TextTransform.c
init.c)

View file

@ -0,0 +1,108 @@
/*
* PROJECT: ReactOS API tests
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Tests for the StretchBlt API
* COPYRIGHT: Copyright 2020 Doug Lyons (douglyons at douglyons dot com)
* Most Code copied and modified from Wine gdi32:bitmap test.
*/
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
static void test_StretchBlt(void)
{
HBITMAP bmpDst, bmpSrc;
HDC hdcDst, hdcSrc;
UINT32 *dstBuffer, *srcBuffer;
BITMAPINFO biDst, biSrc;
UINT32 expected[256];
memset(&biDst, 0, sizeof(BITMAPINFO));
biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
biDst.bmiHeader.biWidth = 2;
biDst.bmiHeader.biHeight = 2; // Set our Height to positive so we are bottom-up
biDst.bmiHeader.biPlanes = 1;
biDst.bmiHeader.biBitCount = 32; // Set our BitCount to 32 which is Full Color
biDst.bmiHeader.biCompression = BI_RGB;
memcpy(&biSrc, &biDst, sizeof(BITMAPINFO)); // Put same Destination params into the Source
hdcDst = CreateCompatibleDC(0);
hdcSrc = CreateCompatibleDC(0);
bmpSrc = CreateDIBSection(hdcSrc, &biSrc, DIB_RGB_COLORS, (void**)&srcBuffer, NULL, 0);
SelectObject(hdcSrc, bmpSrc);
bmpDst = CreateDIBSection(hdcDst, &biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0);
SelectObject(hdcDst, bmpDst);
srcBuffer[0] = 0x000000FF; // BLUE - stored beginning bottom left
srcBuffer[1] = 0x0000FF00; // GREEN
srcBuffer[2] = 0x00FF0000; // RED
srcBuffer[3] = 0xFF000000; // BLACK - 0xFF for alpha channel is easy to recognize when printed in hex format
/* Flip Left to Right on Source */
StretchBlt(hdcDst, 0, 0, 2, 2, hdcSrc, 1, 0, -2, 2, SRCCOPY);
expected[0] = 0x0000FF00;
expected[1] = 0x000000FF;
expected[2] = 0xFF000000;
expected[3] = 0x00FF0000;
ok(expected[1] == dstBuffer[1], "StretchBlt expected { %08X } got { %08X }\n",
expected[1], dstBuffer[1]);
ok(expected[3] == dstBuffer[3], "StretchBlt expected { %08X } got { %08X }\n",
expected[3], dstBuffer[3]);
/* Flip Top to Bottom on Source */
StretchBlt(hdcDst, 0, 0, 2, 2, hdcSrc, 0, 1, 2, -2, SRCCOPY);
expected[0] = 0x00FF0000;
expected[1] = 0xFF000000;
expected[2] = 0x000000FF;
expected[3] = 0x0000FF00;
ok(expected[0] == dstBuffer[0], "StretchBlt expected { %08X } got { %08X }\n",
expected[0], dstBuffer[0]);
ok(expected[1] == dstBuffer[1], "StretchBlt expected { %08X } got { %08X }\n",
expected[1], dstBuffer[1]);
/* Flip Left to Right and Top to Bottom on Source */
StretchBlt(hdcDst, 0, 0, 2, 2, hdcSrc, 1, 1, -2, -2, SRCCOPY);
expected[0] = 0xFF000000;
expected[1] = 0x00FF0000;
expected[2] = 0x0000FF00;
expected[3] = 0x000000FF;
ok(expected[1] == dstBuffer[1], "StretchBlt expected { %08X } got { %08X }\n",
expected[1], dstBuffer[1]);
/* Flip Left to Right and Top to Bottom on both Source and Destination */
StretchBlt(hdcDst, 1, 1, -2, -2, hdcSrc, 1, 1, -2, -2, SRCCOPY);
expected[0] = 0xFF000000;
expected[1] = 0x00FF0000;
expected[2] = 0x00FF0000;
expected[3] = 0x000000FF;
ok(expected[1] == dstBuffer[1], "StretchBlt expected { %08X } got { %08X }\n",
expected[1], dstBuffer[1]);
DeleteDC(hdcSrc);
DeleteDC(hdcDst);
}
START_TEST(StretchBlt)
{
test_StretchBlt();
}

View file

@ -75,6 +75,7 @@ extern void func_SetPixel(void);
extern void func_SetSysColors(void);
extern void func_SetWindowExtEx(void);
extern void func_SetWorldTransform(void);
extern void func_StretchBlt(void);
extern void func_TextTransform(void);
const struct test winetest_testlist[] =
@ -151,6 +152,7 @@ const struct test winetest_testlist[] =
{ "SetSysColors", func_SetSysColors },
{ "SetWindowExtEx", func_SetWindowExtEx },
{ "SetWorldTransform", func_SetWorldTransform },
{ "StretchBlt", func_StretchBlt },
{ "TextTransform", func_TextTransform },
{ 0, 0 }