From f886d23efce9107663587d1b72ddca23c03c74ea Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 13 Oct 2011 12:52:25 +0000 Subject: [PATCH] [GDI32_APITEST] - Add tests for CreateDIBitmap - more tests for AddFontResource, GetPixel, SetSysColors svn path=/trunk/; revision=54106 --- rostests/apitests/gdi32/AddFontResource.c | 30 +++++++++ rostests/apitests/gdi32/CMakeLists.txt | 1 + rostests/apitests/gdi32/CreateDIBitmap.c | 77 +++++++++++++++++++++++ rostests/apitests/gdi32/GetPixel.c | 7 +++ rostests/apitests/gdi32/SetSysColors.c | 10 +-- rostests/apitests/gdi32/testlist.c | 2 + 6 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 rostests/apitests/gdi32/CreateDIBitmap.c diff --git a/rostests/apitests/gdi32/AddFontResource.c b/rostests/apitests/gdi32/AddFontResource.c index b69f4d69d22..236da3f351a 100644 --- a/rostests/apitests/gdi32/AddFontResource.c +++ b/rostests/apitests/gdi32/AddFontResource.c @@ -87,6 +87,36 @@ void Test_AddFontResourceA() result = AddFontResourceA(szFileNameA); ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); + + + GetCurrentDirectoryA(MAX_PATH, szFileNameA); + strcpy(szFileNameFont1A, szFileNameA); + strcat(szFileNameFont1A, "\\testdata\\test.pfm"); + + strcpy(szFileNameFont2A, szFileNameA); + strcat(szFileNameFont2A, "\\testdata\\test.pfb"); + + SetLastError(ERROR_SUCCESS); + + sprintf(szFileNameA,"%s|%s", szFileNameFont1A, szFileNameFont2A); + result = AddFontResourceA(szFileNameA); + ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n", + szFileNameFont1A, szFileNameFont2A, result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + sprintf(szFileNameA,"%s | %s", szFileNameFont1A, szFileNameFont2A); + result = AddFontResourceA(szFileNameA); + ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n", + szFileNameFont1A, szFileNameFont2A, result); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); + + sprintf(szFileNameA,"%s|%s", szFileNameFont2A, szFileNameFont1A); + result = AddFontResourceA(szFileNameA); + ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n", + szFileNameFont2A, szFileNameFont1A, result); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); + + } START_TEST(AddFontResource) diff --git a/rostests/apitests/gdi32/CMakeLists.txt b/rostests/apitests/gdi32/CMakeLists.txt index fed614cc118..adda045ff80 100644 --- a/rostests/apitests/gdi32/CMakeLists.txt +++ b/rostests/apitests/gdi32/CMakeLists.txt @@ -8,6 +8,7 @@ list(APPEND SOURCE CombineTransform.c CreateBitmapIndirect.c CreateCompatibleDC.c + CreateDIBitmap.c CreateFont.c CreateFontIndirect.c CreatePen.c diff --git a/rostests/apitests/gdi32/CreateDIBitmap.c b/rostests/apitests/gdi32/CreateDIBitmap.c new file mode 100644 index 00000000000..3da8b676fd7 --- /dev/null +++ b/rostests/apitests/gdi32/CreateDIBitmap.c @@ -0,0 +1,77 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreateDIBitmap + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void +Test_CreateDIBitmap1(void) +{ + BITMAPINFO bmi; + HBITMAP hbmp; + BITMAP bitmap; + ULONG bits[128] = {0}; + BYTE rlebits[] = {2, 0, 0, 0, 2, 1, 0, 1}; + HDC hdc; + int ret; + + hdc = GetDC(0); + + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = 2; + bmi.bmiHeader.biHeight = 2; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 16; + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biSizeImage = 0; + bmi.bmiHeader.biXPelsPerMeter = 1; + bmi.bmiHeader.biYPelsPerMeter = 1; + bmi.bmiHeader.biClrUsed = 0; + bmi.bmiHeader.biClrImportant = 0; + + hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, bits, &bmi, DIB_RGB_COLORS); + ok(hbmp != 0, "failed\n"); + + ret = GetObject(hbmp, sizeof(bitmap), &bitmap); + ok(ret != 0, "failed\n"); + ok(bitmap.bmType == 0, "\n"); + ok(bitmap.bmWidth == 2, "\n"); + ok(bitmap.bmHeight == 2, "\n"); + ok(bitmap.bmWidthBytes == 8, "bmWidthBytes = %ld\n", bitmap.bmWidthBytes); + ok(bitmap.bmPlanes == 1, "\n"); + ok(bitmap.bmBitsPixel == GetDeviceCaps(hdc, BITSPIXEL), "\n"); + ok(bitmap.bmBits == 0, "\n"); + + SetLastError(0); + bmi.bmiHeader.biCompression = BI_RLE8; + bmi.bmiHeader.biBitCount = 8; + bmi.bmiHeader.biSizeImage = 8; + hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, rlebits, &bmi, DIB_RGB_COLORS); + ok(hbmp != 0, "failed\n"); + ok(GetLastError() == 0, "GetLastError() == %ld\n", GetLastError()); + + ret = GetObject(hbmp, sizeof(bitmap), &bitmap); + ok(ret != 0, "failed\n"); + ok(bitmap.bmType == 0, "\n"); + ok(bitmap.bmWidth == 2, "\n"); + ok(bitmap.bmHeight == 2, "\n"); + ok(bitmap.bmWidthBytes == 8, "bmWidthBytes = %ld\n", bitmap.bmWidthBytes); + ok(bitmap.bmPlanes == 1, "\n"); + ok(bitmap.bmBitsPixel == GetDeviceCaps(hdc, BITSPIXEL), "\n"); + ok(bitmap.bmBits == 0, "\n"); + + +} + + + +START_TEST(CreateDIBitmap) +{ + Test_CreateDIBitmap1(); +} + diff --git a/rostests/apitests/gdi32/GetPixel.c b/rostests/apitests/gdi32/GetPixel.c index 739be912d3a..27dcd431af5 100644 --- a/rostests/apitests/gdi32/GetPixel.c +++ b/rostests/apitests/gdi32/GetPixel.c @@ -28,6 +28,13 @@ void Test_GetPixel_1bpp() color = GetPixel(hdc, 1, 0); ok(color == 0, "Wrong color at 1,0 : 0x%08x\n", (UINT)color); + SetBkColor(hdc, 0x12345678); + SetTextColor(hdc, 0x87654321); + color = GetPixel(hdc, 0, 0); + ok(color == 0xFFFFFF, "Wrong color at 0,0 : 0x%08x\n", (UINT)color); + color = GetPixel(hdc, 1, 0); + ok(color == 0, "Wrong color at 1,0 : 0x%08x\n", (UINT)color); + hbmp = SelectObject(hdc, hbmp); DeleteObject(hbmp); DeleteDC(hdc); diff --git a/rostests/apitests/gdi32/SetSysColors.c b/rostests/apitests/gdi32/SetSysColors.c index 26a71854414..6be405cc233 100644 --- a/rostests/apitests/gdi32/SetSysColors.c +++ b/rostests/apitests/gdi32/SetSysColors.c @@ -26,21 +26,21 @@ void Test_SetSysColors() nElements[i] = i; crOldColors[i] = GetSysColor(i); } - + for (i = 0; i < NUM_SYSCOLORS+1; i++) crColors[i] = RGB(i, 255-i, i*3); nElements[NUM_SYSCOLORS] = nElements[0]; - + SetLastError(0xdeadbeef); ok(SetSysColors(-1, nElements, crColors) == FALSE, "Expected FALSE, got TRUE\n"); - ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError()); ok(SetSysColors(0, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n"); ok(SetSysColors(0, NULL, crColors) == TRUE, "Expected TRUE, got FALSE\n"); ok(SetSysColors(0, nElements, NULL) == TRUE, "Expected TRUE, got FALSE\n"); ok(SetSysColors(1, NULL, crColors) == FALSE, "Expected FALSE, got TRUE\n"); - ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError()); ok(SetSysColors(1, nElements, NULL) == FALSE, "Expected FALSE, got TRUE\n"); - ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %ld\n", GetLastError()); ok(SetSysColors(1, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n"); ok(SetSysColors(NUM_SYSCOLORS, nElements, crColors) == TRUE, "Expected TRUE, got FALSE\n"); for (i = 0; i < NUM_SYSCOLORS; i++) diff --git a/rostests/apitests/gdi32/testlist.c b/rostests/apitests/gdi32/testlist.c index dfcb82ce054..ec08618639b 100644 --- a/rostests/apitests/gdi32/testlist.c +++ b/rostests/apitests/gdi32/testlist.c @@ -11,6 +11,7 @@ extern void func_BeginPath(void); extern void func_CombineTransform(void); extern void func_CreateBitmapIndirect(void); extern void func_CreateCompatibleDC(void); +extern void func_CreateDIBitmap(void); extern void func_CreateFont(void); extern void func_CreateFontIndirect(void); extern void func_CreatePen(void); @@ -59,6 +60,7 @@ const struct test winetest_testlist[] = { "CombineTransform", func_CombineTransform }, { "CreateBitmapIndirect", func_CreateBitmapIndirect }, { "CreateCompatibleDC", func_CreateCompatibleDC }, + { "CreateDIBitmap", func_CreateDIBitmap }, { "CreateFont", func_CreateFont }, { "CreateFontIndirect", func_CreateFontIndirect }, { "CreatePen", func_CreatePen },