Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)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 | 195 +++++++++++++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index fc94dca..3d58628 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -3943,6 +3943,7 @@ static void test_window_style(void)
struct device_desc device_desc;
LONG style, expected_style;
IDirect3DDevice8 *device;
+ HWND active_window;
IDirect3D8 *d3d8;
HRESULT hr;
ULONG ref;
@@ -4055,6 +4056,200 @@ 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 the current thread has the foreground window at creation */
+ 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);
+ active_window = CreateWindowA("static", "d3d8_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(d3d8, 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);
+
+ 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);
+ ShowWindow(device_window, SW_SHOWNOACTIVATE);
+
+ 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);
+ GetWindowRect(device_window, &r);
+ ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
+
+ ref = IDirect3DDevice8_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("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");
+ 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(d3d8, focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ ShowWindow(device_window, SW_SHOWNOACTIVATE);
+
+ /* Windows 8 and some versions of Windows 10 have some 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...\n");
+ 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");
+ SetActiveWindow(focus_window);
+ ok(GetActiveWindow() == focus_window, "Unexpected active window.");
+ 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);
+
+ ref = IDirect3DDevice8_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+
+ 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");
+ SetActiveWindow(device_window);
+ ok(GetActiveWindow() == device_window, "Unexpected active 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);
+
+ 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);
+
+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