[WIN32KNT_APITEST:NTDD] Improve failure handling
[reactos.git] / modules / rostests / apitests / win32nt / ntdd / NtGdiDdCreateDirectDrawObject.c
index eb07b83..4e0f5c8 100644 (file)
@@ -11,13 +11,30 @@ START_TEST(NtGdiDdCreateDirectDrawObject)
 {
     HANDLE hDirectDraw;
     HDC hdc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
-    ok(hdc != NULL, "\n");
+    ok(hdc != NULL, "CreateDCW() failed\n");
 
-    /* Test ReactX */
-    ok(NtGdiDdCreateDirectDrawObject(NULL) == NULL, "\n");
-    ok((hDirectDraw = NtGdiDdCreateDirectDrawObject(hdc)) != NULL, "\n");
+    hDirectDraw = NtGdiDdCreateDirectDrawObject(NULL);
+    ok(hDirectDraw == NULL,
+       "NtGdiDdCreateDirectDrawObject() succeeded on NULL device context\n");
+    if (hDirectDraw != NULL)
+    {
+        ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE,
+           "NtGdiDdDeleteDirectDrawObject() failed on unwanted 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)
+    {
+        ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE,
+           "NtGdiDdDeleteDirectDrawObject() failed\n");
+    }
+
+    ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
 }