[PATCH 1/2] ddraw/tests: Skip overlay tests if DWM is on.

Stefan Dösinger stefandoesinger at gmx.at
Sun Aug 7 14:22:50 CDT 2016


Signed-off-by: Stefan Dösinger <stefandoesinger at gmx.at>
---
 dlls/ddraw/tests/ddraw1.c | 34 +++++++++++++++++++++++++++++++---
 dlls/ddraw/tests/ddraw2.c | 34 +++++++++++++++++++++++++++++++---
 dlls/ddraw/tests/ddraw4.c | 34 +++++++++++++++++++++++++++++++---
 dlls/ddraw/tests/ddraw7.c | 34 +++++++++++++++++++++++++++++++---
 4 files changed, 124 insertions(+), 12 deletions(-)

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 923aea3..bfc6bfe 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -25,6 +25,8 @@
 static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
 static DEVMODEW registry_mode;
 
+static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
+
 struct create_window_thread_param
 {
     HWND window;
@@ -8455,6 +8457,19 @@ done:
     DestroyWindow(window);
 }
 
+static BOOL dwm_enabled(void)
+{
+    BOOL ret = FALSE;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+    if (!pDwmIsCompositionEnabled)
+        return FALSE;
+    if (FAILED(pDwmIsCompositionEnabled(&ret)))
+        return FALSE;
+    return ret;
+}
+
 static void test_offscreen_overlay(void)
 {
     IDirectDrawSurface *overlay, *offscreen, *primary;
@@ -8516,7 +8531,8 @@ static void test_offscreen_overlay(void)
     ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
 
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled()),
+            "Failed to update overlay, hr %#x.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
@@ -8534,7 +8550,7 @@ done:
 
 static void test_overlay_rect(void)
 {
-    IDirectDrawSurface *overlay, *primary;
+    IDirectDrawSurface *overlay, *primary = NULL;
     DDSURFACEDESC surface_desc;
     RECT rect = {0, 0, 64, 64};
     IDirectDraw *ddraw;
@@ -8571,6 +8587,13 @@ static void test_overlay_rect(void)
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
     ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
 
+    /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
+    if (dwm_enabled())
+    {
+        win_skip("Cannot disable DWM, skipping overlay test.\n");
+        goto done;
+    }
+
     /* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
@@ -8618,9 +8641,10 @@ static void test_overlay_rect(void)
     ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
     ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
 
-    IDirectDrawSurface_Release(primary);
     IDirectDrawSurface_Release(overlay);
 done:
+    if (primary)
+        IDirectDrawSurface_Release(primary);
     IDirectDraw_Release(ddraw);
     DestroyWindow(window);
 }
@@ -9051,6 +9075,7 @@ START_TEST(ddraw1)
 {
     IDirectDraw *ddraw;
     DEVMODEW current_mode;
+    HMODULE dwmapi;
 
     if (!(ddraw = create_ddraw()))
     {
@@ -9071,6 +9096,9 @@ START_TEST(ddraw1)
         return;
     }
 
+    if ((dwmapi = LoadLibraryA("dwmapi.dll")))
+        pDwmIsCompositionEnabled = (void *)GetProcAddress(dwmapi, "DwmIsCompositionEnabled");
+
     test_coop_level_create_device_window();
     test_clipper_blt();
     test_coop_level_d3d_state();
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index fda7ffd..479b636 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -27,6 +27,8 @@
 static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
 static DEVMODEW registry_mode;
 
+static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
+
 struct create_window_thread_param
 {
     HWND window;
@@ -9567,6 +9569,19 @@ done:
     DestroyWindow(window);
 }
 
+static BOOL dwm_enabled(void)
+{
+    BOOL ret = FALSE;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+    if (!pDwmIsCompositionEnabled)
+        return FALSE;
+    if (FAILED(pDwmIsCompositionEnabled(&ret)))
+        return FALSE;
+    return ret;
+}
+
 static void test_offscreen_overlay(void)
 {
     IDirectDrawSurface *overlay, *offscreen, *primary;
@@ -9628,7 +9643,8 @@ static void test_offscreen_overlay(void)
     ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
 
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled()),
+            "Failed to update overlay, hr %#x.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
@@ -9646,7 +9662,7 @@ done:
 
 static void test_overlay_rect(void)
 {
-    IDirectDrawSurface *overlay, *primary;
+    IDirectDrawSurface *overlay, *primary = NULL;
     DDSURFACEDESC surface_desc;
     RECT rect = {0, 0, 64, 64};
     IDirectDraw2 *ddraw;
@@ -9683,6 +9699,13 @@ static void test_overlay_rect(void)
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
     ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
 
+    /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
+    if (dwm_enabled())
+    {
+        win_skip("Cannot disable DWM, skipping overlay test.\n");
+        goto done;
+    }
+
     /* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
@@ -9730,9 +9753,10 @@ static void test_overlay_rect(void)
     ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
     ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
 
-    IDirectDrawSurface_Release(primary);
     IDirectDrawSurface_Release(overlay);
 done:
+    if (primary)
+        IDirectDrawSurface_Release(primary);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -10224,6 +10248,7 @@ START_TEST(ddraw2)
 {
     IDirectDraw2 *ddraw;
     DEVMODEW current_mode;
+    HMODULE dwmapi;
 
     if (!(ddraw = create_ddraw()))
     {
@@ -10244,6 +10269,9 @@ START_TEST(ddraw2)
         return;
     }
 
+    if ((dwmapi = LoadLibraryA("dwmapi.dll")))
+        pDwmIsCompositionEnabled = (void *)GetProcAddress(dwmapi, "DwmIsCompositionEnabled");
+
     test_coop_level_create_device_window();
     test_clipper_blt();
     test_coop_level_d3d_state();
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index efb485f..8cce19d 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -27,6 +27,8 @@
 static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
 static DEVMODEW registry_mode;
 
+static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
+
 struct vec2
 {
     float x, y;
@@ -10734,6 +10736,19 @@ done:
     DestroyWindow(window);
 }
 
+static BOOL dwm_enabled(void)
+{
+    BOOL ret = FALSE;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+    if (!pDwmIsCompositionEnabled)
+        return FALSE;
+    if (FAILED(pDwmIsCompositionEnabled(&ret)))
+        return FALSE;
+    return ret;
+}
+
 static void test_offscreen_overlay(void)
 {
     IDirectDrawSurface4 *overlay, *offscreen, *primary;
@@ -10795,7 +10810,8 @@ static void test_offscreen_overlay(void)
     ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
 
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled()),
+            "Failed to update overlay, hr %#x.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface4_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
@@ -10813,7 +10829,7 @@ done:
 
 static void test_overlay_rect(void)
 {
-    IDirectDrawSurface4 *overlay, *primary;
+    IDirectDrawSurface4 *overlay, *primary = NULL;
     DDSURFACEDESC2 surface_desc;
     RECT rect = {0, 0, 64, 64};
     IDirectDraw4 *ddraw;
@@ -10850,6 +10866,13 @@ static void test_overlay_rect(void)
     hr = IDirectDrawSurface4_ReleaseDC(primary, dc);
     ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
 
+    /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
+    if (dwm_enabled())
+    {
+        win_skip("Cannot disable DWM, skipping overlay test.\n");
+        goto done;
+    }
+
     /* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
@@ -10897,9 +10920,10 @@ static void test_overlay_rect(void)
     ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
     ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
 
-    IDirectDrawSurface4_Release(primary);
     IDirectDrawSurface4_Release(overlay);
 done:
+    if (primary)
+        IDirectDrawSurface4_Release(primary);
     IDirectDraw4_Release(ddraw);
     DestroyWindow(window);
 }
@@ -11540,6 +11564,7 @@ START_TEST(ddraw4)
 {
     IDirectDraw4 *ddraw;
     DEVMODEW current_mode;
+    HMODULE dwmapi;
 
     if (!(ddraw = create_ddraw()))
     {
@@ -11560,6 +11585,9 @@ START_TEST(ddraw4)
         return;
     }
 
+    if ((dwmapi = LoadLibraryA("dwmapi.dll")))
+        pDwmIsCompositionEnabled = (void *)GetProcAddress(dwmapi, "DwmIsCompositionEnabled");
+
     test_process_vertices();
     test_coop_level_create_device_window();
     test_clipper_blt();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index bcd2021..024da08 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -28,6 +28,8 @@ static HRESULT (WINAPI *pDirectDrawCreateEx)(GUID *guid, void **ddraw, REFIID ii
 static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
 static DEVMODEW registry_mode;
 
+static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
+
 struct vec2
 {
     float x, y;
@@ -11063,6 +11065,19 @@ done:
     DestroyWindow(window);
 }
 
+static BOOL dwm_enabled(void)
+{
+    BOOL ret = FALSE;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+    if (!pDwmIsCompositionEnabled)
+        return FALSE;
+    if (FAILED(pDwmIsCompositionEnabled(&ret)))
+        return FALSE;
+    return ret;
+}
+
 static void test_offscreen_overlay(void)
 {
     IDirectDrawSurface7 *overlay, *offscreen, *primary;
@@ -11124,7 +11139,8 @@ static void test_offscreen_overlay(void)
     ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
 
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled()),
+            "Failed to update overlay, hr %#x.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
@@ -11142,7 +11158,7 @@ done:
 
 static void test_overlay_rect(void)
 {
-    IDirectDrawSurface7 *overlay, *primary;
+    IDirectDrawSurface7 *overlay, *primary = NULL;
     DDSURFACEDESC2 surface_desc;
     RECT rect = {0, 0, 64, 64};
     IDirectDraw7 *ddraw;
@@ -11179,6 +11195,13 @@ static void test_overlay_rect(void)
     hr = IDirectDrawSurface7_ReleaseDC(primary, dc);
     ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
 
+    /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
+    if (dwm_enabled())
+    {
+        win_skip("Cannot disable DWM, skipping overlay test.\n");
+        goto done;
+    }
+
     /* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
@@ -11226,9 +11249,10 @@ static void test_overlay_rect(void)
     ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
     ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
 
-    IDirectDrawSurface7_Release(primary);
     IDirectDrawSurface7_Release(overlay);
 done:
+    if (primary)
+        IDirectDrawSurface7_Release(primary);
     IDirectDraw7_Release(ddraw);
     DestroyWindow(window);
 }
@@ -11860,6 +11884,7 @@ static void test_draw_primitive(void)
 START_TEST(ddraw7)
 {
     HMODULE module = GetModuleHandleA("ddraw.dll");
+    HMODULE dwmapi;
     IDirectDraw7 *ddraw;
     DEVMODEW current_mode;
 
@@ -11888,6 +11913,9 @@ START_TEST(ddraw7)
         return;
     }
 
+    if ((dwmapi = LoadLibraryA("dwmapi.dll")))
+        pDwmIsCompositionEnabled = (void *)GetProcAddress(dwmapi, "DwmIsCompositionEnabled");
+
     test_process_vertices();
     test_coop_level_create_device_window();
     test_clipper_blt();
-- 
2.7.3




More information about the wine-patches mailing list