[PATCH v4 2/6] d3d9/tests: Test for window changes when it's not active.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Jan 10 08:47:26 CST 2022


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/d3d9/tests/d3d9ex.c | 210 +++++++++++++++++++++++++++++++++++++++
 dlls/d3d9/tests/device.c |  57 ++++++++++-
 2 files changed, 264 insertions(+), 3 deletions(-)

diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 2afe730..84298c6 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -3475,6 +3475,7 @@ static void test_window_style(void)
     struct device_desc device_desc;
     LONG style;
     IDirect3DDevice9Ex *device;
+    HWND active_window;
     HRESULT hr;
     ULONG ref;
     BOOL ret;
@@ -3662,6 +3663,215 @@ static void test_window_style(void)
         DestroyWindow(device_window);
         DestroyWindow(focus_window);
     }
+
+    /* Window changes are done only if the focus window is foreground */
+    focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+    device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+    active_window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            10, 20, 30, 40, 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(active_window);
+    ok(ret, "Failed to set foreground window.\n");
+    ok(GetActiveWindow() == active_window, "Unexpected active window.\n");
+
+    device_desc.device_window = device_window;
+    device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+    device = create_device(focus_window, &device_desc);
+    ok(!!device, "Failed to create a D3D device.\n");
+    ref = IDirect3DDevice9Ex_Release(device);
+    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+    ret = SetForegroundWindow(active_window);
+    ok(ret, "Failed to set foreground window.\n");
+    ok(GetActiveWindow() == active_window, "Unexpected active window.\n");
+
+    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);
+    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);
+
+    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);
+    GetWindowRect(device_window, &r);
+    ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
+
+    device_desc.flags = 0;
+    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);
+
+    ret = SetForegroundWindow(GetDesktopWindow());
+    ok(ret, "Failed to set foreground window.\n");
+    SetActiveWindow(active_window);
+    ok(GetActiveWindow() == active_window, "Unexpected active 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);
+
+    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);
+    expected_style = device_exstyle | WS_EX_TOPMOST;
+    todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", expected_style, style);
+
+    device_desc.flags = 0;
+    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);
+    expected_style = device_exstyle | WS_EX_TOPMOST;
+    todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", expected_style, style);
+
+    ref = IDirect3DDevice9Ex_Release(device);
+    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+    DestroyWindow(active_window);
+    DestroyWindow(device_window);
+    DestroyWindow(focus_window);
+
+    focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+    device_window = CreateWindowA("d3d9_test_wc", "d3d9_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");
+    SetActiveWindow(focus_window);
+    ok(GetActiveWindow() == focus_window, "Unexpected active window.\n");
+
+    device_desc.device_window = device_window;
+    device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+    device = create_device(focus_window, &device_desc);
+    ok(!!device, "Failed to create a D3D device.\n");
+    ref = IDirect3DDevice9Ex_Release(device);
+    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+    ret = SetForegroundWindow(GetDesktopWindow());
+    ok(ret, "Failed to set foreground window.\n");
+    SetActiveWindow(focus_window);
+    ok(GetActiveWindow() == focus_window, "Unexpected active window.\n");
+
+    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);
+    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);
+
+    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);
+    GetWindowRect(device_window, &r);
+    ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
+
+    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");
+    SetActiveWindow(focus_window);
+    ok(GetActiveWindow() == focus_window, "Unexpected active 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);
+
+    SetForegroundWindow(device_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);
+
+    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);
+    expected_style = device_exstyle | WS_EX_TOPMOST;
+    todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", expected_style, style);
+
+    device_desc.flags = 0;
+    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);
+    expected_style = device_exstyle | WS_EX_TOPMOST;
+    todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", expected_style, style);
+
+    ref = IDirect3DDevice9Ex_Release(device);
+    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+    DestroyWindow(device_window);
+    DestroyWindow(focus_window);
 }
 
 static void test_swapchain_parameters(void)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index c480a9d..b922c88 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -5051,9 +5051,7 @@ static void test_window_style(void)
         if (!(device = create_device(d3d9, focus_window, &device_desc)))
         {
             skip("Failed to create a D3D device, skipping tests.\n");
-            DestroyWindow(device_window);
-            DestroyWindow(focus_window);
-            break;
+            goto done;
         }
 
         style = GetWindowLongA(device_window, GWL_STYLE);
@@ -5148,6 +5146,59 @@ static void test_window_style(void)
         DestroyWindow(device_window);
         DestroyWindow(focus_window);
     }
+
+    /* Window changes are always done no matter if it is active or not */
+    focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+    device_window = CreateWindowA("d3d9_test_wc", "d3d9_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(d3d9, focus_window, &device_desc);
+    ok(!!device, "Failed to create a D3D device.\n");
+
+    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);
+    expected_style = device_exstyle | WS_EX_TOPMOST;
+    todo_wine ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "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);
+    GetWindowRect(device_window, &r);
+    ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
+
+    device_desc.flags = 0;
+    hr = reset_device(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+    style = GetWindowLongA(device_window, GWL_STYLE);
+    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);
+    expected_style = device_exstyle | WS_EX_TOPMOST;
+    ok(style == expected_style || broken(style == (expected_style & ~WS_EX_OVERLAPPEDWINDOW)) /* w1064v1809 */,
+            "Expected device window extended style %#x, got %#x.\n", expected_style, style);
+
+    ref = IDirect3DDevice9_Release(device);
+    ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+done:
+    DestroyWindow(device_window);
+    DestroyWindow(focus_window);
     IDirect3D9_Release(d3d9);
 }
 
-- 
2.34.1




More information about the wine-devel mailing list