From f217636e2d574c441d7ce8184883e8c488bbc7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Thu, 4 Dec 2014 21:51:45 +0100 Subject: [PATCH] d3d9/test: Test WM_SYSCOMMAND handling. --- dlls/d3d9/tests/d3d9ex.c | 88 ++++++++++++++++++++++++++++++++++++++++ dlls/d3d9/tests/device.c | 83 +++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index e20740569de..49be31e83f9 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -1898,6 +1898,32 @@ static void test_wndproc(void) {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE}, {0, 0, FALSE, 0}, }; + static const struct message sc_restore_messages[] = + { + {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, FOCUS_WINDOW, FALSE, 0}, + {WM_SIZE, FOCUS_WINDOW, TRUE, SIZE_RESTORED}, + {WM_SYSCOMMAND, FOCUS_WINDOW, TRUE, SC_RESTORE}, + {0, 0, FALSE, 0}, + }; + static const struct message sc_minimize_messages[] = + { + {WM_SYSCOMMAND, FOCUS_WINDOW, TRUE, SC_MINIMIZE}, + {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, FOCUS_WINDOW, FALSE, 0}, + {WM_MOVE, FOCUS_WINDOW, FALSE, 0}, + {WM_SIZE, FOCUS_WINDOW, TRUE, SIZE_MINIMIZED}, + {0, 0, FALSE, 0}, + }; + static const struct message sc_maximize_messages[] = + { + {WM_SYSCOMMAND, FOCUS_WINDOW, TRUE, SC_MAXIMIZE}, + {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, FOCUS_WINDOW, FALSE, 0}, + {WM_MOVE, FOCUS_WINDOW, FALSE, 0}, + /* WM_SIZE(SIZE_MAXIMIZED) is unreliable on native. */ + {0, 0, FALSE, 0}, + }; static const struct { DWORD create_flags; @@ -2131,12 +2157,42 @@ static void test_wndproc(void) expect_messages->message, expect_messages->window, i); ok(!windowposchanged_received, "Received WM_WINDOWPOSCHANGED but did not expect it, i=%u.\n", i); expect_messages = NULL; + flush_events(); ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode); ok(ret, "Failed to get display mode.\n"); ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth); ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight); + /* SW_SHOWMINNOACTIVE is needed to make FVWM happy. SW_SHOWNOACTIVATE is needed to make windows + * send SIZE_RESTORED after ShowWindow(SW_SHOWMINNOACTIVE). */ + ShowWindow(focus_window, SW_SHOWNOACTIVATE); + ShowWindow(focus_window, SW_SHOWMINNOACTIVE); + flush_events(); + + expect_messages = sc_restore_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0); + todo_wine 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); + expect_messages = NULL; + flush_events(); + + expect_messages = sc_minimize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MINIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + + expect_messages = sc_maximize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + + SetForegroundWindow(GetDesktopWindow()); + ShowWindow(device_window, SW_MINIMIZE); ShowWindow(device_window, SW_RESTORE); ShowWindow(focus_window, SW_MINIMIZE); ShowWindow(focus_window, SW_RESTORE); @@ -2160,6 +2216,9 @@ static void test_wndproc(void) * device will show it again. */ filter_messages = NULL; ShowWindow(device_window, SW_HIDE); + /* Remove the maximized state from the SYSCOMMAND test while we're not + * interfering with a device. */ + ShowWindow(focus_window, SW_SHOWNORMAL); filter_messages = focus_window; device_desc.device_window = focus_window; @@ -2187,6 +2246,35 @@ static void test_wndproc(void) ok(!IsIconic(focus_window) == !tests[i].iconic, "Expected IsIconic %u, got %u, i=%u.\n", tests[i].iconic, IsIconic(focus_window), i); + ShowWindow(focus_window, SW_SHOWNOACTIVATE); + ShowWindow(focus_window, SW_SHOWMINNOACTIVE); + flush_events(); + + expect_messages = sc_restore_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0); + todo_wine 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); + expect_messages = NULL; + flush_events(); + + /* For FVWM. */ + ShowWindow(focus_window, SW_RESTORE); + flush_events(); + + expect_messages = sc_minimize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MINIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + + expect_messages = sc_maximize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + /* This test can't activate, drop focus and restore focus like in plain d3d9 because d3d9ex * immediately restores the device on activation. There are plenty of WM_WINDOWPOSCHANGED * messages that are generated by ShowWindow, so testing for their absence is pointless. */ diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index fea68f1a911..72044a51985 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -3328,6 +3328,32 @@ static void test_wndproc(void) {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, TRUE}, {0, 0, FALSE, 0}, }; + static const struct message sc_restore_messages[] = + { + {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, FOCUS_WINDOW, FALSE, 0}, + {WM_SIZE, FOCUS_WINDOW, TRUE, SIZE_RESTORED}, + {WM_SYSCOMMAND, FOCUS_WINDOW, TRUE, SC_RESTORE}, + {0, 0, FALSE, 0}, + }; + static const struct message sc_minimize_messages[] = + { + {WM_SYSCOMMAND, FOCUS_WINDOW, TRUE, SC_MINIMIZE}, + {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, FOCUS_WINDOW, FALSE, 0}, + {WM_MOVE, FOCUS_WINDOW, FALSE, 0}, + {WM_SIZE, FOCUS_WINDOW, TRUE, SIZE_MINIMIZED}, + {0, 0, FALSE, 0}, + }; + static const struct message sc_maximize_messages[] = + { + {WM_SYSCOMMAND, FOCUS_WINDOW, TRUE, SC_MAXIMIZE}, + {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0}, + {WM_WINDOWPOSCHANGED, FOCUS_WINDOW, FALSE, 0}, + {WM_MOVE, FOCUS_WINDOW, FALSE, 0}, + /* WM_SIZE(SIZE_MAXIMIZED) is unreliable on native. */ + {0, 0, FALSE, 0}, + }; static const struct { DWORD create_flags; @@ -3565,12 +3591,42 @@ static void test_wndproc(void) expect_messages->message, expect_messages->window, i); ok(!windowposchanged_received, "Received WM_WINDOWPOSCHANGED but did not expect it.\n"); expect_messages = NULL; + flush_events(); ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode); ok(ret, "Failed to get display mode.\n"); ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth); ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight); + /* SW_SHOWMINNOACTIVE is needed to make FVWM happy. SW_SHOWNOACTIVATE is needed to make windows + * send SIZE_RESTORED after ShowWindow(SW_SHOWMINNOACTIVE). */ + ShowWindow(focus_window, SW_SHOWNOACTIVATE); + ShowWindow(focus_window, SW_SHOWMINNOACTIVE); + flush_events(); + + expect_messages = sc_restore_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0); + todo_wine 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); + expect_messages = NULL; + flush_events(); + + expect_messages = sc_minimize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MINIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + + expect_messages = sc_maximize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + + SetForegroundWindow(GetDesktopWindow()); + ShowWindow(device_window, SW_MINIMIZE); ShowWindow(device_window, SW_RESTORE); ShowWindow(focus_window, SW_MINIMIZE); ShowWindow(focus_window, SW_RESTORE); @@ -3599,6 +3655,9 @@ static void test_wndproc(void) * device will show it again. */ filter_messages = NULL; ShowWindow(device_window, SW_HIDE); + /* Remove the maximized state from the SYSCOMMAND test while we're not + * interfering with a device. */ + ShowWindow(focus_window, SW_SHOWNORMAL); filter_messages = focus_window; device_desc.device_window = focus_window; @@ -3632,7 +3691,31 @@ static void test_wndproc(void) if (tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES) ShowWindow(focus_window, SW_MINIMIZE); + expect_messages = sc_restore_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_RESTORE, 0); + todo_wine 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); + expect_messages = NULL; + flush_events(); + + /* For FVWM. */ ShowWindow(focus_window, SW_RESTORE); + flush_events(); + + expect_messages = sc_minimize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MINIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + + expect_messages = sc_maximize_messages; + SendMessageA(focus_window, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + 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); + expect_messages = NULL; + flush_events(); + /* Make sure the SetWindowPos call done by d3d9 is not a no-op. */ SetWindowPos(focus_window, NULL, 10, 10, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE); SetForegroundWindow(GetDesktopWindow());