2015-12-28 20:31:10 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for NtGdiSetBitmapBits
|
2019-01-26 02:38:42 +00:00
|
|
|
* PROGRAMMERS: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
2015-12-28 20:31:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <win32nt.h>
|
|
|
|
|
|
|
|
START_TEST(NtGdiSetBitmapBits)
|
2008-06-01 18:06:22 +00:00
|
|
|
{
|
|
|
|
BYTE Bits[50] = {0,1,2,3,4,5,6,7,8,9};
|
|
|
|
HBITMAP hBitmap;
|
2019-01-26 02:38:42 +00:00
|
|
|
HDC hDC;
|
|
|
|
BITMAPINFO bmi;
|
|
|
|
LPVOID pvBits;
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(0, 0, 0), 0);
|
|
|
|
ok_long(GetLastError(), ERROR_SUCCESS);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test NULL bitnap handle */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(0, 5, Bits), 0);
|
|
|
|
ok_long(GetLastError(), ERROR_INVALID_HANDLE);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test invalid bitmap handle */
|
|
|
|
hBitmap = (HBITMAP)CreatePen(PS_SOLID, 1, RGB(1,2,3));
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 5, Bits), 0);
|
|
|
|
ok_long(GetLastError(), ERROR_INVALID_HANDLE);
|
2008-06-01 18:06:22 +00:00
|
|
|
DeleteObject(hBitmap);
|
|
|
|
|
|
|
|
hBitmap = CreateBitmap(3, 3, 1, 8, NULL);
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
|
|
|
|
/* test NULL pointer and count buffer size != 0 */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 5, NULL), 0);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* test NULL pointer and buffer size == 0*/
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 0, NULL), 0);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* test bad pointer */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 5, (PBYTE)0x500), 0);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test if we can set a number of bytes between lines */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 5, Bits), 5);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test alignment */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 4, Bits+1), 4);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test 1 byte too much */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 10, Bits), 10);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test one row too much */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 12, Bits), 12);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 13, Bits), 12);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 100, Bits), 12);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test huge bytes count */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 12345678, Bits), 0);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
/* Test negative bytes count */
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, -5, Bits), 0);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
2019-01-21 16:38:20 +00:00
|
|
|
ok_long(GetLastError(), ERROR_SUCCESS);
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
DeleteObject(hBitmap);
|
2019-01-26 02:38:42 +00:00
|
|
|
|
|
|
|
/* ------------------------- */
|
|
|
|
|
|
|
|
hBitmap = CreateBitmap(16, 16, 1, 1, NULL);
|
|
|
|
ok(hBitmap != NULL, "hBitmap was NULL.\n");
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 0, Bits), 0);
|
|
|
|
ok_int(Bits[0], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 1, Bits), 1);
|
|
|
|
ok_int(Bits[0], 0);
|
|
|
|
ok_int(Bits[1], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
ok_int(Bits[0], 0);
|
|
|
|
ok_int(Bits[1], 0);
|
|
|
|
ok_int(Bits[2], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x33);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 10, Bits), 10);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0xAA);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 1, Bits), 1);
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 1, Bits), 1);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0x33);
|
|
|
|
ok_int(Bits[2], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0xAA);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 3, Bits), 3);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0x33);
|
|
|
|
ok_int(Bits[3], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0xAA);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 3, Bits), 3);
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 3, Bits), 3);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0xAA);
|
|
|
|
ok_int(Bits[3], 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 4, Bits), 4);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0xAA);
|
|
|
|
ok_int(Bits[3], 0x33);
|
|
|
|
ok_int(Bits[4], 0x55);
|
|
|
|
|
|
|
|
DeleteObject(hBitmap);
|
|
|
|
|
|
|
|
/* ------------------------- */
|
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
|
|
|
|
ZeroMemory(&bmi, sizeof(bmi));
|
|
|
|
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
bmi.bmiHeader.biWidth = 15;
|
|
|
|
bmi.bmiHeader.biHeight = 15;
|
|
|
|
bmi.bmiHeader.biPlanes = 1;
|
|
|
|
bmi.bmiHeader.biBitCount = 24;
|
|
|
|
hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pvBits, NULL, 0);
|
|
|
|
ok(hBitmap != NULL, "hBitmap was NULL.\n");
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 0, Bits), 0);
|
|
|
|
ok_int(Bits[0], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 1, Bits), 1);
|
|
|
|
ok_int(Bits[0], 0);
|
|
|
|
ok_int(Bits[1], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
ok_int(Bits[0], 0);
|
|
|
|
ok_int(Bits[1], 0);
|
|
|
|
ok_int(Bits[2], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x33);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 10, Bits), 10);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0xAA);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 1, Bits), 1);
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 1, Bits), 1);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0x33);
|
|
|
|
ok_int(Bits[2], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0xAA);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 2, Bits), 2);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 3, Bits), 3);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0x33);
|
|
|
|
ok_int(Bits[3], 0x55);
|
|
|
|
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0xAA);
|
|
|
|
ok_long(NtGdiSetBitmapBits(hBitmap, 3, Bits), 3);
|
|
|
|
FillMemory(Bits, sizeof(Bits), 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 3, Bits), 3);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0xAA);
|
|
|
|
ok_int(Bits[3], 0x55);
|
|
|
|
ok_long(NtGdiGetBitmapBits(hBitmap, 4, Bits), 4);
|
|
|
|
ok_int(Bits[0], 0xAA);
|
|
|
|
ok_int(Bits[1], 0xAA);
|
|
|
|
ok_int(Bits[2], 0xAA);
|
|
|
|
ok_int(Bits[3], 0x33);
|
|
|
|
ok_int(Bits[4], 0x55);
|
|
|
|
|
|
|
|
DeleteObject(hBitmap);
|
|
|
|
DeleteDC(hDC);
|
2008-06-01 18:06:22 +00:00
|
|
|
}
|