[ROSTESTS]
[reactos.git] / rostests / apitests / w32knapi / ntgdi / NtGdiDeleteObjectApp.c
index ef4daa2..7403ab4 100644 (file)
@@ -5,6 +5,7 @@ Test_NtGdiDeleteObjectApp(PTESTINFO pti)
     HDC hdc;
     HBITMAP hbmp;
     HBRUSH hbrush;
+    HPEN hpen;
 
     /* Try to delete 0 */
     SetLastError(0);
@@ -16,14 +17,38 @@ Test_NtGdiDeleteObjectApp(PTESTINFO pti)
     TEST(NtGdiDeleteObjectApp((PVOID)(GDI_HANDLE_STOCK_MASK | 0x1234)) == 1);
     TEST(GetLastError() == 0);
 
-    /* Delete a DC */
+    /* Delete a compatible DC */
     SetLastError(0);
     hdc = CreateCompatibleDC(NULL);
     ASSERT(IsHandleValid(hdc) == 1);
     TEST(NtGdiDeleteObjectApp(hdc) == 1);
     TEST(GetLastError() == 0);
     TEST(IsHandleValid(hdc) == 0);
-
+    
+    /* Delete a display DC */
+    SetLastError(0);
+    hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
+    ASSERT(IsHandleValid(hdc) == 1);
+    TEST((hpen=SelectObject(hdc, GetStockObject(WHITE_PEN))) != NULL);
+    SelectObject(hdc, hpen);
+    TEST(NtGdiDeleteObjectApp(hdc) != 0);
+    TEST(GetLastError() == 0);
+    TEST(IsHandleValid(hdc) == 1);
+    TEST(SelectObject(hdc, GetStockObject(WHITE_PEN)) == NULL);
+    TESTX(GetLastError() == ERROR_INVALID_PARAMETER, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError());
+    
+    /* Once more */
+    SetLastError(0);
+    hdc = GetDC(0);
+    ASSERT(IsHandleValid(hdc) == 1);
+    TEST(NtGdiDeleteObjectApp(hdc) != 0);
+    TEST(GetLastError() == 0);
+    TEST(IsHandleValid(hdc) == 1);
+    TEST(SelectObject(hdc, GetStockObject(WHITE_PEN)) == NULL);
+    TESTX(GetLastError() == ERROR_INVALID_PARAMETER, "GetLasterror returned 0x%08x\n", (unsigned int)GetLastError());
+    /* Make sure */
+    TEST(NtUserCallOneParam((DWORD_PTR)hdc, ONEPARAM_ROUTINE_RELEASEDC) == 0);
+    
     /* Delete a brush */
     SetLastError(0);
     hbrush = CreateSolidBrush(0x123456);