[WIN32KNT_APITEST:NTDD] Improve failure handling
[reactos.git] / modules / rostests / apitests / win32nt / ntdd / NtGdiDdDeleteDirectDrawObject.c
index 00ee1f5..78d1af7 100644 (file)
@@ -11,14 +11,31 @@ START_TEST(NtGdiDdDeleteDirectDrawObject)
 {
     HANDLE hDirectDraw;
     HDC hdc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
-    ok(hdc != NULL, "\n");
+    ok(hdc != NULL, "CreateDCW() failed\n");
 
-    /* Test ReactX */
-    ok(NtGdiDdDeleteDirectDrawObject(NULL) == FALSE, "\n");
-    ok((hDirectDraw=NtGdiDdCreateDirectDrawObject(hdc)) != NULL, "\n");
-    ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE, "\n");
+    ok(NtGdiDdDeleteDirectDrawObject(NULL) == FALSE,
+       "NtGdiDdDeleteDirectDrawObject() succeeded on NULL object\n");
 
-    /* Cleanup ReactX setup */
-    DeleteDC(hdc);
-    NtGdiDdDeleteDirectDrawObject(hDirectDraw);
+    if (hdc == NULL)
+    {
+        skip("No DC\n");
+        return;
+    }
+
+    hDirectDraw = NtGdiDdCreateDirectDrawObject(hdc);
+    ok(hDirectDraw != NULL, "NtGdiDdCreateDirectDrawObject() failed\n");
+
+    if (hDirectDraw == NULL)
+    {
+        skip("No DirectDrawObject\n");
+        ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
+        return;
+    }
+
+    ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE,
+       "NtGdiDdDeleteDirectDrawObject() failed on existing object\n");
+    ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == FALSE,
+       "NtGdiDdDeleteDirectDrawObject() succeeded on deleted object\n");
+
+    ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
 }