[PATCH 4/6] d3d9/tests: Test style changes on focus loss.

Stefan Dösinger stefan at codeweavers.com
Wed Nov 12 15:15:37 CST 2014


I will add message tests for the hidden window behavior in a separate
test.

I don't particularly care about the behavior on the second d3d9ex device
creation. This part is in the test to explain why I am destroying
the device and the windows. d3d9ex does the same when calling reset to
switch to fullscreen mode a second time.
---
 dlls/d3d9/tests/d3d9ex.c | 85 +++++++++++++++++++++++++++++++++++++++++++++---
 dlls/d3d9/tests/device.c | 40 +++++++++++++++++++++--
 2 files changed, 117 insertions(+), 8 deletions(-)

diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 424d2cc..0074261 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -2218,24 +2218,27 @@ done:
 static void test_window_style(void)
 {
     RECT focus_rect, device_rect, fullscreen_rect, r, r2;
-    LONG device_style, device_exstyle;
+    LONG device_style, device_exstyle, expected_style;
     LONG focus_style, focus_exstyle;
     struct device_desc device_desc;
     LONG style;
     IDirect3DDevice9Ex *device;
     HRESULT hr;
     ULONG ref;
+    BOOL ret;
     static const struct
     {
         LONG style_flags;
         DWORD device_flags;
+        LONG focus_loss_style;
+        LONG create2_style, create2_exstyle;
     }
     tests[] =
     {
-        {0,             0},
-        {WS_VISIBLE,    0},
-        {0,             CREATE_DEVICE_NOWINDOWCHANGES},
-        {WS_VISIBLE,    CREATE_DEVICE_NOWINDOWCHANGES},
+        {0,             0,                              0,              WS_VISIBLE, WS_EX_TOPMOST},
+        {WS_VISIBLE,    0,                              WS_MINIMIZE,    WS_VISIBLE, WS_EX_TOPMOST},
+        {0,             CREATE_DEVICE_NOWINDOWCHANGES,  0,              0,          0},
+        {WS_VISIBLE,    CREATE_DEVICE_NOWINDOWCHANGES,  0,              0,          0},
     };
     unsigned int i;
 
@@ -2323,6 +2326,78 @@ static void test_window_style(void)
         ref = IDirect3DDevice9Ex_Release(device);
         ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
 
+        style = GetWindowLongA(device_window, GWL_STYLE);
+        if (device_style & WS_VISIBLE)
+            ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+                device_style, style, i);
+        else
+            todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+                    device_style, style, i);
+        style = GetWindowLongA(device_window, GWL_EXSTYLE);
+        todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+                device_exstyle, style, i);
+
+        style = GetWindowLongA(focus_window, GWL_STYLE);
+        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+                focus_style, style, i);
+        style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+                focus_exstyle, style, i);
+
+        /* The second time a device is created on the window the window becomes visible and
+         * topmost if D3DCREATE_NOWINDOWCHANGES is not set. */
+        device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+        device = create_device(focus_window, &device_desc);
+        ok(!!device, "Failed to create a D3D device.\n");
+        style = GetWindowLongA(device_window, GWL_STYLE);
+        expected_style = device_style | tests[i].create2_style;
+        todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+                expected_style, style, i);
+        expected_style = device_exstyle | tests[i].create2_exstyle;
+        style = GetWindowLongA(device_window, GWL_EXSTYLE);
+        todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+                expected_style, style, i);
+
+        style = GetWindowLongA(focus_window, GWL_STYLE);
+        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+                focus_style, style, i);
+        style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+                focus_exstyle, style, i);
+        ref = IDirect3DDevice9Ex_Release(device);
+        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+        DestroyWindow(device_window);
+        DestroyWindow(focus_window);
+        focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+                0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+        device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+                0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+
+        device_desc.device_window = device_window;
+        device = create_device(focus_window, &device_desc);
+        ok(!!device, "Failed to create a D3D device.\n");
+        ret = SetForegroundWindow(GetDesktopWindow());
+        ok(ret, "Failed to set foreground window.\n");
+
+        style = GetWindowLongA(device_window, GWL_STYLE);
+        expected_style = device_style | tests[i].focus_loss_style;
+        todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+                expected_style, style, i);
+        style = GetWindowLongA(device_window, GWL_EXSTYLE);
+        todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+                device_exstyle, style, i);
+
+        style = GetWindowLongA(focus_window, GWL_STYLE);
+        ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+                focus_style, style, i);
+        style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+                focus_exstyle, style, i);
+
+        ref = IDirect3DDevice9Ex_Release(device);
+        ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
         DestroyWindow(device_window);
         DestroyWindow(focus_window);
     }
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index aeda123..d98221a 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3787,15 +3787,16 @@ static void test_window_style(void)
     IDirect3D9 *d3d9;
     HRESULT hr;
     ULONG ref;
+    BOOL ret;
     static const struct
     {
         DWORD device_flags;
-        LONG style, exstyle;
+        LONG style, focus_loss_style, exstyle;
     }
     tests[] =
     {
-        {0,                               WS_VISIBLE, WS_EX_TOPMOST},
-        {CREATE_DEVICE_NOWINDOWCHANGES,   0},
+        {0,                                 WS_VISIBLE, WS_MINIMIZE,    WS_EX_TOPMOST},
+        {CREATE_DEVICE_NOWINDOWCHANGES,     0,          0,              0},
     };
     unsigned int i;
 
@@ -3890,6 +3891,39 @@ static void test_window_style(void)
         ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
                 focus_exstyle, style, i);
 
+        device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+        hr = reset_device(device, &device_desc);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+        ret = SetForegroundWindow(GetDesktopWindow());
+        ok(ret, "Failed to set foreground window.\n");
+
+        style = GetWindowLongA(device_window, GWL_STYLE);
+        expected_style = device_style | tests[i].focus_loss_style | tests[i].style;
+        todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+                expected_style, style);
+        style = GetWindowLongA(device_window, GWL_EXSTYLE);
+        expected_style = device_exstyle | tests[i].exstyle;
+        todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+                expected_style, style);
+
+        style = GetWindowLongA(focus_window, GWL_STYLE);
+        ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+                focus_style, style);
+        style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+        ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+                focus_exstyle, style);
+
+        /* In d3d8 follow-up tests fail on native if the device is destroyed while
+         * lost. This doesn't happen in d3d9 on my test machine but it still seems
+         * like a good idea to reset it first. */
+        ShowWindow(focus_window, SW_MINIMIZE);
+        ShowWindow(focus_window, SW_RESTORE);
+        ret = SetForegroundWindow(focus_window);
+        ok(ret, "Failed to set foreground window.\n");
+        flush_events();
+        hr = reset_device(device, &device_desc);
+        ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
         ref = IDirect3DDevice9_Release(device);
         ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
 
-- 
2.0.4




More information about the wine-patches mailing list