mirror of
https://github.com/reactos/reactos.git
synced 2024-07-03 19:24:20 +00:00
add tests for GetCurrentObject
svn path=/trunk/; revision=33295
This commit is contained in:
parent
486242012f
commit
6ea5c51737
|
@ -12,6 +12,7 @@
|
|||
#include "tests/CreateRectRgn.c"
|
||||
#include "tests/ExtCreatePen.c"
|
||||
#include "tests/GetClipRgn.c"
|
||||
#include "tests/GetCurrentObject.c"
|
||||
#include "tests/GetObject.c"
|
||||
#include "tests/GetStockObject.c"
|
||||
#include "tests/GetDIBits.c"
|
||||
|
@ -31,6 +32,7 @@ TESTENTRY TestList[] =
|
|||
{ L"CreateRectRgn", Test_CreateRectRgn },
|
||||
{ L"ExtCreatePen", Test_ExtCreatePen },
|
||||
{ L"GetClipRgn", Test_GetClipRgn },
|
||||
{ L"GetCurrentObject", Test_GetCurrentObject },
|
||||
{ L"GetObject", Test_GetObject },
|
||||
{ L"GetStockObject", Test_GetStockObject },
|
||||
{ L"GetDIBits", Test_GetDIBits },
|
||||
|
|
139
rostests/apitests/gdi32api/tests/GetCurrentObject.c
Normal file
139
rostests/apitests/gdi32api/tests/GetCurrentObject.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
|
||||
INT
|
||||
Test_GetCurrentObject(PTESTINFO pti)
|
||||
{
|
||||
HWND hWnd;
|
||||
HDC hDC;
|
||||
|
||||
/* Create a window */
|
||||
hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
|
||||
NULL, NULL, g_hInstance, 0);
|
||||
/* Get the DC */
|
||||
hDC = GetDC(hWnd);
|
||||
|
||||
/* Test NULL DC */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(NULL, 0) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(NULL, OBJ_BITMAP) == 0);
|
||||
TEST(GetCurrentObject(NULL, OBJ_BRUSH) == 0);
|
||||
TEST(GetCurrentObject(NULL, OBJ_COLORSPACE) == 0);
|
||||
TEST(GetCurrentObject(NULL, OBJ_FONT) == 0);
|
||||
TEST(GetCurrentObject(NULL, OBJ_PAL) == 0);
|
||||
TEST(GetCurrentObject(NULL, OBJ_PEN) == 0);
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Test invalid DC handle */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject((HDC)-123, 0) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject((HDC)-123, OBJ_BITMAP) == 0);
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Test invalid types */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 0) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 3) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 4) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 8) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 9) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 10) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 12) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, 13) == 0);
|
||||
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
||||
|
||||
/* Default bitmap */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
HBITMAP hBmp;
|
||||
hBmp = GetCurrentObject(hDC, OBJ_BITMAP);
|
||||
TEST(GDI_HANDLE_GET_TYPE(hBmp) == GDI_OBJECT_TYPE_BITMAP);
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Other bitmap */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
SelectObject(hDC, GetStockObject(21));
|
||||
TEST(hBmp == GetCurrentObject(hDC, OBJ_BITMAP));
|
||||
TEST(GDI_HANDLE_GET_TYPE(hBmp) == GDI_OBJECT_TYPE_BITMAP);
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Default brush */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, OBJ_BRUSH) == GetStockObject(WHITE_BRUSH));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Other brush */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
SelectObject(hDC, GetStockObject(BLACK_BRUSH));
|
||||
TEST(GetCurrentObject(hDC, OBJ_BRUSH) == GetStockObject(BLACK_BRUSH));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Default colorspace */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, OBJ_COLORSPACE) == GetStockObject(20));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Default font */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, OBJ_FONT) == GetStockObject(SYSTEM_FONT));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Other font */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));
|
||||
TEST(GetCurrentObject(hDC, OBJ_FONT) == GetStockObject(DEFAULT_GUI_FONT));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Default palette */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, OBJ_PAL) == GetStockObject(DEFAULT_PALETTE));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Default pen */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(BLACK_PEN));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* Other pen */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
SelectObject(hDC, GetStockObject(WHITE_PEN));
|
||||
TEST(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(WHITE_PEN));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
/* DC pen */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
SelectObject(hDC, GetStockObject(DC_PEN));
|
||||
TEST(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(DC_PEN));
|
||||
TEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
ReleaseDC(hWnd, hDC);
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
return APISTATUS_NORMAL;
|
||||
}
|
||||
|
Loading…
Reference in a new issue