reactos/modules/rostests/apitests/win32nt/ntgdi/NtGdiSelectFont.c
Serge Gautherie a5c3bb5bce
[WIN32KNT_APITEST] 2 minor code improvements and a first fix (#5980)
- Update .rc filename; addendum to 7ad21a4 (r70458).
- Move one '#include "resource.h"' around to where it is needed.
  Addendum to e1b2e7a (r29284) then ec5e0ea (r48103).
- Adjust all '#include <win32nt.h>'
2023-11-16 21:57:10 +01:00

54 lines
1.3 KiB
C

/*
* PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: Test for NtGdiSelectFont
* PROGRAMMERS:
*/
#include "../win32nt.h"
START_TEST(NtGdiSelectFont)
{
HDC hDC;
HFONT hFont, hOldFont;
hDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
hFont = GetStockObject(DEFAULT_GUI_FONT);
/* Test NULL DC */
SetLastError(ERROR_SUCCESS);
hOldFont = NtGdiSelectFont(NULL, hFont);
TEST(hOldFont == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
/* Test invalid DC */
SetLastError(ERROR_SUCCESS);
hOldFont = NtGdiSelectFont((HDC)((ULONG_PTR)hDC & 0x0000ffff), hFont);
TEST(hOldFont == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
/* Test NULL font */
SetLastError(ERROR_SUCCESS);
hOldFont = NtGdiSelectFont(hDC, NULL);
TEST(hOldFont == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
/* Test invalid font */
SetLastError(ERROR_SUCCESS);
hOldFont = NtGdiSelectFont(hDC, (HFONT)((ULONG_PTR)hFont & 0x0000ffff));
TEST(hOldFont == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
SetLastError(ERROR_SUCCESS);
hOldFont = NtGdiSelectFont(hDC, hFont);
TEST(hOldFont != NULL);
hOldFont = NtGdiSelectFont(hDC, hOldFont);
TEST(hOldFont == hFont);
TEST(GetLastError() == ERROR_SUCCESS);
DeleteDC(hDC);
}