[APITESTS][WIN32KNT_APITEST] Improve NtGdiDeleteObjectApp testcase (#1282)

Use ok, ok_int and ok_long macros instead of obsolete TEST macros.
This commit is contained in:
Katayama Hirofumi MZ 2019-01-22 21:17:58 +09:00 committed by GitHub
parent 8fa1a24edc
commit 7c847f26e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,108 +16,108 @@ START_TEST(NtGdiDeleteObjectApp)
/* Try to delete 0 */ /* Try to delete 0 */
SetLastError(0); SetLastError(0);
TEST(NtGdiDeleteObjectApp(0) == 0); ok_int(NtGdiDeleteObjectApp(0), 0);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
/* Try to delete something with a stockbit */ /* Try to delete something with a stockbit */
SetLastError(0); SetLastError(0);
TEST(NtGdiDeleteObjectApp((PVOID)(GDI_HANDLE_STOCK_MASK | 0x1234)) == 1); ok_int(NtGdiDeleteObjectApp((PVOID)(GDI_HANDLE_STOCK_MASK | 0x1234)), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
/* Delete a compatible DC */ /* Delete a compatible DC */
SetLastError(0); SetLastError(0);
hdc = CreateCompatibleDC(NULL); hdc = CreateCompatibleDC(NULL);
ASSERT(GdiIsHandleValid(hdc) == 1); ok_int(GdiIsHandleValid(hdc), 1);
TEST(NtGdiDeleteObjectApp(hdc) == 1); ok_int(NtGdiDeleteObjectApp(hdc), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hdc) == 0); ok_int(GdiIsHandleValid(hdc), 0);
/* Delete a display DC */ /* Delete a display DC */
SetLastError(0); SetLastError(0);
hdc = CreateDC("DISPLAY", NULL, NULL, NULL); hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
ASSERT(GdiIsHandleValid(hdc) == 1); ok_int(GdiIsHandleValid(hdc), 1);
TEST((hpen=SelectObject(hdc, GetStockObject(WHITE_PEN))) != NULL); ok((hpen=SelectObject(hdc, GetStockObject(WHITE_PEN))) != NULL, "hpen was NULL.\n");
SelectObject(hdc, hpen); SelectObject(hdc, hpen);
TEST(NtGdiDeleteObjectApp(hdc) != 0); ok(NtGdiDeleteObjectApp(hdc) != 0, "NtGdiDeleteObjectApp(hdc) was zero.\n");
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hdc) == 1); ok_int(GdiIsHandleValid(hdc), 1);
TEST(SelectObject(hdc, GetStockObject(WHITE_PEN)) == NULL); ok_ptr(SelectObject(hdc, GetStockObject(WHITE_PEN)), NULL);
TESTX(GetLastError() == ERROR_INVALID_PARAMETER, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError()); ok_long(GetLastError(), ERROR_INVALID_PARAMETER);
/* Once more */ /* Once more */
SetLastError(0); SetLastError(0);
hdc = GetDC(0); hdc = GetDC(0);
ASSERT(GdiIsHandleValid(hdc) == 1); ok_int(GdiIsHandleValid(hdc), 1);
TEST(NtGdiDeleteObjectApp(hdc) != 0); ok(NtGdiDeleteObjectApp(hdc) != 0, "NtGdiDeleteObjectApp(hdc) was zero.\n");
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hdc) == 1); ok_int(GdiIsHandleValid(hdc), 1);
TEST(SelectObject(hdc, GetStockObject(WHITE_PEN)) == NULL); ok_ptr(SelectObject(hdc, GetStockObject(WHITE_PEN)), NULL);
TESTX(GetLastError() == ERROR_INVALID_PARAMETER, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError()); ok_long(GetLastError(), ERROR_INVALID_PARAMETER);
/* Make sure */ /* Make sure */
TEST(NtUserCallOneParam((DWORD_PTR)hdc, ONEPARAM_ROUTINE_RELEASEDC) == 0); ok_ptr((void *)NtUserCallOneParam((DWORD_PTR)hdc, ONEPARAM_ROUTINE_RELEASEDC), NULL);
/* Delete a brush */ /* Delete a brush */
SetLastError(0); SetLastError(0);
hbrush = CreateSolidBrush(0x123456); hbrush = CreateSolidBrush(0x123456);
ASSERT(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
TEST(NtGdiDeleteObjectApp(hbrush) == 1); ok_int(NtGdiDeleteObjectApp(hbrush), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbrush) == 0); ok_int(GdiIsHandleValid(hbrush), 0);
/* Try to delete a stock brush */ /* Try to delete a stock brush */
SetLastError(0); SetLastError(0);
hbrush = GetStockObject(BLACK_BRUSH); hbrush = GetStockObject(BLACK_BRUSH);
ASSERT(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
TEST(NtGdiDeleteObjectApp(hbrush) == 1); ok_int(NtGdiDeleteObjectApp(hbrush), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
/* Delete a bitmap */ /* Delete a bitmap */
SetLastError(0); SetLastError(0);
hbmp = CreateBitmap(10, 10, 1, 1, NULL); hbmp = CreateBitmap(10, 10, 1, 1, NULL);
ASSERT(GdiIsHandleValid(hbmp) == 1); ok_int(GdiIsHandleValid(hbmp), 1);
TEST(NtGdiDeleteObjectApp(hbmp) == 1); ok_int(NtGdiDeleteObjectApp(hbmp), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbmp) == 0); ok_int(GdiIsHandleValid(hbmp), 0);
/* Create a DC for further use */ /* Create a DC for further use */
hdc = CreateCompatibleDC(NULL); hdc = CreateCompatibleDC(NULL);
ASSERT(hdc); ok(hdc != NULL, "hdc was NULL.\n");
/* Try to delete a brush that is selected into a DC */ /* Try to delete a brush that is selected into a DC */
SetLastError(0); SetLastError(0);
hbrush = CreateSolidBrush(0x123456); hbrush = CreateSolidBrush(0x123456);
ASSERT(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
TEST(NtGdiSelectBrush(hdc, hbrush) != NULL); ok(NtGdiSelectBrush(hdc, hbrush) != NULL, "NtGdiSelectBrush(hdc, hbrush) was NULL.\n");
TEST(NtGdiDeleteObjectApp(hbrush) == 1); ok_int(NtGdiDeleteObjectApp(hbrush), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
/* Try to delete a bitmap that is selected into a DC */ /* Try to delete a bitmap that is selected into a DC */
SetLastError(0); SetLastError(0);
hbmp = CreateBitmap(10, 10, 1, 1, NULL); hbmp = CreateBitmap(10, 10, 1, 1, NULL);
ASSERT(GdiIsHandleValid(hbmp) == 1); ok_int(GdiIsHandleValid(hbmp), 1);
TEST(NtGdiSelectBitmap(hdc, hbmp) != NULL); ok(NtGdiSelectBitmap(hdc, hbmp) != NULL, "NtGdiSelectBitmap(hdc, hbmp) was NULL.\n");
TEST(NtGdiDeleteObjectApp(hbmp) == 1); ok_int(NtGdiDeleteObjectApp(hbmp), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbmp) == 1); ok_int(GdiIsHandleValid(hbmp), 1);
/* Bitmap get's deleted as soon as we dereference it */ /* Bitmap get's deleted as soon as we dereference it */
NtGdiSelectBitmap(hdc, GetStockObject(DEFAULT_BITMAP)); NtGdiSelectBitmap(hdc, GetStockObject(DEFAULT_BITMAP));
TEST(GdiIsHandleValid(hbmp) == 0); ok_int(GdiIsHandleValid(hbmp), 0);
TEST(NtGdiDeleteObjectApp(hbmp) == 1); ok_int(NtGdiDeleteObjectApp(hbmp), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbmp) == 0); ok_int(GdiIsHandleValid(hbmp), 0);
/* Try to delete a brush that is selected into a DC */ /* Try to delete a brush that is selected into a DC */
SetLastError(0); SetLastError(0);
hbrush = CreateSolidBrush(123); hbrush = CreateSolidBrush(123);
ASSERT(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
TEST(NtGdiSelectBrush(hdc, hbrush) != NULL); ok(NtGdiSelectBrush(hdc, hbrush) != NULL, "NtGdiSelectBrush(hdc, hbrush) was NULL.\n");
TEST(NtGdiDeleteObjectApp(hbrush) == 1); ok_int(NtGdiDeleteObjectApp(hbrush), 1);
TEST(GetLastError() == 0); ok_long(GetLastError(), 0);
TEST(GdiIsHandleValid(hbrush) == 1); ok_int(GdiIsHandleValid(hbrush), 1);
} }