[ROSTESTS]
authorJérôme Gardou <jerome.gardou@reactos.org>
Fri, 14 May 2010 23:19:16 +0000 (23:19 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Fri, 14 May 2010 23:19:16 +0000 (23:19 +0000)
  - more tests for direct DC creation/deletion

svn path=/trunk/; revision=47210

rostests/apitests/w32knapi/ntgdi/NtGdiCreateCompatibleDC.c
rostests/apitests/w32knapi/ntgdi/NtGdiDeleteObjectApp.c

index 3597eb6..130e100 100644 (file)
@@ -21,6 +21,8 @@ Test_NtGdiCreateCompatibleDC(PTESTINFO pti)
        /* The default pen should be GetStockObject(BLACK_PEN) */
        hObj = SelectObject(hDC, GetStockObject(WHITE_PEN));
        TEST(hObj == GetStockObject(BLACK_PEN));
        /* The default pen should be GetStockObject(BLACK_PEN) */
        hObj = SelectObject(hDC, GetStockObject(WHITE_PEN));
        TEST(hObj == GetStockObject(BLACK_PEN));
+       
+       TEST(NtGdiDeleteObjectApp(hDC) != 0);
 
        TEST(NtGdiDeleteObjectApp(hDC) != 0);
 
 
        TEST(NtGdiDeleteObjectApp(hDC) != 0);
 
index 0084b10..351de95 100644 (file)
@@ -5,6 +5,7 @@ Test_NtGdiDeleteObjectApp(PTESTINFO pti)
     HDC hdc;
     HBITMAP hbmp;
     HBRUSH hbrush;
     HDC hdc;
     HBITMAP hbmp;
     HBRUSH hbrush;
+    HPEN hpen;
 
     /* Try to delete 0 */
     SetLastError(0);
 
     /* Try to delete 0 */
     SetLastError(0);
@@ -23,7 +24,31 @@ Test_NtGdiDeleteObjectApp(PTESTINFO pti)
     TEST(NtGdiDeleteObjectApp(hdc) == 1);
     TEST(GetLastError() == 0);
     TEST(IsHandleValid(hdc) == 0);
     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 display DC */
     SetLastError(0);
     hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
     /* Delete a display DC */
     SetLastError(0);
     hdc = CreateDC("DISPLAY", NULL, NULL, NULL);