[WIN32KNT_APITEST:NTDD] Improve failure handling
[reactos.git] / modules / rostests / apitests / win32nt / ntdd / NtGdiDdDeleteDirectDrawObject.c
index 7c71988..78d1af7 100644 (file)
@@ -9,16 +9,33 @@
 
 START_TEST(NtGdiDdDeleteDirectDrawObject)
 {
-    HANDLE  hDirectDraw;
-    HDC hdc = CreateDCW(L"DISPLAY",NULL,NULL,NULL);
-    ok(hdc != NULL, "\n");
-
-    /* Test ReactX */
-    ok(NtGdiDdDeleteDirectDrawObject(NULL) == FALSE, "\n");
-    ok((hDirectDraw=NtGdiDdCreateDirectDrawObject(hdc)) != NULL, "\n");
-    ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE, "\n");
-
-    /* Cleanup ReactX setup */
-    DeleteDC(hdc);
-    NtGdiDdDeleteDirectDrawObject(hDirectDraw);
+    HANDLE hDirectDraw;
+    HDC hdc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
+    ok(hdc != NULL, "CreateDCW() failed\n");
+
+    ok(NtGdiDdDeleteDirectDrawObject(NULL) == FALSE,
+       "NtGdiDdDeleteDirectDrawObject() succeeded on NULL object\n");
+
+    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");
 }