Index: rostests/apitests/win32nt/ntgdi/NtGdiCreateDIBSection.c =================================================================== --- rostests/apitests/win32nt/ntgdi/NtGdiCreateDIBSection.c (revision 75066) +++ rostests/apitests/win32nt/ntgdi/NtGdiCreateDIBSection.c (working copy) @@ -2,7 +2,7 @@ * PROJECT: ReactOS api tests * LICENSE: GPL - See COPYING in the top level directory * PURPOSE: Test for NtGdiCreateDIBSection - * PROGRAMMERS: + * PROGRAMMERS: Katayama Hirofumi MZ */ #include @@ -57,7 +57,7 @@ NTSTATUS Status; LARGE_INTEGER MaximumSize; - hDC = GetDC(0); + hDC = GetDC(NULL); pbih->biSize = sizeof(BITMAPINFOHEADER); pbih->biWidth = 2; pbih->biHeight = 2; @@ -77,128 +77,128 @@ cjHeader = bmi.bmiHeader.biSize + cEntries * 4 + 8; /* Test something simple */ - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); -// TEST(GetLastError() == 0); - TEST(GetObject(hbmp, sizeof(DIBSECTION), &dibsection) == sizeof(DIBSECTION)); - TEST(dibsection.dsBitfields[0] == 0); - TEST(dibsection.dsBitfields[1] == 0); - TEST(dibsection.dsBitfields[2] == 0); - TEST(dibsection.dshSection == 0); - TEST(dibsection.dsOffset == 0); + TEST(hbmp != NULL); +// ok_err(0xDEADBEEF); + ok_int(GetObject(hbmp, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION)); + ok_int(dibsection.dsBitfields[0], 0); + ok_int(dibsection.dsBitfields[1], 0); + ok_int(dibsection.dsBitfields[2], 0); + ok_ptr(dibsection.dshSection, NULL); + ok_int(dibsection.dsOffset, 0); if (hbmp) DeleteObject(hbmp); - /* Test a 0 HDC */ - SetLastError(0); - pvBits = 0; - hbmp = NtGdiCreateDIBSection(0, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); + /* Test a NULL HDC */ + SetLastError(0xDEADBEEF); + pvBits = NULL; + hbmp = NtGdiCreateDIBSection(NULL, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); - TEST(GetLastError() == ERROR_NOT_ENOUGH_MEMORY); + TEST(hbmp != NULL); + ok_err(ERROR_NOT_ENOUGH_MEMORY); if (hbmp) DeleteObject(hbmp); /* Test a wrong HDC */ - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection((HDC)0xdeadbeef, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(pvBits != 0); - TEST(hbmp != 0); - TEST(GetLastError() == 8); + TEST(pvBits != NULL); + TEST(hbmp != NULL); + ok_err(ERROR_NOT_ENOUGH_MEMORY); if (hbmp) DeleteObject(hbmp); /* Test pbmi = NULL */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, NULL, 0, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* Test invalid pbmi */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, (PVOID)0x80001234, 0, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(ERROR_INVALID_PARAMETER); if (hbmp) DeleteObject(hbmp); /* Test invalid pbmi */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, (PVOID)1, 0, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(ERROR_INVALID_PARAMETER); if (hbmp) DeleteObject(hbmp); /* Test ppvBits = NULL */ - SetLastError(0); - hbmp = NtGdiCreateDIBSection(0, NULL, 0, pbmi, 0, cjHeader, 0, 0, NULL); - TEST(hbmp == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); + SetLastError(0xDEADBEEF); + hbmp = NtGdiCreateDIBSection(NULL, NULL, 0, pbmi, 0, cjHeader, 0, 0, NULL); + ok_ptr(hbmp, NULL); + ok_err(ERROR_INVALID_PARAMETER); if (hbmp) DeleteObject(hbmp); - /* Test ppvBits = NULL and pbmi == 0*/ - SetLastError(0); - hbmp = NtGdiCreateDIBSection(0, NULL, 0, NULL, 0, cjHeader, 0, 0, NULL); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + /* Test ppvBits = NULL and pbmi == NULL */ + SetLastError(0xDEADBEEF); + hbmp = NtGdiCreateDIBSection(NULL, NULL, 0, NULL, 0, cjHeader, 0, 0, NULL); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* Test ppvBits = NULL and wrong cjHeader */ - SetLastError(0); - hbmp = NtGdiCreateDIBSection(0, NULL, 0, pbmi, 0, cjHeader+4, 0, 0, NULL); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + SetLastError(0xDEADBEEF); + hbmp = NtGdiCreateDIBSection(NULL, NULL, 0, pbmi, 0, cjHeader+4, 0, 0, NULL); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* Test ppvBits = NULL and cjHeader = 0 */ - SetLastError(0); - hbmp = NtGdiCreateDIBSection(0, NULL, 0, pbmi, 0, 0, 0, 0, NULL); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + SetLastError(0xDEADBEEF); + hbmp = NtGdiCreateDIBSection(NULL, NULL, 0, pbmi, 0, 0, 0, 0, NULL); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* Test wrong cjHeader */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader+4, 0, 0, &pvBits); pvBits = (PVOID)-1; - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* Test different bitcount */ pbih->biBitCount = 4; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(hbmp != 0); + TEST(hbmp != NULL); if (hbmp) DeleteObject(hbmp); pbih->biBitCount = 8; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(hbmp != 0); + TEST(hbmp != NULL); if (hbmp) DeleteObject(hbmp); cjHeader = pbih->biSize; pbih->biBitCount = 16; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(hbmp != 0); + TEST(hbmp != NULL); if (hbmp) DeleteObject(hbmp); pbih->biBitCount = 24; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(hbmp != 0); + TEST(hbmp != NULL); if (hbmp) DeleteObject(hbmp); pbih->biBitCount = 32; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(hbmp != 0); + TEST(hbmp != NULL); if (hbmp) DeleteObject(hbmp); /* Test BI_BITFIELDS */ @@ -210,31 +210,31 @@ ((DWORD*)pbmi->bmiColors)[1] = 0x0038; ((DWORD*)pbmi->bmiColors)[2] = 0x01C0; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(hbmp != 0); - TEST(GetObject(hbmp, sizeof(DIBSECTION), &dibsection) == sizeof(DIBSECTION)); - TEST(dibsection.dsBm.bmType == 0); - TEST(dibsection.dsBm.bmWidth == 2); - TEST(dibsection.dsBm.bmHeight == 2); - TEST(dibsection.dsBm.bmWidthBytes == 4); - TEST(dibsection.dsBm.bmPlanes == 1); - TEST(dibsection.dsBm.bmBitsPixel == 16); - TEST(dibsection.dsBm.bmBits == pvBits); - TEST(dibsection.dsBmih.biSize == sizeof(BITMAPINFOHEADER)); - TEST(dibsection.dsBmih.biWidth == 2); - TEST(dibsection.dsBmih.biHeight == 2); - TEST(dibsection.dsBmih.biPlanes == 1); - TEST(dibsection.dsBmih.biBitCount == 16); - TEST(dibsection.dsBmih.biCompression == BI_BITFIELDS); - TEST(dibsection.dsBmih.biSizeImage == 8); - TEST(dibsection.dsBmih.biXPelsPerMeter == 0); - TEST(dibsection.dsBmih.biYPelsPerMeter == 0); - TEST(dibsection.dsBmih.biClrUsed == 0); - TEST(dibsection.dsBmih.biClrImportant == 0); - TEST(dibsection.dsBitfields[0] == 0x0007); - TEST(dibsection.dsBitfields[1] == 0x0038); - TEST(dibsection.dsBitfields[2] == 0x01C0); - TEST(dibsection.dshSection == 0); - TEST(dibsection.dsOffset == 0); + TEST(hbmp != NULL); + ok_int(GetObject(hbmp, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION)); + ok_int(dibsection.dsBm.bmType, 0); + ok_int(dibsection.dsBm.bmWidth, 2); + ok_int(dibsection.dsBm.bmHeight, 2); + ok_int(dibsection.dsBm.bmWidthBytes, 4); + ok_int(dibsection.dsBm.bmPlanes, 1); + ok_int(dibsection.dsBm.bmBitsPixel, 16); + ok_ptr(dibsection.dsBm.bmBits, pvBits); + ok_int(dibsection.dsBmih.biSize, sizeof(BITMAPINFOHEADER)); + ok_int(dibsection.dsBmih.biWidth, 2); + ok_int(dibsection.dsBmih.biHeight, 2); + ok_int(dibsection.dsBmih.biPlanes, 1); + ok_int(dibsection.dsBmih.biBitCount, 16); + ok_int(dibsection.dsBmih.biCompression, BI_BITFIELDS); + ok_int(dibsection.dsBmih.biSizeImage, 8); + ok_int(dibsection.dsBmih.biXPelsPerMeter, 0); + ok_int(dibsection.dsBmih.biYPelsPerMeter, 0); + ok_int(dibsection.dsBmih.biClrUsed, 0); + ok_int(dibsection.dsBmih.biClrImportant, 0); + ok_int(dibsection.dsBitfields[0], 0x0007); + ok_int(dibsection.dsBitfields[1], 0x0038); + ok_int(dibsection.dsBitfields[2], 0x01C0); + ok_ptr(dibsection.dshSection, NULL); + ok_int(dibsection.dsOffset, 0); printf("dib with bitfileds: %p\n", hbmp); //system("PAUSE"); @@ -243,8 +243,8 @@ /* Test BI_BITFIELDS */ - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; pbih->biSize = sizeof(BITMAPINFOHEADER); pbih->biWidth = 2; @@ -273,12 +273,12 @@ cjHeader = bmi.bmiHeader.biSize + cEntries * 4 + 8; /* Test iUsage = 1 */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 1, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); @@ -286,12 +286,12 @@ /** iUsage = 2 (???) **********************************************************/ /* Test iUsage = 2 */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 2, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); @@ -301,72 +301,72 @@ cjHeader = bmi.bmiHeader.biSize + cEntries * 4 + 8; /* Test iUsage = 3 */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 3, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(ERROR_INVALID_PARAMETER); if (hbmp) DeleteObject(hbmp); /* Test iUsage = 3 */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 3, cjHeader+4, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* Test wrong iUsage */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, -55, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(ERROR_INVALID_PARAMETER); if (hbmp) DeleteObject(hbmp); /* Test wrong iUsage and wrong cjHeader */ - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, -55, cjHeader+4, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* increased header size */ pbih->biSize = sizeof(BITMAPINFOHEADER) + 4; cjHeader = pbih->biSize + cEntries * 4 + 8; - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); - TEST(GetLastError() == 8); + TEST(hbmp != NULL); + ok_err(ERROR_NOT_ENOUGH_MEMORY); if (hbmp) DeleteObject(hbmp); /* increased header size */ pbih->biSize = sizeof(BITMAPINFOHEADER) + 2; cjHeader = pbih->biSize + cEntries * 4 + 8; - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); /* decreased header size */ pbih->biSize = sizeof(BITMAPINFOHEADER) - 4; cjHeader = pbih->biSize + cEntries * 4 + 8; - SetLastError(0); + SetLastError(0xDEADBEEF); pvBits = (PVOID)-1; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); - TEST(pvBits == (PVOID)-1); - TEST(hbmp == 0); - TEST(GetLastError() == 0); + ok_ptr(pvBits, (PVOID)-1); + ok_ptr(hbmp, NULL); + ok_err(0xDEADBEEF); if (hbmp) DeleteObject(hbmp); @@ -397,12 +397,12 @@ cjHeader = bmi.bmiHeader.biSize + cEntries * 4 + 8; /* Test something simple */ - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); - TEST(GetLastError() == 8); + TEST(hbmp != NULL); + ok_err(ERROR_NOT_ENOUGH_MEMORY); if (hbmp) DeleteObject(hbmp); @@ -437,23 +437,23 @@ cjHeader = pbV5h->bV5Size + cEntries * 4 + 8; /* Test something simple */ - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); - TEST(GetLastError() == 8); + TEST(hbmp != NULL); + ok_err(ERROR_NOT_ENOUGH_MEMORY); if (hbmp) DeleteObject(hbmp); /* increased header size */ pbV5h->bV5Size = sizeof(BITMAPV5HEADER) + 64; cjHeader = pbV5h->bV5Size + cEntries * 4 + 8; - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection(hDC, NULL, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); - TEST(GetLastError() == 8); + TEST(hbmp != NULL); + ok_err(ERROR_NOT_ENOUGH_MEMORY); if (hbmp) DeleteObject(hbmp); /* Test section */ @@ -467,12 +467,12 @@ NULL); ASSERT(NT_SUCCESS(Status)); - SetLastError(0); - pvBits = 0; + SetLastError(0xDEADBEEF); + pvBits = NULL; hbmp = NtGdiCreateDIBSection(hDC, hSection, 0, pbmi, 0, cjHeader, 0, 0, &pvBits); TEST(pvBits != NULL); - TEST(hbmp != 0); -// TEST(GetLastError() == 0); + TEST(hbmp != NULL); +// ok_err(0xDEADBEEF); printf("hbmp = %p, pvBits = %p, hSection = %p\n", hbmp, pvBits, hSection); //system("PAUSE"); if (hbmp) DeleteObject(hbmp);