[PATCH v2 1/6] d3d8/tests: Test for window changes when it's not active.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Jan 3 08:08:07 CST 2022


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

I'm sending these tests first to show the behavior across d3d versions. I do
not plan to fix them during code freeze, except for ddraw, since I'm not aware
of any regressions due to them. I might fix them after code freeze though.

 dlls/d3d8/tests/device.c | 91 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index fc94dca..9e7c0fb 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -4055,6 +4055,97 @@ static void test_window_style(void)
 
     ref = IDirect3DDevice8_Release(device);
     ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+    DestroyWindow(device_window);
+    DestroyWindow(focus_window);
+
+    /* Window changes are done only if either the device or focus windows are active */
+    focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+    device_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+
+    device_style = GetWindowLongA(device_window, GWL_STYLE);
+    device_exstyle = GetWindowLongA(device_window, GWL_EXSTYLE);
+    focus_style = GetWindowLongA(focus_window, GWL_STYLE);
+    focus_exstyle = GetWindowLongA(focus_window, GWL_EXSTYLE);
+
+    ret = SetForegroundWindow(GetDesktopWindow());
+    ok(ret, "Failed to set foreground window.\n");
+
+    device_desc.device_window = device_window;
+    device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+    device = create_device(d3d8, focus_window, &device_desc);
+    ok(!!device, "Failed to create a D3D device.\n");
+    ShowWindow(device_window, SW_SHOWNOACTIVATE);
+
+    /* 32-bit tests ran under Windows 8 and 10 testbots have pretty
+       inconsistent behavior but topmost is set even when inactive. */
+    style = GetWindowLongA(device_window, GWL_EXSTYLE);
+    if (broken(style & WS_EX_TOPMOST))
+    {
+        win_skip("topmost set when inactive due to inconsistent behavior, skipping related tests...");
+        goto skip_inactive;
+    }
+    todo_wine ok(style == device_exstyle || broken(style == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", device_exstyle, style);
+    style = GetWindowLongA(device_window, GWL_STYLE);
+    todo_wine ok(style == device_style || broken(style == (device_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window style %#x, got %#x.\n", device_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);
+
+    device_desc.flags = 0;
+    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");
+    device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+    hr = reset_device(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    style = GetWindowLongA(device_window, GWL_STYLE);
+    todo_wine ok(style == device_style || broken(style == (device_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window style %#x, got %#x.\n", device_style, style);
+    style = GetWindowLongA(device_window, GWL_EXSTYLE);
+    todo_wine ok(style == device_exstyle || broken(style == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", device_exstyle, style);
+    GetWindowRect(device_window, &r);
+    ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
+
+    SetForegroundWindow(focus_window);
+    ok(ret, "Failed to set foreground window.\n");
+    hr = reset_device(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    style = GetWindowLongA(device_window, GWL_STYLE);
+    todo_wine ok(style == device_style || broken(style == (device_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window style %#x, got %#x.\n", device_style, style);
+    style = GetWindowLongA(device_window, GWL_EXSTYLE);
+    todo_wine ok(style == device_exstyle || broken(style == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", device_exstyle, style);
+
+    device_desc.flags = 0;
+    hr = reset_device(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+    hr = reset_device(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    style = GetWindowLongA(device_window, GWL_STYLE);
+    todo_wine ok(style == device_style || broken(style == (device_style & ~WS_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window style %#x, got %#x.\n", device_style, style);
+    style = GetWindowLongA(device_window, GWL_EXSTYLE);
+    todo_wine ok(style == device_exstyle || broken(style == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", device_exstyle, style);
+
+skip_inactive:
+    ref = IDirect3DDevice8_Release(device);
+    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
 
 done:
     IDirect3D8_Release(d3d8);
-- 
2.34.1




More information about the wine-devel mailing list