From 90c7e55190377f3e2643daae60f6cf6066606a8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Wed, 15 Nov 2017 23:21:17 +0100 Subject: [PATCH] d3d8/tests: Test mode change messages. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Dösinger Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/tests/device.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 9cebd17e2d9..94b3e2e407d 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -2435,6 +2435,7 @@ struct message enum message_window window; BOOL check_wparam; WPARAM expect_wparam; + WINDOWPOS *store_wp; }; static const struct message *expect_messages; @@ -2483,6 +2484,9 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM "Got unexpected wparam %lx for message %x, expected %lx.\n", wparam, message, expect_messages->expect_wparam); + if (expect_messages->store_wp) + *expect_messages->store_wp = *(WINDOWPOS *)lparam; + ++expect_messages; } } @@ -2549,8 +2553,9 @@ static void test_wndproc(void) D3DDISPLAYMODE d3ddm; DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0; DEVMODEW devmode; - LONG change_ret; + LONG change_ret, device_style; BOOL ret; + WINDOWPOS windowpos; static const struct message create_messages[] = { @@ -2649,6 +2654,31 @@ static void test_wndproc(void) {WM_SIZE, FOCUS_WINDOW, TRUE, SIZE_MAXIMIZED}, {0, 0, FALSE, 0}, }; + struct message mode_change_messages[] = + { + {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0}, + {WM_SIZE, DEVICE_WINDOW, FALSE, 0}, + /* TODO: WM_DISPLAYCHANGE is sent to the focus window too, but the order is + * differs between Wine and Windows. */ + /* TODO 2: Windows sends a second WM_WINDOWPOSCHANGING(SWP_NOMOVE | SWP_NOSIZE + * | SWP_NOACTIVATE) in this situation, suggesting a difference in their ShowWindow + * implementation. This SetWindowPos call could in theory affect the Z order. Wine's + * ShowWindow does not send such a message because the window is already visible. */ + {0, 0, FALSE, 0}, + }; + struct message mode_change_messages_hidden[] = + { + {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0}, + {WM_SIZE, DEVICE_WINDOW, FALSE, 0}, + {WM_SHOWWINDOW, DEVICE_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, &windowpos}, + {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0}, + /* TODO: WM_DISPLAYCHANGE is sent to the focus window too, but the order is + * differs between Wine and Windows. */ + {0, 0, FALSE, 0}, + }; d3d8 = Direct3DCreate8(D3D_SDK_VERSION); ok(!!d3d8, "Failed to create a D3D object.\n"); @@ -3010,13 +3040,63 @@ static void test_wndproc(void) ref = IDirect3DDevice8_Release(device); ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref); + filter_messages = NULL; + + ShowWindow(device_window, SW_RESTORE); + SetForegroundWindow(focus_window); + flush_events(); + filter_messages = focus_window; device_desc.device_window = device_window; if (!(device = create_device(d3d8, focus_window, &device_desc))) { skip("Failed to create a D3D device, skipping tests.\n"); goto done; } + filter_messages = NULL; + flush_events(); + + device_desc.width = user32_width; + device_desc.height = user32_height; + + expect_messages = mode_change_messages; + filter_messages = focus_window; + hr = reset_device(device, &device_desc); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + filter_messages = NULL; + + flush_events(); + ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n", + expect_messages->message, expect_messages->window, i); + + /* World of Warplanes hides the window by removing WS_VISIBLE and expects Reset() to show it again. */ + device_style = GetWindowLongA(device_window, GWL_STYLE); + SetWindowLongA(device_window, GWL_STYLE, device_style & ~WS_VISIBLE); + + flush_events(); + device_desc.width = d3d_width; + device_desc.height = d3d_height; + memset(&windowpos, 0, sizeof(windowpos)); + + expect_messages = mode_change_messages_hidden; + filter_messages = focus_window; + hr = reset_device(device, &device_desc); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + filter_messages = NULL; + + flush_events(); + ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n", + expect_messages->message, expect_messages->window); + + ok(windowpos.hwnd == device_window && !windowpos.hwndInsertAfter + && !windowpos.x && !windowpos.y && !windowpos.cx && !windowpos.cy + && windowpos.flags == (SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE), + "Got unexpected WINDOWPOS hwnd=%p, insertAfter=%p, x=%d, y=%d, cx=%d, cy=%d, flags=%x\n", + windowpos.hwnd, windowpos.hwndInsertAfter, windowpos.x, windowpos.y, windowpos.cx, + windowpos.cy, windowpos.flags); + + device_style = GetWindowLongA(device_window, GWL_STYLE); + ok(device_style & WS_VISIBLE, "Expected the device window to be visible.\n"); proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA); ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc); -- 2.11.4.GIT