[WIN32KNT_APITEST:NTDD] Improve failure handling
authorSerge Gautherie <reactos-git_serge_171003@gautherie.fr>
Thu, 20 Sep 2018 22:58:14 +0000 (00:58 +0200)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 2 Jun 2019 17:10:30 +0000 (19:10 +0200)
And remove comments about ReactX.

ROSTESTS-315

modules/rostests/apitests/win32nt/ntdd/NtGdiDdCreateDirectDrawObject.c
modules/rostests/apitests/win32nt/ntdd/NtGdiDdDeleteDirectDrawObject.c
modules/rostests/apitests/win32nt/ntdd/NtGdiDdQueryDirectDrawObject.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");
 }
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");
 }
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");
 }