3 Test_NtGdiDeleteObjectApp(PTESTINFO pti
)
12 TEST(NtGdiDeleteObjectApp(0) == 0);
13 TEST(GetLastError() == 0);
15 /* Try to delete something with a stockbit */
17 TEST(NtGdiDeleteObjectApp((PVOID
)(GDI_HANDLE_STOCK_MASK
| 0x1234)) == 1);
18 TEST(GetLastError() == 0);
20 /* Delete a compatible DC */
22 hdc
= CreateCompatibleDC(NULL
);
23 ASSERT(IsHandleValid(hdc
) == 1);
24 TEST(NtGdiDeleteObjectApp(hdc
) == 1);
25 TEST(GetLastError() == 0);
26 TEST(IsHandleValid(hdc
) == 0);
28 /* Delete a display DC */
30 hdc
= CreateDC("DISPLAY", NULL
, NULL
, NULL
);
31 ASSERT(IsHandleValid(hdc
) == 1);
32 TEST((hpen
=SelectObject(hdc
, GetStockObject(WHITE_PEN
))) != NULL
);
33 SelectObject(hdc
, hpen
);
34 TEST(NtGdiDeleteObjectApp(hdc
) != 0);
35 TEST(GetLastError() == 0);
36 TEST(IsHandleValid(hdc
) == 1);
37 TEST(SelectObject(hdc
, GetStockObject(WHITE_PEN
)) == NULL
);
38 TESTX(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError());
43 ASSERT(IsHandleValid(hdc
) == 1);
44 TEST(NtGdiDeleteObjectApp(hdc
) != 0);
45 TEST(GetLastError() == 0);
46 TEST(IsHandleValid(hdc
) == 1);
47 TEST(SelectObject(hdc
, GetStockObject(WHITE_PEN
)) == NULL
);
48 TESTX(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError());
50 TEST(NtUserCallOneParam((DWORD_PTR
)hdc
, ONEPARAM_ROUTINE_RELEASEDC
) == 0);
52 /* Delete a display DC */
54 hdc
= CreateDC("DISPLAY", NULL
, NULL
, NULL
);
55 ASSERT(IsHandleValid(hdc
) == 1);
56 TEST(NtGdiDeleteObjectApp(hdc
) != 0);
57 TEST(GetLastError() == 0);
58 TEST(IsHandleValid(hdc
) == 1);
59 TEST(SelectObject(hdc
, GetStockObject(WHITE_PEN
)) == NULL
);
60 TESTX(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError());
65 ASSERT(IsHandleValid(hdc
) == 1);
66 TEST(NtGdiDeleteObjectApp(hdc
) != 0);
67 TEST(GetLastError() == 0);
68 TEST(IsHandleValid(hdc
) == 1);
69 TEST(SelectObject(hdc
, GetStockObject(WHITE_PEN
)) == NULL
);
70 TESTX(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError());
74 hbrush
= CreateSolidBrush(0x123456);
75 ASSERT(IsHandleValid(hbrush
) == 1);
76 TEST(NtGdiDeleteObjectApp(hbrush
) == 1);
77 TEST(GetLastError() == 0);
78 TEST(IsHandleValid(hbrush
) == 0);
80 /* Try to delete a stock brush */
82 hbrush
= GetStockObject(BLACK_BRUSH
);
83 ASSERT(IsHandleValid(hbrush
) == 1);
84 TEST(NtGdiDeleteObjectApp(hbrush
) == 1);
85 TEST(GetLastError() == 0);
86 TEST(IsHandleValid(hbrush
) == 1);
90 hbmp
= CreateBitmap(10, 10, 1, 1, NULL
);
91 ASSERT(IsHandleValid(hbmp
) == 1);
92 TEST(NtGdiDeleteObjectApp(hbmp
) == 1);
93 TEST(GetLastError() == 0);
94 TEST(IsHandleValid(hbmp
) == 0);
96 /* Create a DC for further use */
97 hdc
= CreateCompatibleDC(NULL
);
100 /* Try to delete a brush that is selected into a DC */
102 hbrush
= CreateSolidBrush(0x123456);
103 ASSERT(IsHandleValid(hbrush
) == 1);
104 TEST(NtGdiSelectBrush(hdc
, hbrush
));
105 TEST(NtGdiDeleteObjectApp(hbrush
) == 1);
106 TEST(GetLastError() == 0);
107 TEST(IsHandleValid(hbrush
) == 1);
109 /* Try to delete a bitmap that is selected into a DC */
111 hbmp
= CreateBitmap(10, 10, 1, 1, NULL
);
112 ASSERT(IsHandleValid(hbmp
) == 1);
113 TEST(NtGdiSelectBitmap(hdc
, hbmp
));
115 TEST(NtGdiDeleteObjectApp(hbmp
) == 1);
116 TEST(GetLastError() == 0);
117 TEST(IsHandleValid(hbmp
) == 1);
119 /* Bitmap get's deleted as soon as we dereference it */
120 NtGdiSelectBitmap(hdc
, GetStockObject(DEFAULT_BITMAP
));
121 TEST(IsHandleValid(hbmp
) == 0);
123 TEST(NtGdiDeleteObjectApp(hbmp
) == 1);
124 TEST(GetLastError() == 0);
125 TEST(IsHandleValid(hbmp
) == 0);
127 /* Try to delete a brush that is selected into a DC */
129 hbrush
= CreateSolidBrush(123);
130 ASSERT(IsHandleValid(hbrush
) == 1);
131 TEST(NtGdiSelectBrush(hdc
, hbrush
));
133 TEST(NtGdiDeleteObjectApp(hbrush
) == 1);
134 TEST(GetLastError() == 0);
135 TEST(IsHandleValid(hbrush
) == 1);
137 return APISTATUS_NORMAL
;