[WIN32KNT_APITEST:NTDD] Improve failure handling
[reactos.git] / modules / rostests / apitests / win32nt / ntdd / NtGdiDdQueryDirectDrawObject.c
index ab3fb14..e682b7d 100644 (file)
@@ -15,7 +15,7 @@
  */
 START_TEST(NtGdiDdQueryDirectDrawObject)
 {
-    HANDLE hDirectDraw = NULL;
+    HANDLE hDirectDraw;
     DD_HALINFO *pHalInfo = NULL;
     DWORD *pCallBackFlags = NULL;
     LPD3DNTHAL_CALLBACKS puD3dCallbacks = NULL;
@@ -68,16 +68,8 @@ START_TEST(NtGdiDdQueryDirectDrawObject)
     ASSERT(hdc != NULL);
 
 
-    /* Create ReactX handle */
-    hDirectDraw = (HANDLE) NtGdiDdCreateDirectDrawObject(hdc);
+    hDirectDraw = NtGdiDdCreateDirectDrawObject(hdc);
     RTEST(hDirectDraw != NULL);
-    if (hDirectDraw == NULL)
-    {
-        DeleteDC(hdc);
-        return;
-    }
-
-    /* Start Test ReactX NtGdiDdQueryDirectDrawObject function */
 
     /* testing  OsThunkDdQueryDirectDrawObject( NULL, ....  */
     RTEST(NtGdiDdQueryDirectDrawObject( NULL, pHalInfo,
@@ -98,6 +90,13 @@ START_TEST(NtGdiDdQueryDirectDrawObject)
     RTEST(puNumHeaps == NULL);
     RTEST(puvmList == NULL);
 
+    if (hDirectDraw == NULL)
+    {
+        skip("No DirectDrawObject\n");
+        ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
+        return;
+    }
+
     /* testing  NtGdiDdQueryDirectDrawObject( hDirectDrawLocal, NULL, ....  */
     RTEST(NtGdiDdQueryDirectDrawObject( hDirectDraw, pHalInfo,
                                         pCallBackFlags, puD3dCallbacks,
@@ -797,7 +796,8 @@ START_TEST(NtGdiDdQueryDirectDrawObject)
     * puFourCC
     */
 
-    /* Cleanup ReactX setup */
-    DeleteDC(hdc);
-    NtGdiDdDeleteDirectDrawObject(hDirectDraw);
+    ok(NtGdiDdDeleteDirectDrawObject(hDirectDraw) == TRUE,
+       "NtGdiDdDeleteDirectDrawObject() failed\n");
+
+    ok(DeleteDC(hdc) != 0, "DeleteDC() failed\n");
 }