mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +00:00
Add one test for NtGdiDeleteObjectApp, and a bunch of tests for NtGdiSaveDC and NtGdiRestoreDC.
svn path=/trunk/; revision=40217
This commit is contained in:
parent
b023f69f76
commit
9a1d43e359
4 changed files with 247 additions and 0 deletions
|
@ -13,6 +13,11 @@ Test_NtGdiDeleteObjectApp(PTESTINFO pti)
|
||||||
TEST(ret == 0);
|
TEST(ret == 0);
|
||||||
TEST(GetLastError() == 0);
|
TEST(GetLastError() == 0);
|
||||||
|
|
||||||
|
/* Try to delete something with a stockbit */
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiDeleteObjectApp((PVOID)(GDI_HANDLE_STOCK_MASK | 0x1234)) == 1);
|
||||||
|
TEST(GetLastError() == 0);
|
||||||
|
|
||||||
/* Delete a DC */
|
/* Delete a DC */
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
hdc = CreateCompatibleDC(NULL);
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
@ -74,6 +79,7 @@ Test_NtGdiDeleteObjectApp(PTESTINFO pti)
|
||||||
ASSERT(hbmp);
|
ASSERT(hbmp);
|
||||||
TEST(IsHandleValid(hbmp) == 1);
|
TEST(IsHandleValid(hbmp) == 1);
|
||||||
TEST(NtGdiSelectBitmap(hdc, hbmp));
|
TEST(NtGdiSelectBitmap(hdc, hbmp));
|
||||||
|
|
||||||
ret = NtGdiDeleteObjectApp(hbmp);
|
ret = NtGdiDeleteObjectApp(hbmp);
|
||||||
TEST(ret == 1);
|
TEST(ret == 1);
|
||||||
TEST(GetLastError() == 0);
|
TEST(GetLastError() == 0);
|
||||||
|
|
192
rostests/apitests/w32knapi/ntgdi/NtGdiRestoreDC.c
Normal file
192
rostests/apitests/w32knapi/ntgdi/NtGdiRestoreDC.c
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
|
||||||
|
|
||||||
|
static HBRUSH hbrush;
|
||||||
|
static HBITMAP hbitmap;
|
||||||
|
static HPEN hpen;
|
||||||
|
static HFONT hfont;
|
||||||
|
static HRGN hrgn, hrgn2;
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
SetSpecialDCState(HDC hdc)
|
||||||
|
{
|
||||||
|
/* Select spcial Objects */
|
||||||
|
SelectObject(hdc, hbrush);
|
||||||
|
SelectObject(hdc, hpen);
|
||||||
|
SelectObject(hdc, hbitmap);
|
||||||
|
SelectObject(hdc, hfont);
|
||||||
|
SelectObject(hdc, hrgn);
|
||||||
|
|
||||||
|
/* Colors */
|
||||||
|
SetDCBrushColor(hdc, RGB(12,34,56));
|
||||||
|
SetDCPenColor(hdc, RGB(23,34,45));
|
||||||
|
|
||||||
|
/* Coordinates */
|
||||||
|
SetMapMode(hdc, MM_ANISOTROPIC);
|
||||||
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
||||||
|
SetWindowOrgEx(hdc, 12, 34, NULL);
|
||||||
|
SetViewportOrgEx(hdc, 56, 78, NULL);
|
||||||
|
SetWindowExtEx(hdc, 123, 456, NULL);
|
||||||
|
SetViewportExtEx(hdc, 234, 567, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
SetSpecialDCState2(HDC hdc)
|
||||||
|
{
|
||||||
|
/* Select spcial Objects */
|
||||||
|
SelectObject(hdc, GetStockObject(DC_BRUSH));
|
||||||
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
||||||
|
SelectObject(hdc, GetStockObject(DEFAULT_BITMAP));
|
||||||
|
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
|
||||||
|
SelectObject(hdc, hrgn2);
|
||||||
|
|
||||||
|
/* Colors */
|
||||||
|
SetDCBrushColor(hdc, RGB(65,43,21));
|
||||||
|
SetDCPenColor(hdc, RGB(54,43,32));
|
||||||
|
|
||||||
|
/* Coordinates */
|
||||||
|
SetMapMode(hdc, MM_ISOTROPIC);
|
||||||
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
||||||
|
SetWindowOrgEx(hdc, 43, 21, NULL);
|
||||||
|
SetViewportOrgEx(hdc, 87, 65, NULL);
|
||||||
|
SetWindowExtEx(hdc, 654, 321, NULL);
|
||||||
|
SetViewportExtEx(hdc, 765, 432, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
Test_IsSpecialState(PTESTINFO pti, HDC hdc, BOOL bMemDC)
|
||||||
|
{
|
||||||
|
POINT pt;
|
||||||
|
SIZE sz;
|
||||||
|
|
||||||
|
/* Test Objects */
|
||||||
|
TEST(SelectObject(hdc, GetStockObject(DC_BRUSH)) == hbrush);
|
||||||
|
TEST(SelectObject(hdc, GetStockObject(DC_PEN)) == hpen);
|
||||||
|
TEST(SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)) == hfont);
|
||||||
|
if (bMemDC)
|
||||||
|
{
|
||||||
|
TEST(SelectObject(hdc, GetStockObject(DEFAULT_BITMAP)) == hbitmap);
|
||||||
|
TEST(SelectObject(hdc, hrgn2) == (PVOID)1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TEST(SelectObject(hdc, GetStockObject(DEFAULT_BITMAP)) == 0);
|
||||||
|
TEST(SelectObject(hdc, hrgn2) == (PVOID)2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test colors */
|
||||||
|
TEST(GetDCBrushColor(hdc) == RGB(12,34,56));
|
||||||
|
TEST(GetDCPenColor(hdc) == RGB(23,34,45));
|
||||||
|
|
||||||
|
/* Test coordinates */
|
||||||
|
TEST(GetMapMode(hdc) == MM_ANISOTROPIC);
|
||||||
|
TEST(GetGraphicsMode(hdc) == GM_ADVANCED);
|
||||||
|
GetWindowOrgEx(hdc, &pt);
|
||||||
|
TEST(pt.x == 12);
|
||||||
|
TEST(pt.y == 34);
|
||||||
|
GetViewportOrgEx(hdc, &pt);
|
||||||
|
TEST(pt.x == 56);
|
||||||
|
TEST(pt.y == 78);
|
||||||
|
GetWindowExtEx(hdc, &sz);
|
||||||
|
TESTX(sz.cx == 123, "sz.cx == %ld\n", sz.cx);
|
||||||
|
TESTX(sz.cy == 456, "sz.cy == %ld\n", sz.cy);
|
||||||
|
GetViewportExtEx(hdc, &sz);
|
||||||
|
TEST(sz.cx == 234);
|
||||||
|
TEST(sz.cy == 567);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
Test_SaveRestore(PTESTINFO pti, HDC hdc, BOOL bMemDC)
|
||||||
|
{
|
||||||
|
SetSpecialDCState(hdc);
|
||||||
|
NtGdiSaveDC(hdc);
|
||||||
|
SetSpecialDCState2(hdc);
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(hdc, 2) == 0);
|
||||||
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(hdc, 0) == 0);
|
||||||
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(hdc, -2) == 0);
|
||||||
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(hdc, 1) == 1);
|
||||||
|
TEST(GetLastError() == 0);
|
||||||
|
|
||||||
|
Test_IsSpecialState(pti, hdc, bMemDC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT
|
||||||
|
Test_NtGdiRestoreDC(PTESTINFO pti)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(0);
|
||||||
|
ASSERT(IsHandleValid(hdc));
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(0, -10) == 0);
|
||||||
|
TEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(hdc, 0) == 0);
|
||||||
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
TEST(NtGdiRestoreDC(hdc, 1) == 0);
|
||||||
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
/* Initialize objects */
|
||||||
|
hbrush = CreateSolidBrush(12345);
|
||||||
|
ASSERT(IsHandleValid(hbrush));
|
||||||
|
hpen = CreatePen(PS_SOLID, 4, RGB(10,12,32));
|
||||||
|
ASSERT(IsHandleValid(hpen));
|
||||||
|
hbitmap = CreateBitmap(10, 10, 1, 1, NULL);
|
||||||
|
ASSERT(IsHandleValid(hbitmap));
|
||||||
|
hfont = CreateFont(10, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET,
|
||||||
|
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||||
|
DEFAULT_PITCH, "Arial");
|
||||||
|
ASSERT(IsHandleValid(hfont));
|
||||||
|
hrgn = CreateRectRgn(12, 14, 14, 17);
|
||||||
|
ASSERT(IsHandleValid(hrgn));
|
||||||
|
hrgn2 = CreateRectRgn(1, 1, 2, 2);
|
||||||
|
ASSERT(IsHandleValid(hrgn2));
|
||||||
|
|
||||||
|
/* Test mem dc */
|
||||||
|
Test_SaveRestore(pti, hdc, TRUE);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
/* Test screen DC */
|
||||||
|
hdc = GetDC(0);
|
||||||
|
ASSERT(IsHandleValid(hdc));
|
||||||
|
Test_SaveRestore(pti, hdc, FALSE);
|
||||||
|
ReleaseDC(0, hdc);
|
||||||
|
|
||||||
|
/* Test info dc */
|
||||||
|
hdc = CreateICW(L"DISPLAY", NULL, NULL, NULL);
|
||||||
|
ASSERT(IsHandleValid(hdc));
|
||||||
|
Test_SaveRestore(pti, hdc, FALSE);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return APISTATUS_NORMAL;
|
||||||
|
}
|
||||||
|
|
45
rostests/apitests/w32knapi/ntgdi/NtGdiSaveDC.c
Normal file
45
rostests/apitests/w32knapi/ntgdi/NtGdiSaveDC.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
INT
|
||||||
|
Test_NtGdiSaveDC(PTESTINFO pti)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
HWND hwnd;
|
||||||
|
|
||||||
|
/* Test 0 hdc */
|
||||||
|
TEST(NtGdiSaveDC(0) == 0);
|
||||||
|
|
||||||
|
/* Test info dc */
|
||||||
|
hdc = CreateICW(L"DISPLAY",NULL,NULL,NULL);
|
||||||
|
TEST(hdc);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 1);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 2);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
/* Test display dc */
|
||||||
|
hdc = GetDC(0);
|
||||||
|
TEST(hdc);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 1);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 2);
|
||||||
|
ReleaseDC(0, hdc);
|
||||||
|
|
||||||
|
/* Test a mem DC */
|
||||||
|
hdc = CreateCompatibleDC(0);
|
||||||
|
TEST(hdc);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 1);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 2);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
/* Create a window */
|
||||||
|
hwnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||||
|
10, 10, 100, 100,
|
||||||
|
NULL, NULL, g_hInstance, 0);
|
||||||
|
hdc = GetDC(hwnd);
|
||||||
|
TEST(hdc);
|
||||||
|
TEST(NtGdiSaveDC(hdc) == 1);
|
||||||
|
NtGdiRestoreDC(hdc, 1);
|
||||||
|
ReleaseDC(hwnd, hdc);
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
|
||||||
|
return APISTATUS_NORMAL;
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "ntgdi/NtGdiGetFontResourceInfoInternalW.c"
|
#include "ntgdi/NtGdiGetFontResourceInfoInternalW.c"
|
||||||
#include "ntgdi/NtGdiGetRandomRgn.c"
|
#include "ntgdi/NtGdiGetRandomRgn.c"
|
||||||
#include "ntgdi/NtGdiPolyPolyDraw.c"
|
#include "ntgdi/NtGdiPolyPolyDraw.c"
|
||||||
|
#include "ntgdi/NtGdiRestoreDC.c"
|
||||||
|
#include "ntgdi/NtGdiSaveDC.c"
|
||||||
#include "ntgdi/NtGdiSelectBitmap.c"
|
#include "ntgdi/NtGdiSelectBitmap.c"
|
||||||
#include "ntgdi/NtGdiSelectBrush.c"
|
#include "ntgdi/NtGdiSelectBrush.c"
|
||||||
#include "ntgdi/NtGdiSelectFont.c"
|
#include "ntgdi/NtGdiSelectFont.c"
|
||||||
|
@ -85,6 +87,8 @@ TESTENTRY TestList[] =
|
||||||
{ L"NtGdiGetFontResourceInfoInternalW", Test_NtGdiGetFontResourceInfoInternalW },
|
{ L"NtGdiGetFontResourceInfoInternalW", Test_NtGdiGetFontResourceInfoInternalW },
|
||||||
{ L"NtGdiGetRandomRgn", Test_NtGdiGetRandomRgn },
|
{ L"NtGdiGetRandomRgn", Test_NtGdiGetRandomRgn },
|
||||||
{ L"NtGdiPolyPolyDraw", Test_NtGdiPolyPolyDraw },
|
{ L"NtGdiPolyPolyDraw", Test_NtGdiPolyPolyDraw },
|
||||||
|
{ L"NtGdiRestoreDC", Test_NtGdiRestoreDC },
|
||||||
|
{ L"NtGdiSaveDC", Test_NtGdiSaveDC },
|
||||||
{ L"NtGdiSetBitmapBits", Test_NtGdiSetBitmapBits },
|
{ L"NtGdiSetBitmapBits", Test_NtGdiSetBitmapBits },
|
||||||
{ L"NtGdiSetDIBitsToDeviceInternal", Test_NtGdiSetDIBitsToDeviceInternal },
|
{ L"NtGdiSetDIBitsToDeviceInternal", Test_NtGdiSetDIBitsToDeviceInternal },
|
||||||
{ L"NtGdiSelectBitmap", Test_NtGdiSelectBitmap },
|
{ L"NtGdiSelectBitmap", Test_NtGdiSelectBitmap },
|
||||||
|
|
Loading…
Reference in a new issue