When a minimized window doesn't handle WM_SYSCOMMAND SC_RESTORE messages, the window should remain minimized when its taskbar icon gets clicked.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/tests/msg.c | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index f0e0d0fba76..3c4cb084d8e 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -18735,6 +18735,82 @@ static void test_button_style(void) } }
+static BOOL sc_restore_received; + +static LRESULT CALLBACK test_taskbar_msg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + if (msg == WM_SYSCOMMAND && wp == SC_RESTORE) + { + sc_restore_received = TRUE; + return 0; + } + + return DefWindowProcA(hwnd, msg, wp, lp); +} + +static void test_taskbar_messages(void) +{ + HWND hwnd, background; + int timeout = 0; + COLORREF color; + WNDCLASSA cls; + HDC hdc; + + if (!winetest_interactive) + return; + + memset(&cls, 0, sizeof(cls)); + cls.lpfnWndProc = DefWindowProcA; + cls.hInstance = GetModuleHandleA(NULL); + cls.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszClassName = "test_taskbar_background_class"; + RegisterClassA(&cls); + + cls.lpfnWndProc = test_taskbar_msg_proc; + cls.hbrBackground = GetStockObject(GRAY_BRUSH); + cls.lpszClassName = "test_taskbar_class"; + RegisterClassA(&cls); + + background = CreateWindowA("test_taskbar_background_class", "background", WS_POPUP | WS_VISIBLE, + 100, 100, 200, 200, NULL, NULL, NULL, NULL); + ok(background != NULL, "CreateWindowA failed, error %d.\n", GetLastError()); + hwnd = CreateWindowA("test_taskbar_class", "test", WS_POPUP, 100, 100, 200, 200, NULL, NULL, NULL, + NULL); + ok(hwnd != NULL, "CreateWindowA failed, error %d.\n", GetLastError()); + ShowWindow(hwnd, SW_SHOWMINIMIZED); + flush_events(); + + trace("Click the taskbar icon of the test window within 5 seconds.\n"); + while (!sc_restore_received && timeout < 5000) + { + flush_events(); + timeout += 200; + } + ok(timeout < 5000 && sc_restore_received, "Didn't receive clicks on the taskbar icon.\n"); + + /* Desktop pixels may take a while to update */ + timeout = 0; + hdc = GetDC(0); + color = GetPixel(hdc, 150, 150); + while (color != 0xffffff && timeout < 1000) + { + flush_events(); + timeout += 200; + color = GetPixel(hdc, 150, 150); + } + /* The background window rectangle is (100, 100, 200, 200). If hwnd gets unminimized, it will + * end up obscuring the background window. */ + todo_wine_if(color != 0xffffff) + ok(color == 0xffffff, "Expected color %#x, got %#x.\n", 0xffffff, color); + + ReleaseDC(0, hdc); + DestroyWindow(hwnd); + DestroyWindow(background); + UnregisterClassA("test_taskbar_class", GetModuleHandleA(NULL)); + UnregisterClassA("test_taskbar_background_class", GetModuleHandleA(NULL)); +} + START_TEST(msg) { char **test_argv; @@ -18860,6 +18936,7 @@ START_TEST(msg) test_TrackPopupMenu(); test_TrackPopupMenuEmpty(); test_DoubleSetCapture(); + test_taskbar_messages(); /* keep it the last test, under Windows it tends to break the tests * which rely on active/foreground windows being correct. */
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108874
Your paranoid android.
=== w1064 (32 bit report) ===
user32: msg.c:15241: Test failed: unexpected message 31f msg.c:15242: Test failed: bad wparam 1 msg.c:15248: Test failed: unicode WM_CHAR: 0: the msg sequence is not complete: expected 0102 - actual 0000