2009-03-24 01:25:03 +00:00
|
|
|
|
|
|
|
INT
|
|
|
|
Test_NtGdiDeleteObjectApp(PTESTINFO pti)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HBITMAP hbmp;
|
|
|
|
HBRUSH hbrush;
|
|
|
|
|
|
|
|
/* Try to delete 0 */
|
|
|
|
SetLastError(0);
|
2009-04-06 02:49:47 +00:00
|
|
|
TEST(NtGdiDeleteObjectApp(0) == 0);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
|
2009-03-25 03:51:22 +00:00
|
|
|
/* Try to delete something with a stockbit */
|
|
|
|
SetLastError(0);
|
|
|
|
TEST(NtGdiDeleteObjectApp((PVOID)(GDI_HANDLE_STOCK_MASK | 0x1234)) == 1);
|
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
|
2009-03-24 01:25:03 +00:00
|
|
|
/* Delete a DC */
|
|
|
|
SetLastError(0);
|
|
|
|
hdc = CreateCompatibleDC(NULL);
|
2009-04-06 02:49:47 +00:00
|
|
|
ASSERT(IsHandleValid(hdc) == 1);
|
|
|
|
TEST(NtGdiDeleteObjectApp(hdc) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hdc) == 0);
|
|
|
|
|
|
|
|
/* Delete a brush */
|
|
|
|
SetLastError(0);
|
|
|
|
hbrush = CreateSolidBrush(0x123456);
|
2009-04-06 02:49:47 +00:00
|
|
|
ASSERT(IsHandleValid(hbrush) == 1);
|
|
|
|
TEST(NtGdiDeleteObjectApp(hbrush) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbrush) == 0);
|
|
|
|
|
|
|
|
/* Try to delete a stock brush */
|
|
|
|
SetLastError(0);
|
|
|
|
hbrush = GetStockObject(BLACK_BRUSH);
|
2009-04-06 02:49:47 +00:00
|
|
|
ASSERT(IsHandleValid(hbrush) == 1);
|
|
|
|
TEST(NtGdiDeleteObjectApp(hbrush) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbrush) == 1);
|
|
|
|
|
|
|
|
/* Delete a bitmap */
|
|
|
|
SetLastError(0);
|
|
|
|
hbmp = CreateBitmap(10, 10, 1, 1, NULL);
|
2009-04-06 02:49:47 +00:00
|
|
|
ASSERT(IsHandleValid(hbmp) == 1);
|
|
|
|
TEST(NtGdiDeleteObjectApp(hbmp) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbmp) == 0);
|
|
|
|
|
|
|
|
/* Create a DC for further use */
|
|
|
|
hdc = CreateCompatibleDC(NULL);
|
|
|
|
ASSERT(hdc);
|
|
|
|
|
|
|
|
/* Try to delete a brush that is selected into a DC */
|
|
|
|
SetLastError(0);
|
|
|
|
hbrush = CreateSolidBrush(0x123456);
|
2009-04-06 02:49:47 +00:00
|
|
|
ASSERT(IsHandleValid(hbrush) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(NtGdiSelectBrush(hdc, hbrush));
|
2009-04-06 02:49:47 +00:00
|
|
|
TEST(NtGdiDeleteObjectApp(hbrush) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbrush) == 1);
|
|
|
|
|
|
|
|
/* Try to delete a bitmap that is selected into a DC */
|
|
|
|
SetLastError(0);
|
|
|
|
hbmp = CreateBitmap(10, 10, 1, 1, NULL);
|
2009-04-06 02:49:47 +00:00
|
|
|
ASSERT(IsHandleValid(hbmp) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(NtGdiSelectBitmap(hdc, hbmp));
|
2009-03-25 03:51:22 +00:00
|
|
|
|
2009-04-06 02:49:47 +00:00
|
|
|
TEST(NtGdiDeleteObjectApp(hbmp) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbmp) == 1);
|
|
|
|
|
|
|
|
/* Bitmap get's deleted as soon as we dereference it */
|
|
|
|
NtGdiSelectBitmap(hdc, GetStockObject(DEFAULT_BITMAP));
|
|
|
|
TEST(IsHandleValid(hbmp) == 0);
|
|
|
|
|
2009-04-06 02:49:47 +00:00
|
|
|
TEST(NtGdiDeleteObjectApp(hbmp) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbmp) == 0);
|
|
|
|
|
2009-04-06 02:49:47 +00:00
|
|
|
/* Try to delete a brush that is selected into a DC */
|
|
|
|
SetLastError(0);
|
|
|
|
hbrush = CreateSolidBrush(123);
|
|
|
|
ASSERT(IsHandleValid(hbrush) == 1);
|
|
|
|
TEST(NtGdiSelectBrush(hdc, hbrush));
|
|
|
|
|
|
|
|
TEST(NtGdiDeleteObjectApp(hbrush) == 1);
|
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(IsHandleValid(hbrush) == 1);
|
2009-03-24 01:25:03 +00:00
|
|
|
|
|
|
|
return APISTATUS_NORMAL;
|
|
|
|
}
|