mirror of
https://github.com/reactos/reactos.git
synced 2025-06-03 16:30:26 +00:00
[GDI32_APITEST]
More testcases for SelectObject and GetDIBits svn path=/trunk/; revision=50929
This commit is contained in:
parent
5de8339cd1
commit
27b33c3045
2 changed files with 253 additions and 137 deletions
|
@ -9,93 +9,161 @@
|
||||||
#include <wine/test.h>
|
#include <wine/test.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define TEST(x) ok(x, #x"\n")
|
#define ok_err(dwErr) ok(GetLastError() == dwErr, "LastError is wrong, expected %d, got %ld\n", dwErr, GetLastError())
|
||||||
#define RTEST(x) ok(x, #x"\n")
|
|
||||||
|
|
||||||
void Test_GetDIBits()
|
void Test_GetDIBits()
|
||||||
{
|
{
|
||||||
HDC hDCScreen;
|
HDC hdcScreen, hdcMem;
|
||||||
HBITMAP hBitmap;
|
HBITMAP hbmp;
|
||||||
BITMAPINFO bi;
|
PBITMAPINFO pbi;
|
||||||
INT ScreenBpp;
|
INT ret, ScreenBpp;
|
||||||
|
DWORD ajBits[10] = {0xff, 0x00, 0xcc, 0xf0, 0x0f};
|
||||||
|
|
||||||
hDCScreen = GetDC(NULL);
|
pbi = malloc(sizeof(BITMAPV5HEADER) + 256 * sizeof(DWORD));
|
||||||
ok(hDCScreen != 0, "GetDC failed, skipping tests\n");
|
|
||||||
if (hDCScreen == NULL) return;
|
|
||||||
|
|
||||||
hBitmap = CreateCompatibleBitmap(hDCScreen, 16, 16);
|
hdcScreen = GetDC(NULL);
|
||||||
RTEST(hBitmap != NULL);
|
ok(hdcScreen != 0, "GetDC failed, skipping tests\n");
|
||||||
|
if (hdcScreen == NULL) return;
|
||||||
|
|
||||||
|
hdcMem = CreateCompatibleDC(0);
|
||||||
|
ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
|
||||||
|
if (hdcMem == NULL) return;
|
||||||
|
|
||||||
|
hbmp = CreateCompatibleBitmap(hdcScreen, 16, 16);
|
||||||
|
ok(hbmp != NULL, "CreateCompatibleBitmap failed\n");
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
RTEST(GetDIBits(0, 0, 0, 0, NULL, NULL, 0) == 0);
|
ok(GetDIBits(0, 0, 0, 0, NULL, NULL, 0) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
ok_err(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
RTEST(GetDIBits((HDC)2345, 0, 0, 0, NULL, NULL, 0) == 0);
|
ok(GetDIBits((HDC)2345, 0, 0, 0, NULL, NULL, 0) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
ok_err(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
RTEST(GetDIBits((HDC)2345, hBitmap, 0, 0, NULL, NULL, 0) == 0);
|
ok(GetDIBits((HDC)2345, hbmp, 0, 0, NULL, NULL, 0) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
ok_err(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
RTEST(GetDIBits((HDC)2345, hBitmap, 0, 15, NULL, &bi, 0) == 0);
|
ok(GetDIBits((HDC)2345, hbmp, 0, 15, NULL, pbi, 0) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
ok_err(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* null hdc */
|
/* null hdc */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ZeroMemory(&bi, sizeof(BITMAPINFO));
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
RTEST(GetDIBits(NULL, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS) == 0);
|
ok(GetDIBits(NULL, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
ok_err(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
/* null bitmap */
|
/* null bitmap */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ZeroMemory(&bi, sizeof(BITMAPINFO));
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
RTEST(GetDIBits(hDCScreen, NULL, 0, 15, NULL, &bi, DIB_RGB_COLORS) == 0);
|
ok(GetDIBits(hdcScreen, NULL, 0, 15, NULL, pbi, DIB_RGB_COLORS) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
|
|
||||||
/* 0 scan lines */
|
/* 0 scan lines */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ZeroMemory(&bi, sizeof(BITMAPINFO));
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
RTEST(GetDIBits(hDCScreen, hBitmap, 0, 0, NULL, &bi, DIB_RGB_COLORS) > 0);
|
ok(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS) > 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
|
|
||||||
/* null bitmap info - crashes XP*/
|
/* null bitmap info - crashes XP*/
|
||||||
//SetLastError(ERROR_SUCCESS);
|
//SetLastError(ERROR_SUCCESS);
|
||||||
//RTEST(GetDIBits(hDCScreen, NULL, 0, 15, NULL, NULL, DIB_RGB_COLORS) == 0);
|
//ok(GetDIBits(hdcScreen, NULL, 0, 15, NULL, NULL, DIB_RGB_COLORS) == 0);
|
||||||
//RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
//ok(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
/* bad bmi colours (uUsage) */
|
/* bad bmi colours (uUsage) */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ZeroMemory(&bi, sizeof(BITMAPINFO));
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
RTEST(GetDIBits(hDCScreen, hBitmap, 0, 15, NULL, &bi, 100) == 0);
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, 100) == 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
RTEST(bi.bmiHeader.biWidth == 0);
|
ok(pbi->bmiHeader.biWidth == 0, "\n");
|
||||||
RTEST(bi.bmiHeader.biHeight == 0);
|
ok(pbi->bmiHeader.biHeight == 0, "\n");
|
||||||
RTEST(bi.bmiHeader.biBitCount == 0);
|
ok(pbi->bmiHeader.biBitCount == 0, "\n");
|
||||||
RTEST(bi.bmiHeader.biSizeImage == 0);
|
ok(pbi->bmiHeader.biSizeImage == 0, "\n");
|
||||||
|
|
||||||
/* basic call */
|
/* basic call */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ZeroMemory(&bi, sizeof(BITMAPINFO));
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
RTEST(GetDIBits(hDCScreen, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS) > 0);
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) > 0, "\n");
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL);
|
ScreenBpp = GetDeviceCaps(hdcScreen, BITSPIXEL);
|
||||||
RTEST(bi.bmiHeader.biWidth == 16);
|
ok(pbi->bmiHeader.biWidth == 16, "\n");
|
||||||
RTEST(bi.bmiHeader.biHeight == 16);
|
ok(pbi->bmiHeader.biHeight == 16, "\n");
|
||||||
RTEST(bi.bmiHeader.biBitCount == ScreenBpp);
|
ok(pbi->bmiHeader.biBitCount == ScreenBpp, "\n");
|
||||||
RTEST(bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8));
|
ok(pbi->bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8), "\n");
|
||||||
|
|
||||||
DeleteObject(hBitmap);
|
/* Test if COREHEADER is supported */
|
||||||
ReleaseDC(NULL, hDCScreen);
|
pbi->bmiHeader.biSize = sizeof(BITMAPCOREHEADER);
|
||||||
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) > 0, "\n");
|
||||||
|
ok(pbi->bmiHeader.biSize == sizeof(BITMAPCOREHEADER), "\n");
|
||||||
|
|
||||||
|
/* Test different header sizes */
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPCOREHEADER) + 4;
|
||||||
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) == 0, "should fail.\n");
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + 4;
|
||||||
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) == 0, "should fail.\n");
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPV5HEADER);
|
||||||
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) > 0, "should not fail.\n");
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPV5HEADER) + 4;
|
||||||
|
ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) > 0, "should not fail.\n");
|
||||||
|
|
||||||
|
|
||||||
|
DeleteObject(hbmp);
|
||||||
|
|
||||||
|
/* Test a mono bitmap */
|
||||||
|
hbmp = CreateBitmap(13, 7, 1, 1, ajBits);
|
||||||
|
ok(hbmp != 0, "failed to create bitmap\n");
|
||||||
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
ret = GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS);
|
||||||
|
ok(ret == 1, "%d\n", ret);
|
||||||
|
ok(pbi->bmiHeader.biWidth == 13, "pbi->bmiHeader.biWidth = %ld\n", pbi->bmiHeader.biWidth);
|
||||||
|
ok(pbi->bmiHeader.biHeight == 7, "pbi->bmiHeader.biHeight = %ld\n", pbi->bmiHeader.biHeight);
|
||||||
|
ok(pbi->bmiHeader.biBitCount == 1, "pbi->bmiHeader.biBitCount = %d\n", pbi->bmiHeader.biBitCount);
|
||||||
|
ok(pbi->bmiHeader.biSizeImage == 28, "pbi->bmiHeader.biSizeImage = %ld\n", pbi->bmiHeader.biSizeImage);
|
||||||
|
|
||||||
|
/* Test a mono bitmap with values set */
|
||||||
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
pbi->bmiHeader.biWidth = 12;
|
||||||
|
pbi->bmiHeader.biHeight = 9;
|
||||||
|
pbi->bmiHeader.biPlanes = 1;
|
||||||
|
pbi->bmiHeader.biBitCount = 32;
|
||||||
|
pbi->bmiHeader.biCompression = BI_RGB;
|
||||||
|
pbi->bmiHeader.biSizeImage = 123;
|
||||||
|
ret = GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS);
|
||||||
|
ok(ret == 1, "%d\n", ret);
|
||||||
|
ok(pbi->bmiHeader.biWidth == 12, "pbi->bmiHeader.biWidth = %ld\n", pbi->bmiHeader.biWidth);
|
||||||
|
ok(pbi->bmiHeader.biHeight == 9, "pbi->bmiHeader.biHeight = %ld\n", pbi->bmiHeader.biHeight);
|
||||||
|
ok(pbi->bmiHeader.biBitCount == 32, "pbi->bmiHeader.biBitCount = %d\n", pbi->bmiHeader.biBitCount);
|
||||||
|
ok(pbi->bmiHeader.biSizeImage == 432, "pbi->bmiHeader.biSizeImage = %ld\n", pbi->bmiHeader.biSizeImage);
|
||||||
|
|
||||||
|
/* Set individual values */
|
||||||
|
ZeroMemory(pbi, sizeof(BITMAPINFO));
|
||||||
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
pbi->bmiHeader.biWidth = 12;
|
||||||
|
ret = GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS);
|
||||||
|
ok(ret == 1, "%d\n", ret);
|
||||||
|
pbi->bmiHeader.biWidth = 0;
|
||||||
|
pbi->bmiHeader.biSizeImage = 123;
|
||||||
|
ret = GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS);
|
||||||
|
ok(ret == 0, "%d\n", ret);
|
||||||
|
pbi->bmiHeader.biSizeImage = 0;
|
||||||
|
pbi->bmiHeader.biCompression = BI_RGB;
|
||||||
|
ret = GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS);
|
||||||
|
ok(ret == 0, "%d\n", ret);
|
||||||
|
|
||||||
|
DeleteObject(hbmp);
|
||||||
|
DeleteDC(hdcMem);
|
||||||
|
ReleaseDC(NULL, hdcScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(GetDIBits)
|
START_TEST(GetDIBits)
|
||||||
|
|
|
@ -15,24 +15,20 @@
|
||||||
#define TEST(x) ok(x, #x"\n")
|
#define TEST(x) ok(x, #x"\n")
|
||||||
#define RTEST(x) ok(x, #x"\n")
|
#define RTEST(x) ok(x, #x"\n")
|
||||||
|
|
||||||
void Test_SelectObject()
|
#define ok_err(dwErr) ok(GetLastError() == dwErr, "Wrong LastError, expected %d, got %ld\n", dwErr, GetLastError())
|
||||||
|
|
||||||
|
HDC hdc1, hdc2;
|
||||||
|
|
||||||
|
static void
|
||||||
|
Test_SelectObject()
|
||||||
{
|
{
|
||||||
HGDIOBJ hOldObj, hNewObj;
|
HGDIOBJ hOldObj, hNewObj;
|
||||||
HDC hScreenDC, hDC, hDC2;
|
|
||||||
// PGDI_TABLE_ENTRY pEntry;
|
// PGDI_TABLE_ENTRY pEntry;
|
||||||
// PDC_ATTR pDc_Attr;
|
// PDC_ATTR pDc_Attr;
|
||||||
// HANDLE hcmXform;
|
// HANDLE hcmXform;
|
||||||
BYTE bmBits[4] = {0};
|
|
||||||
|
|
||||||
hScreenDC = GetDC(NULL);
|
|
||||||
ok(hScreenDC != NULL, "GetDC failed. Skipping tests.\n");
|
|
||||||
if (hScreenDC == NULL) return;
|
|
||||||
hDC = CreateCompatibleDC(hScreenDC);
|
|
||||||
ok(hDC != NULL, "CreateCompatibleDC failed. Skipping tests.\n");
|
|
||||||
if (hDC == NULL) return;
|
|
||||||
|
|
||||||
/* Get the Dc_Attr for later testing */
|
/* Get the Dc_Attr for later testing */
|
||||||
// pEntry = &GdiHandleTable[GDI_HANDLE_GET_INDEX(hDC)];
|
// pEntry = &GdiHandleTable[GDI_HANDLE_GET_INDEX(hdc1)];
|
||||||
// pDc_Attr = pEntry->UserData;
|
// pDc_Attr = pEntry->UserData;
|
||||||
// ok(pDc_Attr != NULL, "Skipping tests.\n");
|
// ok(pDc_Attr != NULL, "Skipping tests.\n");
|
||||||
// if (pDc_Attr == NULL) return;
|
// if (pDc_Attr == NULL) return;
|
||||||
|
@ -40,27 +36,27 @@ void Test_SelectObject()
|
||||||
/* Test incomplete dc handle doesn't work */
|
/* Test incomplete dc handle doesn't work */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
hNewObj = GetStockObject(GRAY_BRUSH);
|
hNewObj = GetStockObject(GRAY_BRUSH);
|
||||||
hOldObj = SelectObject((HDC)GDI_HANDLE_GET_INDEX(hDC), hNewObj);
|
hOldObj = SelectObject((HDC)GDI_HANDLE_GET_INDEX(hdc1), hNewObj);
|
||||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
ok_err(ERROR_INVALID_HANDLE);
|
||||||
RTEST(hOldObj == NULL);
|
ok(hOldObj == NULL, "\n");
|
||||||
// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
|
// ok(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH), "\n");
|
||||||
SelectObject(hDC, hOldObj);
|
SelectObject(hdc1, hOldObj);
|
||||||
|
|
||||||
/* Test incomplete hobj handle works */
|
/* Test incomplete hobj handle works */
|
||||||
hNewObj = GetStockObject(GRAY_BRUSH);
|
hNewObj = GetStockObject(GRAY_BRUSH);
|
||||||
hOldObj = SelectObject(hDC, (HGDIOBJ)GDI_HANDLE_GET_INDEX(hNewObj));
|
hOldObj = SelectObject(hdc1, (HGDIOBJ)GDI_HANDLE_GET_INDEX(hNewObj));
|
||||||
RTEST(hOldObj == GetStockObject(WHITE_BRUSH));
|
ok(hOldObj == GetStockObject(WHITE_BRUSH), "\n");
|
||||||
// RTEST(pDc_Attr->hbrush == hNewObj);
|
// ok(pDc_Attr->hbrush == hNewObj, "\n");
|
||||||
SelectObject(hDC, hOldObj);
|
SelectObject(hdc1, hOldObj);
|
||||||
|
|
||||||
/* Test wrong hDC handle type */
|
/* Test wrong hDC handle type */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
hNewObj = GetStockObject(GRAY_BRUSH);
|
hNewObj = GetStockObject(GRAY_BRUSH);
|
||||||
hDC2 = (HDC)((UINT_PTR)hDC & ~GDI_HANDLE_TYPE_MASK);
|
hdc2 = (HDC)((UINT_PTR)hdc1 & ~GDI_HANDLE_TYPE_MASK);
|
||||||
hDC2 = (HDC)((UINT_PTR)hDC2 | GDI_OBJECT_TYPE_PEN);
|
hdc2 = (HDC)((UINT_PTR)hdc2 | GDI_OBJECT_TYPE_PEN);
|
||||||
hOldObj = SelectObject(hDC2, hNewObj);
|
hOldObj = SelectObject(hdc2, hNewObj);
|
||||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
ok_err(ERROR_INVALID_HANDLE);
|
||||||
RTEST(hOldObj == NULL);
|
ok(hOldObj == NULL, "\n");
|
||||||
// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
|
// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
/* Test wrong hobj handle type */
|
/* Test wrong hobj handle type */
|
||||||
|
@ -68,57 +64,24 @@ void Test_SelectObject()
|
||||||
hNewObj = GetStockObject(GRAY_BRUSH);
|
hNewObj = GetStockObject(GRAY_BRUSH);
|
||||||
hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj & ~GDI_HANDLE_TYPE_MASK);
|
hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj & ~GDI_HANDLE_TYPE_MASK);
|
||||||
hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj | GDI_OBJECT_TYPE_PEN);
|
hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj | GDI_OBJECT_TYPE_PEN);
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
hOldObj = SelectObject(hdc1, hNewObj);
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
RTEST(hOldObj == NULL);
|
ok(hOldObj == NULL, "\n");
|
||||||
// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
|
// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
hNewObj = (HGDIOBJ)0x00761234;
|
hNewObj = (HGDIOBJ)0x00761234;
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
hOldObj = SelectObject(hdc1, hNewObj);
|
||||||
RTEST(hOldObj == NULL);
|
ok(hOldObj == NULL, "\n");
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
SelectObject(hDC, hOldObj);
|
SelectObject(hdc1, hOldObj);
|
||||||
|
|
||||||
/* Test DC */
|
/* Test DC */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
hOldObj = SelectObject(hDC, hScreenDC);
|
hOldObj = SelectObject(hdc1, GetDC(NULL));
|
||||||
RTEST(hOldObj == NULL);
|
ok(hOldObj == NULL, "\n");
|
||||||
TEST(GetLastError() == ERROR_SUCCESS);
|
ok_err(ERROR_SUCCESS);
|
||||||
|
|
||||||
/* Test REGION */
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
|
||||||
hNewObj = CreateRectRgn(0,0,0,0);
|
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
|
||||||
RTEST((UINT_PTR)hOldObj == NULLREGION);
|
|
||||||
DeleteObject(hNewObj);
|
|
||||||
|
|
||||||
hNewObj = CreateRectRgn(0,0,10,10);
|
|
||||||
RTEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION);
|
|
||||||
hOldObj = CreateRectRgn(5,5,20,20);
|
|
||||||
RTEST(CombineRgn(hNewObj, hNewObj, hOldObj, RGN_OR) == COMPLEXREGION);
|
|
||||||
DeleteObject(hOldObj);
|
|
||||||
RTEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION); // ??? Why this?
|
|
||||||
DeleteObject(hNewObj);
|
|
||||||
// TEST(IsHandleValid(hNewObj) == TRUE);
|
|
||||||
|
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
|
||||||
|
|
||||||
/* Test BITMAP */
|
|
||||||
hNewObj = CreateBitmap(2, 2, 1, 1, &bmBits);
|
|
||||||
ok(hNewObj != NULL, "CreateBitmap failed. Skipping tests.\n");
|
|
||||||
if (hNewObj == NULL) return;
|
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
|
||||||
RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BITMAP);
|
|
||||||
hOldObj = SelectObject(hDC, hOldObj);
|
|
||||||
RTEST(hOldObj == hNewObj);
|
|
||||||
|
|
||||||
/* Test invalid BITMAP */
|
|
||||||
hNewObj = CreateBitmap(2, 2, 1, 4, &bmBits);
|
|
||||||
ok(hNewObj != NULL, "CreateBitmap failed. Skipping tests.\n");
|
|
||||||
if (hNewObj == NULL) return;
|
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
|
||||||
ok(hOldObj == NULL, "should fail\n");
|
|
||||||
|
|
||||||
/* Test CLIOBJ */
|
/* Test CLIOBJ */
|
||||||
|
|
||||||
|
@ -127,9 +90,9 @@ void Test_SelectObject()
|
||||||
/* Test PALETTE */
|
/* Test PALETTE */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
hNewObj = GetStockObject(DEFAULT_PALETTE);
|
hNewObj = GetStockObject(DEFAULT_PALETTE);
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
hOldObj = SelectObject(hdc1, hNewObj);
|
||||||
RTEST(hOldObj == NULL);
|
RTEST(hOldObj == NULL);
|
||||||
RTEST(GetLastError() == ERROR_INVALID_FUNCTION);
|
ok_err(ERROR_INVALID_FUNCTION);
|
||||||
|
|
||||||
/* Test COLORSPACE */
|
/* Test COLORSPACE */
|
||||||
|
|
||||||
|
@ -139,17 +102,17 @@ void Test_SelectObject()
|
||||||
|
|
||||||
/* Test BRUSH */
|
/* Test BRUSH */
|
||||||
hNewObj = GetStockObject(GRAY_BRUSH);
|
hNewObj = GetStockObject(GRAY_BRUSH);
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
hOldObj = SelectObject(hdc1, hNewObj);
|
||||||
RTEST(hOldObj == GetStockObject(WHITE_BRUSH));
|
RTEST(hOldObj == GetStockObject(WHITE_BRUSH));
|
||||||
// RTEST(pDc_Attr->hbrush == hNewObj);
|
// RTEST(pDc_Attr->hbrush == hNewObj);
|
||||||
RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
|
RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
|
||||||
SelectObject(hDC, hOldObj);
|
SelectObject(hdc1, hOldObj);
|
||||||
|
|
||||||
/* Test DC_BRUSH */
|
/* Test DC_BRUSH */
|
||||||
hNewObj = GetStockObject(DC_BRUSH);
|
hNewObj = GetStockObject(DC_BRUSH);
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
hOldObj = SelectObject(hdc1, hNewObj);
|
||||||
// RTEST(pDc_Attr->hbrush == hNewObj);
|
// RTEST(pDc_Attr->hbrush == hNewObj);
|
||||||
SelectObject(hDC, hOldObj);
|
SelectObject(hdc1, hOldObj);
|
||||||
|
|
||||||
/* Test BRUSH color xform */
|
/* Test BRUSH color xform */
|
||||||
// hcmXform = (HANDLE)pDc_Attr->hcmXform;
|
// hcmXform = (HANDLE)pDc_Attr->hcmXform;
|
||||||
|
@ -161,22 +124,107 @@ void Test_SelectObject()
|
||||||
|
|
||||||
/* Test ENHMETAFILE */
|
/* Test ENHMETAFILE */
|
||||||
|
|
||||||
/* Test PEN */
|
|
||||||
hNewObj = GetStockObject(GRAY_BRUSH);
|
|
||||||
hOldObj = SelectObject(hDC, hNewObj);
|
|
||||||
RTEST(hOldObj == GetStockObject(WHITE_BRUSH));
|
|
||||||
// RTEST(pDc_Attr->hbrush == hNewObj);
|
|
||||||
RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
|
|
||||||
SelectObject(hDC, hOldObj);
|
|
||||||
|
|
||||||
|
|
||||||
/* Test EXTPEN */
|
/* Test EXTPEN */
|
||||||
|
|
||||||
/* Test METADC */
|
/* Test METADC */
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(SelectObject)
|
static void
|
||||||
|
Test_Bitmap()
|
||||||
{
|
{
|
||||||
Test_SelectObject();
|
HBITMAP hbmp, hbmpInvalid, hbmpOld;
|
||||||
|
BYTE bmBits[4] = {0};
|
||||||
|
HDC hdcTmp;
|
||||||
|
|
||||||
|
hbmp = CreateBitmap(2, 2, 1, 1, &bmBits);
|
||||||
|
hbmpInvalid = CreateBitmap(2, 2, 1, 4, &bmBits);
|
||||||
|
if (!hbmp || !hbmpInvalid)
|
||||||
|
{
|
||||||
|
printf("couldn't create bitmaps, skipping\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hbmpOld = SelectObject(hdc1, hbmp);
|
||||||
|
ok(GDI_HANDLE_GET_TYPE(hbmpOld) == GDI_OBJECT_TYPE_BITMAP, "wrong type\n");
|
||||||
|
|
||||||
|
/* Test invalid BITMAP */
|
||||||
|
ok(SelectObject(hdc1, hbmpInvalid) == NULL, "should fail\n");
|
||||||
|
|
||||||
|
/* Test if we get the right bitmap back */
|
||||||
|
hbmpOld = SelectObject(hdc1, hbmpOld);
|
||||||
|
ok(hbmpOld == hbmp, "didn't get the right bitmap back.\n");
|
||||||
|
|
||||||
|
/* Test selecting bitmap into 2 DCs */
|
||||||
|
hbmpOld = SelectObject(hdc1, hbmp);
|
||||||
|
ok(SelectObject(hdc2, hbmp) == NULL, "Should fail.\n");
|
||||||
|
|
||||||
|
/* Test selecting same bitmap twice */
|
||||||
|
hbmpOld = SelectObject(hdc1, hbmp);
|
||||||
|
ok(hbmpOld == hbmp, "didn't get the right bitmap back.\n");
|
||||||
|
SelectObject(hdc1, GetStockObject(DEFAULT_BITMAP));
|
||||||
|
|
||||||
|
/* Test selecting and then deleting the DC */
|
||||||
|
hdcTmp = CreateCompatibleDC(NULL);
|
||||||
|
hbmpOld = SelectObject(hdcTmp, hbmp);
|
||||||
|
ok(hbmpOld == GetStockObject(DEFAULT_BITMAP), "didn't get the right bitmap back.\n");
|
||||||
|
DeleteDC(hdcTmp);
|
||||||
|
hbmpOld = SelectObject(hdc1, hbmp);
|
||||||
|
ok(hbmpOld == GetStockObject(DEFAULT_BITMAP), "didn't get the right bitmap back.\n");
|
||||||
|
|
||||||
|
DeleteObject(hbmp);
|
||||||
|
DeleteObject(hbmpInvalid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Test_Pen()
|
||||||
|
{
|
||||||
|
HPEN hpen, hpenOld;
|
||||||
|
|
||||||
|
/* Test PEN */
|
||||||
|
hpen = GetStockObject(GRAY_BRUSH);
|
||||||
|
hpenOld = SelectObject(hdc1, hpen);
|
||||||
|
ok(hpenOld == GetStockObject(WHITE_BRUSH), "Got wrong pen.\n");
|
||||||
|
// RTEST(pDc_Attr->hbrush == hpen);
|
||||||
|
ok(GDI_HANDLE_GET_TYPE(hpenOld) == GDI_OBJECT_TYPE_BRUSH, "wrong type.\n");
|
||||||
|
SelectObject(hdc1, hpenOld);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Test_Region()
|
||||||
|
{
|
||||||
|
HRGN hrgn, hrgnOld;
|
||||||
|
|
||||||
|
/* Test REGION */
|
||||||
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
hrgn = CreateRectRgn(0,0,0,0);
|
||||||
|
hrgnOld = SelectObject(hdc1, hrgn);
|
||||||
|
ok((UINT_PTR)hrgnOld == NULLREGION, "\n");
|
||||||
|
DeleteObject(hrgn);
|
||||||
|
|
||||||
|
hrgn = CreateRectRgn(0,0,10,10);
|
||||||
|
ok((UINT_PTR)SelectObject(hdc1, hrgn) == SIMPLEREGION, "\n");
|
||||||
|
hrgnOld = CreateRectRgn(5,5,20,20);
|
||||||
|
ok(CombineRgn(hrgn, hrgn, hrgnOld, RGN_OR) == COMPLEXREGION, "\n");
|
||||||
|
DeleteObject(hrgnOld);
|
||||||
|
ok((UINT_PTR)SelectObject(hdc1, hrgn) == SIMPLEREGION, "\n"); // ??? Why this?
|
||||||
|
DeleteObject(hrgn);
|
||||||
|
// ok(IsHandleValid(hrgn) == TRUE, "\n");
|
||||||
|
ok_err(ERROR_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(SelectObject)
|
||||||
|
{
|
||||||
|
hdc1 = CreateCompatibleDC(NULL);
|
||||||
|
hdc2 = CreateCompatibleDC(NULL);
|
||||||
|
if (!hdc1 || !hdc2)
|
||||||
|
{
|
||||||
|
printf("couldn't create DCs, skipping all tests\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Test_SelectObject();
|
||||||
|
Test_Bitmap();
|
||||||
|
Test_Pen();
|
||||||
|
Test_Region();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue