[PATCH 2/2] d3d9/tests: Add interactive test for window pos messages received when restoring a window after device lost.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Thu Oct 15 09:39:26 CDT 2020
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/d3d9/tests/device.c | 55 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 53a83ad..7c2fcfa 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -11404,6 +11404,35 @@ static void test_writeonly_resource(void)
DestroyWindow(window);
}
+static BOOL test_lost_device_focus_set, test_lost_device_pos_changed_ok;
+static WNDPROC test_lost_device_orig_proc;
+
+static LRESULT CALLBACK test_lost_device_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_SETFOCUS:
+ test_lost_device_focus_set = TRUE;
+ break;
+ case WM_WINDOWPOSCHANGED:
+ if (!IsIconic(hwnd))
+ {
+ WINDOWPOS *p = (WINDOWPOS*)lParam;
+ MONITORINFO mi;
+
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfoA(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &mi);
+
+ if (p->x == mi.rcMonitor.left && p->y == mi.rcMonitor.top &&
+ p->cx == registry_mode.dmPelsWidth && p->cy == registry_mode.dmPelsHeight &&
+ !(p->flags & SWP_NOSIZE))
+ test_lost_device_pos_changed_ok = TRUE;
+ }
+ break;
+ }
+ return CallWindowProcA(test_lost_device_orig_proc, hwnd, msg, wParam, lParam);
+}
+
static void test_lost_device(void)
{
struct device_desc device_desc;
@@ -11440,6 +11469,32 @@ static void test_lost_device(void)
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+ if (winetest_interactive)
+ {
+ MSG msg;
+
+ test_lost_device_focus_set = FALSE;
+ test_lost_device_orig_proc = (WNDPROC)SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)test_lost_device_proc);
+
+ trace("Please restore the minimized d3d9_test by clicking on it.\n");
+ while (GetMessageA(&msg, NULL, 0, 0) > 0 && !test_lost_device_focus_set)
+ {
+ TranslateMessage(&msg);
+ DispatchMessageA(&msg);
+ }
+ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessageA(&msg);
+ }
+ SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)test_lost_device_orig_proc);
+
+ ok(test_lost_device_pos_changed_ok,
+ "WM_WINDOWPOSCHANGED was never sent with fullscreen size while window was not minimized.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ }
+
ret = ShowWindow(window, SW_RESTORE);
ok(ret, "Failed to restore window.\n");
ret = SetForegroundWindow(window);
--
2.21.0
More information about the wine-devel
mailing list