Fix these failures:
win.c:2445: Test failed: style 0x200000: expected !100 win.c:2445: Test failed: style 0x300000: expected !100
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index cb6b61e59c0..e48d7bea513 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2249,7 +2249,7 @@ static void test_mdi(void) mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX /*| WS_VISIBLE*/, - 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, + 200, 100, CW_USEDEFAULT, CW_USEDEFAULT, GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); assert(mdi_hwndMain);
Improve the tests robustness by avoiding cross tests interactions, and recreating the windows every time making them more likely to get foreground.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 477 ++++++++++++++++++++++++++++------------ 1 file changed, 342 insertions(+), 135 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index e48d7bea513..400c00ec238 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -70,7 +70,6 @@ static BOOL test_lbuttondown_flag; static DWORD num_gettext_msgs; static DWORD num_settext_msgs; static HWND hwndMessage; -static HWND hwndMain, hwndMain2; static HHOOK hhook; static BOOL app_activated, app_deactivated;
@@ -183,6 +182,47 @@ static BOOL ignore_message( UINT message ) message == 0x0060 /* undocumented, used by Win10 1709+ */); }
+static BOOL init_test_windows( HWND *main_window, HWND *other_window ) +{ + DWORD style = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP; + HINSTANCE module = GetModuleHandleA( NULL ); + BOOL ret = TRUE; + + *main_window = CreateWindowExA( /*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window", + style | WS_VISIBLE, 100, 100, 200, 200, 0, 0, module, NULL ); + ok( !!*main_window, "CreateWindowExA failed, error %u\n", GetLastError() ); + + ret = SetForegroundWindow( *main_window ); + ok( ret, "SetForegroundWindow failed, error %u\n", GetLastError() ); + + if (other_window) + { + *other_window = CreateWindowExA( /*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2", + style, 100, 100, 200, 200, 0, 0, module, NULL); + ok( !!*other_window, "CreateWindowExA failed, error %u\n", GetLastError() ); + } + + flush_events( TRUE ); + if (*main_window == GetForegroundWindow()) return TRUE; + + skip( "Created window is not foreground, skipping tests.\n" ); + DestroyWindow( *main_window ); + if (other_window) DestroyWindow( *other_window ); + return FALSE; +} + +static void clean_test_windows( HWND main_window, HWND other_window ) +{ + BOOL ret; + if (!main_window) ret = TRUE; + else ret = DestroyWindow(main_window); + ok(ret, "DestroyWindow failed, error %u\n", GetLastError()); + if (!other_window) ret = TRUE; + else ret = DestroyWindow(other_window); + ok(ret, "DestroyWindow failed, error %u\n", GetLastError()); + flush_events( TRUE ); +} + static BOOL CALLBACK EnumChildProc( HWND hwndChild, LPARAM lParam) { (*(LPINT)lParam)++; @@ -211,9 +251,12 @@ static void test_parent_owner(void) LONG style; HWND test, owner, ret; HWND desktop = GetDesktopWindow(); - HWND child = create_tool_window( WS_CHILD, hwndMain ); + HWND child, hwndMain, hwndMain2; INT numChildren;
+ if (!init_test_windows( &hwndMain, &hwndMain2 )) return; + + child = create_tool_window( WS_CHILD, hwndMain ); if (winetest_debug > 1) trace( "main window %p main2 %p desktop %p child %p\n", hwndMain, hwndMain2, desktop, child );
@@ -649,6 +692,8 @@ static void test_parent_owner(void) check_parents( test, desktop, owner, NULL, owner, test, test ); DestroyWindow( owner ); DestroyWindow( test ); + + clean_test_windows( hwndMain, hwndMain2 ); }
static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lParam) @@ -964,7 +1009,7 @@ static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *in "wrong dwExStyle: %08x != %08x for %p in hook %s\n", info->dwExStyle, GetWindowLongA(hwnd, GWL_EXSTYLE), hwnd, hook); status = (GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0; - if (GetForegroundWindow()) + if (GetForegroundWindow() == hwnd) ok(info->dwWindowStatus == status, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n", info->dwWindowStatus, status, GetActiveWindow(), GetForegroundWindow(), hook);
@@ -1154,7 +1199,7 @@ static LRESULT CALLBACK test_standard_scrollbar_proc(HWND hwnd, UINT msg, WPARAM } }
-static void test_nonclient_area(HWND hwnd) +static void check_nonclient_area(HWND hwnd) { BOOL (WINAPI *pIsThemeActive)(void); POINT point, old_cursor_pos; @@ -1312,6 +1357,14 @@ static void test_nonclient_area(HWND hwnd) FreeLibrary(uxtheme); }
+static void test_nonclient_area(void) +{ + HWND hwnd; + if (!init_test_windows( &hwnd, NULL )) return; + check_nonclient_area( hwnd ); + clean_test_windows( hwnd, NULL ); +} + static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam) { static const char *CBT_code_name[10] = { @@ -2772,16 +2825,18 @@ static LRESULT WINAPI nccalcsize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM return DefWindowProcA( hwnd, msg, wparam, lparam ); }
-static void test_SetWindowPos(HWND hwnd, HWND hwnd2) +static void test_SetWindowPos(void) { RECT orig_win_rc, rect; LONG_PTR old_proc; - HWND hwnd_grandchild, hwnd_child, hwnd_child2; + HWND hwnd, hwnd2, hwnd_grandchild, hwnd_child, hwnd_child2; HWND hwnd_desktop; RECT rc_expected; RECT rc1, rc2; BOOL ret;
+ if (!init_test_windows(&hwnd, &hwnd2)) return; + SetRect(&rect, 111, 222, 333, 444); ok(!GetWindowRect(0, &rect), "GetWindowRect succeeded\n"); ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444, @@ -2987,15 +3042,19 @@ static void test_SetWindowPos(HWND hwnd, HWND hwnd2) flush_events( TRUE ); todo_wine check_active_state(hwnd2, hwnd2, hwnd2); DestroyWindow(hwnd_child); + + clean_test_windows(hwnd, hwnd2); }
-static void test_SetMenu(HWND parent) +static void test_SetMenu(void) { - HWND child; + HWND parent, child; HMENU hMenu, ret; BOOL retok; DWORD style;
+ if (!init_test_windows(&parent, NULL)) return; + hMenu = CreateMenu(); assert(hMenu);
@@ -3003,7 +3062,7 @@ static void test_SetMenu(HWND parent) if (0) { /* fails on (at least) Wine, NT4, XP SP2 */ - test_nonclient_area(parent); + check_nonclient_area(parent); } ret = GetMenu(parent); ok(ret == hMenu, "unexpected menu id %p\n", ret); @@ -3015,7 +3074,7 @@ static void test_SetMenu(HWND parent) ret = GetMenu(parent); ok(ret == hMenu, "unexpected menu id %p\n", ret); ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n"); - test_nonclient_area(parent); + check_nonclient_area(parent);
hMenu = CreateMenu(); assert(hMenu); @@ -3025,7 +3084,7 @@ static void test_SetMenu(HWND parent) ok(ret == 0, "unexpected menu id %p\n", ret);
ok(!SetMenu(parent, (HMENU)20), "SetMenu with invalid menu handle should fail\n"); - test_nonclient_area(parent); + check_nonclient_area(parent); ret = GetMenu(parent); ok(ret == 0, "unexpected menu id %p\n", ret);
@@ -3033,13 +3092,13 @@ static void test_SetMenu(HWND parent) if (0) { /* fails on (at least) Wine, NT4, XP SP2 */ - test_nonclient_area(parent); + check_nonclient_area(parent); } ret = GetMenu(parent); ok(ret == hMenu, "unexpected menu id %p\n", ret);
ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n"); - test_nonclient_area(parent); + check_nonclient_area(parent); ret = GetMenu(parent); ok(ret == 0, "unexpected menu id %p\n", ret);
@@ -3051,17 +3110,17 @@ static void test_SetMenu(HWND parent) ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
ok(!SetMenu(child, (HMENU)20), "SetMenu with invalid menu handle should fail\n"); - test_nonclient_area(child); + check_nonclient_area(child); ret = GetMenu(child); ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
ok(!SetMenu(child, hMenu), "SetMenu on a child window should fail\n"); - test_nonclient_area(child); + check_nonclient_area(child); ret = GetMenu(child); ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
ok(!SetMenu(child, 0), "SetMenu(0) on a child window should fail\n"); - test_nonclient_area(child); + check_nonclient_area(child); ret = GetMenu(child); ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
@@ -3077,6 +3136,8 @@ static void test_SetMenu(HWND parent)
DestroyWindow(child); DestroyMenu(hMenu); + + clean_test_windows(parent, NULL); }
static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total) @@ -3121,7 +3182,7 @@ static void test_window_tree(HWND parent, const DWORD *style, const int *order, ok(DestroyWindow(child[i]), "DestroyWindow failed\n"); }
-static void test_children_zorder(HWND parent) +static void test_children_zorder(void) { const DWORD simple_style[5] = { WS_CHILD, WS_CHILD, WS_CHILD, WS_CHILD, WS_CHILD }; @@ -3139,6 +3200,9 @@ static void test_children_zorder(HWND parent) WS_CHILD | WS_CLIPSIBLINGS | DS_CONTROL | WS_VISIBLE, WS_CHILD | WS_VISIBLE }; const int complex_order_6[3] = { 0, 1, 2 }; + HWND parent; + + if (!init_test_windows(&parent, NULL)) return;
/* simple WS_CHILD */ test_window_tree(parent, simple_style, simple_order, 5); @@ -3152,6 +3216,8 @@ static void test_children_zorder(HWND parent)
/* another set of complex children styles */ test_window_tree(parent, complex_style_6, complex_order_6, 3); + + clean_test_windows(parent, NULL); }
#define check_z_order(hwnd, next, prev, owner, topmost) \ @@ -3194,14 +3260,17 @@ static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner, hwnd, topmost ? "" : "NOT "); }
-static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style) +static void test_popup_zorder(DWORD style) { - HWND hwnd_A, hwnd_B, hwnd_C, hwnd_F; + HWND hwnd_A, hwnd_B, hwnd_C, hwnd_D, hwnd_E, hwnd_F; + + if (!init_test_windows(&hwnd_E, &hwnd_D)) return;;
/* Give current thread foreground state otherwise the tests may fail. */ if (!SetForegroundWindow(hwnd_D)) { skip("SetForegroundWindow not working\n"); + clean_test_windows(hwnd_E, hwnd_D); return; }
@@ -3291,14 +3360,19 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style) DestroyWindow(hwnd_B); DestroyWindow(hwnd_C); DestroyWindow(hwnd_F); + + clean_test_windows(hwnd_E, hwnd_D); }
-static void test_vis_rgn( HWND hwnd ) +static void test_vis_rgn(void) { RECT win_rect, rgn_rect; HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); + HWND hwnd; HDC hdc;
+ if (!init_test_windows(&hwnd, NULL)) return; + ShowWindow(hwnd,SW_SHOW); hdc = GetDC( hwnd ); ok( GetRandomRgn( hdc, hrgn, SYSRGN ) != 0, "GetRandomRgn failed\n" ); @@ -3310,6 +3384,8 @@ static void test_vis_rgn( HWND hwnd ) win_rect.bottom >= rgn_rect.bottom, "rgn %s not inside win %s\n", wine_dbgstr_rect(&rgn_rect), wine_dbgstr_rect(&win_rect)); ReleaseDC( hwnd, hdc ); + + clean_test_windows(hwnd, NULL); }
static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) @@ -3325,11 +3401,13 @@ static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, return DefWindowProcA(hwnd, msg, wp, lp); }
-static void test_SetFocus(HWND hwnd) +static void test_SetFocus(void) { - HWND child, child2, ret; + HWND hwnd, child, child2, ret; WNDPROC old_wnd_proc;
+ if (!init_test_windows(&hwnd, NULL)) return; + /* check if we can set focus to non-visible windows */
ShowWindow(hwnd, SW_SHOW); @@ -3430,11 +3508,15 @@ todo_wine
DestroyWindow( child2 ); DestroyWindow( child ); + + clean_test_windows(hwnd, NULL); }
-static void test_SetActiveWindow(HWND hwnd) +static void test_SetActiveWindow(void) { - HWND hwnd2, ret; + HWND hwnd, hwnd2, ret; + + if (!init_test_windows(&hwnd, NULL)) return;
flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); @@ -3517,6 +3599,8 @@ static void test_SetActiveWindow(HWND hwnd) check_active_state(hwnd, hwnd, hwnd); } DestroyWindow(hwnd2); + + clean_test_windows(hwnd, NULL); }
struct create_window_thread_params @@ -3544,16 +3628,18 @@ static DWORD WINAPI create_window_thread(void *param) return 0; }
-static void test_SetForegroundWindow(HWND hwnd) +static void test_SetForegroundWindow(void) { struct create_window_thread_params thread_params; HANDLE thread; DWORD res, tid; BOOL ret; - HWND hwnd2; + HWND hwnd, hwnd2; MSG msg; LONG style;
+ if (!init_test_windows(&hwnd, NULL)) return; + flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); SetFocus(0); @@ -3576,6 +3662,7 @@ static void test_SetForegroundWindow(HWND hwnd) if (!ret) { skip( "SetForegroundWindow not working\n" ); + clean_test_windows(hwnd, NULL); return; } check_wnd_state(hwnd, hwnd, hwnd, 0); @@ -3670,6 +3757,8 @@ static void test_SetForegroundWindow(HWND hwnd) CloseHandle(thread_params.window_created); CloseHandle(thread); DestroyWindow(hwnd2); + + clean_test_windows(hwnd, NULL); }
static WNDPROC old_button_proc; @@ -3808,10 +3897,13 @@ static void test_capture_2(void) check_wnd_state(oldActive, 0, oldFocus, 0); }
-static void test_capture_3(HWND hwnd1, HWND hwnd2) +static void test_capture_3(void) { + HWND hwnd1, hwnd2; BOOL ret;
+ if (!init_test_windows(&hwnd1, &hwnd2)) return; + ShowWindow(hwnd1, SW_HIDE); ShowWindow(hwnd2, SW_HIDE);
@@ -3831,6 +3923,8 @@ static void test_capture_3(HWND hwnd1, HWND hwnd2) ok (ret, "releasecapture did not return TRUE.\n"); ret = ReleaseCapture(); ok (ret, "releasecapture did not return TRUE after second try.\n"); + + clean_test_windows(hwnd1, hwnd2); }
static LRESULT CALLBACK test_capture_4_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -3957,11 +4051,14 @@ static BOOL peek_message( MSG *msg ) return ret; }
-static void test_keyboard_input(HWND hwnd) +static void test_keyboard_input(void) { + HWND hwnd; MSG msg; BOOL ret;
+ if (!init_test_windows(&hwnd, NULL)) return; + flush_events( TRUE ); SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW); UpdateWindow(hwnd); @@ -3996,6 +4093,7 @@ static void test_keyboard_input(HWND hwnd) if (!peek_message(&msg)) { skip( "keybd_event didn't work, skipping keyboard test\n" ); + clean_test_windows(hwnd, NULL); return; } ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message); @@ -4031,6 +4129,8 @@ static void test_keyboard_input(HWND hwnd) ok(msg.hwnd == hwnd && msg.message == WM_SYSKEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message); ret = peek_message(&msg); ok( !ret, "message %04x available\n", msg.message); + + clean_test_windows(hwnd, NULL); }
static BOOL wait_for_message( MSG *msg ) @@ -4051,15 +4151,17 @@ static BOOL wait_for_message( MSG *msg ) return ret; }
-static void test_mouse_input(HWND hwnd) +static void test_mouse_input(void) { RECT rc; POINT pt; int x, y; - HWND popup, child = NULL; + HWND hwnd, popup, child = NULL; MSG msg; BOOL ret;
+ if (!init_test_windows(&hwnd, NULL)) return; + ShowWindow(hwnd, SW_SHOWNORMAL); UpdateWindow(hwnd); SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE ); @@ -4279,14 +4381,19 @@ done: DestroyWindow(popup);
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); + + clean_test_windows(hwnd, NULL); }
-static void test_validatergn(HWND hwnd) +static void test_validatergn(void) { - HWND child; + HWND hwnd, child; RECT rc, rc2; HRGN rgn; int ret; + + if (!init_test_windows(&hwnd, NULL)) return; + child = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE, 10, 10, 10, 10, hwnd, 0, 0, NULL); ShowWindow(hwnd, SW_SHOW); UpdateWindow( hwnd); @@ -4317,6 +4424,8 @@ static void test_validatergn(HWND hwnd)
DeleteObject( rgn); DestroyWindow( child ); + + clean_test_windows(hwnd, NULL); }
static void nccalchelper(HWND hwnd, INT x, INT y, RECT *prc) @@ -4330,12 +4439,16 @@ static void nccalchelper(HWND hwnd, INT x, INT y, RECT *prc) trace("window rect is %s, nccalc rect is %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(prc)); }
-static void test_nccalcscroll(HWND parent) +static void test_nccalcscroll(void) { + HWND parent, hwnd; RECT rc1; INT sbheight = GetSystemMetrics( SM_CYHSCROLL); INT sbwidth = GetSystemMetrics( SM_CXVSCROLL); - HWND hwnd = CreateWindowExA(0, "static", NULL, + + if (!init_test_windows(&parent, NULL)) return; + + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE | WS_VSCROLL | WS_HSCROLL , 10, 10, 200, 200, parent, 0, 0, NULL); ShowWindow( parent, SW_SHOW); @@ -4367,6 +4480,8 @@ static void test_nccalcscroll(HWND parent) wine_dbgstr_rect(&rc1));
DestroyWindow( hwnd); + + clean_test_windows(parent, NULL); }
static void test_SetParent(void) @@ -4553,6 +4668,8 @@ typedef struct DWORD exstyle; } test_style;
+static ATOM atomStyleCheckClass; + static LRESULT WINAPI cbt_proc(int ncode, WPARAM wparam, LPARAM lparam) { CBT_CREATEWNDW* c = (CBT_CREATEWNDW*)lparam; @@ -4563,19 +4680,43 @@ static LRESULT WINAPI cbt_proc(int ncode, WPARAM wparam, LPARAM lparam) if (ncode != HCBT_CREATEWND) return CallNextHookEx(NULL, ncode, wparam, lparam);
- ts = c->lpcs->lpCreateParams; - ok(ts != NULL, "lpCreateParams not set\n"); - ok(c->lpcs->style == ts->cs_style, "style = 0x%08x, expected 0x%08x\n", - c->lpcs->style, ts->cs_style); - ok(c->lpcs->dwExStyle == ts->cs_exstyle, "exstyle = 0x%08x, expected 0x%08x\n", - c->lpcs->dwExStyle, ts->cs_exstyle); + if (c->lpcs->lpszClass == (void *)MAKEINTATOM(atomStyleCheckClass)) + { + ts = c->lpcs->lpCreateParams; + ok(ts != NULL, "lpCreateParams not set\n"); + ok(c->lpcs->style == ts->cs_style, "style = 0x%08x, expected 0x%08x\n", + c->lpcs->style, ts->cs_style); + ok(c->lpcs->dwExStyle == ts->cs_exstyle, "exstyle = 0x%08x, expected 0x%08x\n", + c->lpcs->dwExStyle, ts->cs_exstyle); + + style = GetWindowLongW(hwnd, GWL_STYLE); + ok(style == ts->cs_style, "style = 0x%08x, expected 0x%08x\n", + style, ts->cs_style); + style = GetWindowLongW(hwnd, GWL_EXSTYLE); + ok(style == (ts->cs_exstyle & ~WS_EX_LAYERED), + "exstyle = 0x%08x, expected 0x%08x\n", style, ts->cs_exstyle); + } + else + { + ok(!c->lpcs->lpCreateParams, "got lpCreateParams %p\n", c->lpcs->lpCreateParams); + ok(!c->lpcs->hInstance, "got hInstance %p\n", c->lpcs->hInstance); + ok(!c->lpcs->hMenu, "got hMenu %p\n", c->lpcs->hMenu); + todo_wine + ok(!!c->lpcs->hwndParent, "got hwndParent %p\n", c->lpcs->hwndParent); + todo_wine + ok(!c->lpcs->cx, "got cx %d\n", c->lpcs->cx); + todo_wine + ok(!c->lpcs->cy, "got cy %d\n", c->lpcs->cy); + ok(!c->lpcs->x, "got x %d\n", c->lpcs->x); + ok(!c->lpcs->y, "got y %d\n", c->lpcs->y); + todo_wine + ok(c->lpcs->style == (WS_POPUP|WS_DISABLED), "got style %#x\n", c->lpcs->style); + ok(!wcscmp(c->lpcs->lpszName, L"Default IME"), "got lpszName %s\n", debugstr_w(c->lpcs->lpszName)); + todo_wine + ok(c->lpcs->lpszClass == (void *)0xc026, "got lpszClass %s\n", debugstr_w(c->lpcs->lpszClass)); + ok(c->lpcs->dwExStyle == 0, "got dwExStyle %#x\n", c->lpcs->dwExStyle); + }
- style = GetWindowLongW(hwnd, GWL_STYLE); - ok(style == ts->cs_style, "style = 0x%08x, expected 0x%08x\n", - style, ts->cs_style); - style = GetWindowLongW(hwnd, GWL_EXSTYLE); - ok(style == (ts->cs_exstyle & ~WS_EX_LAYERED), - "exstyle = 0x%08x, expected 0x%08x\n", style, ts->cs_exstyle); return CallNextHookEx(NULL, ncode, wparam, lparam); }
@@ -4609,8 +4750,6 @@ static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM return DefWindowProcA(hwnd, msg, wparam, lparam); }
-static ATOM atomStyleCheckClass; - static void register_style_check_class(void) { WNDCLASSA wc = @@ -5248,12 +5387,15 @@ static void test_dialog_parent(void) DestroyWindow(parent); }
-static void test_scrollwindow( HWND hwnd) +static void test_scrollwindow(void) { + HWND hwnd; HDC hdc; RECT rc, rc2, rc3; COLORREF colr;
+ if (!init_test_windows(&hwnd, NULL)) return; + ShowWindow( hwnd, SW_SHOW); UpdateWindow( hwnd); flush_events( TRUE ); @@ -5299,9 +5441,11 @@ static void test_scrollwindow( HWND hwnd)
/* clean up */ ReleaseDC( hwnd, hdc); + + clean_test_windows(hwnd, NULL); }
-static void test_scrollvalidate( HWND parent) +static void test_scrollvalidate(void) { HDC hdc; HRGN hrgn=CreateRectRgn(0,0,0,0); @@ -5310,7 +5454,9 @@ static void test_scrollvalidate( HWND parent) /* create two overlapping child windows. The visual region * of hwnd1 is clipped by the overlapping part of * hwnd2 because of the WS_CLIPSIBLING style */ - HWND hwnd1, hwnd2; + HWND parent, hwnd1, hwnd2; + + if (!init_test_windows(&parent, NULL)) return;
clipping = CreateRectRgn(0,0,0,0); tmprgn = CreateRectRgn(0,0,0,0); @@ -5459,6 +5605,8 @@ static void test_scrollvalidate( HWND parent) DeleteObject( tmprgn); DestroyWindow( hwnd1); DestroyWindow( hwnd2); + + clean_test_windows(parent, NULL); }
/* couple of tests of return values of scrollbar functions @@ -5497,14 +5645,16 @@ static void test_scroll(void) DestroyWindow( hwnd); }
-static void test_scrolldc( HWND parent) +static void test_scrolldc(void) { HDC hdc; HRGN exprgn, tmprgn, hrgn; RECT rc, rc2, rcu, cliprc; - HWND hwnd1; + HWND parent, hwnd1; COLORREF colr;
+ if (!init_test_windows(&parent, NULL)) return; + hrgn = CreateRectRgn(0,0,0,0); tmprgn = CreateRectRgn(0,0,0,0); exprgn = CreateRectRgn(0,0,0,0); @@ -5569,13 +5719,17 @@ static void test_scrolldc( HWND parent) DeleteObject(exprgn); DeleteObject(tmprgn); DestroyWindow(hwnd1); + + clean_test_windows(parent, NULL); }
static void test_params(void) { - HWND hwnd; + HWND hwnd, hwndMain, hwndMain2; INT rc;
+ if (!init_test_windows( &hwndMain, &hwndMain2 )) return; + ok(!IsWindow(0), "IsWindow(0)\n"); ok(!IsWindow(HWND_BROADCAST), "IsWindow(HWND_BROADCAST)\n"); ok(!IsWindow(HWND_TOPMOST), "IsWindow(HWND_TOPMOST)\n"); @@ -5596,6 +5750,8 @@ static void test_params(void) if (!hwnd) ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "wrong last error value %d\n", GetLastError()); + + clean_test_windows( hwndMain, hwndMain2 ); }
static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu) @@ -5612,7 +5768,7 @@ static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)
ShowWindow(hwnd, SW_SHOW);
- test_nonclient_area(hwnd); + check_nonclient_area(hwnd);
SetMenu(hwnd, 0); DestroyWindow(hwnd); @@ -6666,9 +6822,11 @@ static void test_set_window_long_size(void) #ifdef _WIN64 WNDPROC wnd_proc, wnd_proc_2; LONG_PTR retval; - HWND hwnd; + HWND hwnd, hwndMain; LONG ret;
+ if (!init_test_windows( &hwndMain, NULL )) return; + /* It's not allowed to set or get 64-bit pointer values using 32-bit functions. */ hwnd = CreateWindowExA(0, "MainWindowClass", "Child window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CHILD | WS_MAXIMIZEBOX | WS_VISIBLE, 100, 100, 200, 200, hwndMain, 0, GetModuleHandleA(NULL), NULL); @@ -6795,6 +6953,8 @@ todo_wine ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#x.\n", ret);
DestroyWindow(hwnd); + + clean_test_windows( hwndMain, NULL ); #endif }
@@ -6802,9 +6962,11 @@ static void test_set_window_word_size(void) { WNDPROC wnd_proc, wnd_proc_2; LONG_PTR retval; - HWND hwnd; + HWND hwnd, hwndMain; LONG ret;
+ if (!init_test_windows( &hwndMain, NULL )) return; + /* It's not allowed to set or get 64-bit pointer values using 32-bit functions. */ hwnd = CreateWindowExA(0, "MainWindowClass", "Child window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CHILD | WS_MAXIMIZEBOX | WS_VISIBLE, 100, 100, 200, 200, hwndMain, 0, GetModuleHandleA(NULL), NULL); @@ -6882,12 +7044,17 @@ todo_wine ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#x.\n", ret);
DestroyWindow(hwnd); + + clean_test_windows( hwndMain, NULL ); }
static void test_SetWindowLong(void) { LONG_PTR retval; WNDPROC old_window_procW; + HWND hwndMain; + + if (!init_test_windows( &hwndMain, NULL )) return;
SetLastError(0xdeadbeef); retval = SetWindowLongPtrA(NULL, GWLP_WNDPROC, 0); @@ -6928,6 +7095,8 @@ static void test_SetWindowLong(void)
test_set_window_long_size(); test_set_window_word_size(); + + clean_test_windows( hwndMain, NULL ); }
static LRESULT WINAPI check_style_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -7346,14 +7515,16 @@ static void test_ShowWindow(void) } }
-static void test_ShowWindow_owned(HWND hwndMain) +static void test_ShowWindow_owned(void) { MONITORINFO mon_info = {sizeof(mon_info)}; RECT rect, orig, expect, nc; BOOL ret; - HWND hwnd, hwnd2; + HWND hwndMain, hwnd, hwnd2; LONG style;
+ if (!init_test_windows(&hwndMain, NULL)) return; + GetMonitorInfoW(MonitorFromWindow(hwndMain, MONITOR_DEFAULTTOPRIMARY), &mon_info); SetRect(&orig, 20, 20, 210, 110); hwnd = CreateWindowA("MainWindowClass", "owned", WS_CAPTION | WS_SYSMENU | @@ -7474,16 +7645,20 @@ static void test_ShowWindow_owned(HWND hwndMain)
DestroyWindow(hwnd2); DestroyWindow(hwnd); + + clean_test_windows(hwndMain, NULL); }
-static void test_ShowWindow_child(HWND hwndMain) +static void test_ShowWindow_child(void) { RECT rect, orig, expect, nc; BOOL ret; - HWND hwnd, hwnd2; + HWND hwndMain, hwnd, hwnd2; LONG style; POINT pt = {0};
+ if (!init_test_windows(&hwndMain, NULL)) return; + SetRect(&orig, 20, 20, 210, 110); hwnd = CreateWindowA("MainWindowClass", "child", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CHILD, @@ -7607,17 +7782,21 @@ static void test_ShowWindow_child(HWND hwndMain)
DestroyWindow(hwnd2); DestroyWindow(hwnd); + + clean_test_windows(hwndMain, NULL); }
-static void test_ShowWindow_mdichild(HWND hwndMain) +static void test_ShowWindow_mdichild(void) { RECT rect, orig, expect, nc; BOOL ret; - HWND mdiclient, hwnd, hwnd2; + HWND hwndMain, mdiclient, hwnd, hwnd2; LONG style; POINT pt = {0}; CLIENTCREATESTRUCT mdi_client_cs = {0,1};
+ if (!init_test_windows(&hwndMain, NULL)) return; + SetRect(&orig, 20, 20, 210, 110); GetClientRect(hwndMain, &rect); mdiclient = CreateWindowA("mdiclient", "MDI client", WS_CHILD, @@ -7736,6 +7915,8 @@ static void test_ShowWindow_mdichild(HWND hwndMain) DestroyWindow(hwnd2); DestroyWindow(hwnd); DestroyWindow(mdiclient); + + clean_test_windows(hwndMain, NULL); }
static DWORD CALLBACK enablewindow_thread(LPVOID arg) @@ -8969,12 +9150,12 @@ static LRESULT WINAPI test_thick_child_size_winproc(HWND hwnd, UINT msg, WPARAM }
#define NUMBER_OF_THICK_CHILD_TESTS 16 -static void test_thick_child_size(HWND parentWindow) +static void test_thick_child_size(void) { BOOL success; RECT childRect; RECT adjustedParentRect; - HWND childWindow; + HWND parentWindow, childWindow; LONG childWidth; LONG childHeight; LONG expectedWidth; @@ -9039,6 +9220,8 @@ static void test_thick_child_size(HWND parentWindow) "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME", };
+ if (!init_test_windows(&parentWindow, NULL)) return; + cls.style = 0; cls.lpfnWndProc = test_thick_child_size_winproc; cls.cbClsExtra = 0; @@ -9099,14 +9282,19 @@ static void test_thick_child_size(HWND parentWindow) ok(success,"DestroyWindow call failed, error: %u\n", GetLastError()); } ok(UnregisterClassA(className, GetModuleHandleA(NULL)),"UnregisterClass call failed\n"); + + clean_test_windows(parentWindow, NULL); }
-static void test_handles( HWND full_hwnd ) +static void test_handles(void) { - HWND hwnd = full_hwnd; + HWND full_hwnd, hwnd; BOOL ret; RECT rect;
+ if (!init_test_windows(&full_hwnd, NULL)) return; + hwnd = full_hwnd; + SetLastError( 0xdeadbeef ); ret = GetWindowRect( hwnd, &rect ); ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() ); @@ -9137,6 +9325,8 @@ static void test_handles( HWND full_hwnd ) ok( !ret, "GetWindowRect succeeded for %p\n", hwnd ); ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() ); #endif + + clean_test_windows(full_hwnd, NULL); }
static void test_winregion(void) @@ -10186,7 +10376,9 @@ todo_wine
static void test_window_without_child_style(void) { - HWND hwnd; + HWND hwnd, hwndMain; + + if (!init_test_windows(&hwndMain, NULL)) return;
hwnd = CreateWindowExA(0, "edit", NULL, WS_VISIBLE|WS_CHILD, 0, 0, 50, 50, hwndMain, NULL, 0, NULL); @@ -10202,6 +10394,7 @@ static void test_window_without_child_style(void) flush_events(TRUE);
DestroyWindow(hwnd); + clean_test_windows(hwndMain, NULL); }
@@ -10501,14 +10694,16 @@ static DWORD WINAPI set_foreground_thread(void *params) return 0; }
-static void test_activateapp(HWND window1) +static void test_activateapp(void) { - HWND window2, test_window; + HWND window1, window2, test_window; HANDLE thread; struct set_foreground_thread_params thread_params; DWORD tid; MSG msg;
+ if (!init_test_windows(&window1, NULL)) return; + window2 = CreateWindowExA(0, "static", "window 2", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 300, 0, 10, 10, 0, 0, 0, NULL); thread_params.msg_quit = WM_USER; @@ -10651,6 +10846,8 @@ static void test_activateapp(HWND window1)
CloseHandle(thread_params.command_executed); DestroyWindow(window2); + + clean_test_windows(window1, NULL); }
static LRESULT WINAPI winproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) @@ -10844,7 +11041,7 @@ todo_wine ok(ret, "got %d\n", ret); }
-static void test_LockWindowUpdate(HWND parent) +static void lock_window_update_tests(HWND parent, HWND child) { typedef struct { @@ -10854,7 +11051,6 @@ static void test_LockWindowUpdate(HWND parent) } TEST;
int i; - HWND child = CreateWindowA("static", 0, WS_CHILD | WS_VISIBLE, 0, 0, 20, 20, parent, 0, 0, 0);
TEST tests[] = { {child, child, 0, 0}, @@ -10867,12 +11063,6 @@ static void test_LockWindowUpdate(HWND parent) {parent, parent, 1, 1} };
- if (!child) - { - skip("CreateWindow failed, skipping LockWindowUpdate tests\n"); - return; - } - ShowWindow(parent, SW_SHOW); UpdateWindow(parent); flush_events(TRUE); @@ -10906,12 +11096,32 @@ static void test_LockWindowUpdate(HWND parent) ReleaseDC(tests[i].hwnd_draw, hdc); #undef TEST_PIXEL } +} + +static void test_LockWindowUpdate(void) +{ + HWND parent, child; + + if (!init_test_windows(&parent, NULL)) return; + + if (!(child = CreateWindowA("static", 0, WS_CHILD | WS_VISIBLE, 0, 0, 20, 20, parent, 0, 0, 0))) + { + skip("CreateWindow failed, skipping LockWindowUpdate tests\n"); + clean_test_windows(parent, NULL); + return; + } + + lock_window_update_tests(parent, child); + DestroyWindow(child); + clean_test_windows(parent, NULL); }
static void test_hide_window(void) { - HWND hwnd, hwnd2, hwnd3; + HWND hwnd, hwnd2, hwnd3, hwndMain; + + if (!init_test_windows(&hwndMain, NULL)) return;
hwnd = CreateWindowExA(0, "MainWindowClass", "Main window", WS_POPUP | WS_VISIBLE, 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL); @@ -11003,11 +11213,15 @@ static void test_hide_window(void) DestroyWindow(hwnd3); DestroyWindow(hwnd2); DestroyWindow(hwnd); + + clean_test_windows(hwndMain, NULL); }
-static void test_minimize_window(HWND hwndMain) +static void test_minimize_window(void) { - HWND hwnd, hwnd2, hwnd3; + HWND hwndMain, hwnd, hwnd2, hwnd3; + + if (!init_test_windows(&hwndMain, NULL)) return;
hwnd = CreateWindowExA(0, "MainWindowClass", "Main window", WS_POPUP | WS_VISIBLE, 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL); @@ -11116,6 +11330,8 @@ static void test_minimize_window(HWND hwndMain) DestroyWindow(hwnd3); DestroyWindow(hwnd2); DestroyWindow(hwnd); + + clean_test_windows(hwndMain, NULL); }
static void test_desktop( void ) @@ -11547,11 +11763,12 @@ if (!is_wine) /* FIXME: remove once Wine is fixed */ DestroyWindow(owner); }
-static void test_display_affinity( HWND win ) +static void test_display_affinity(void) { DWORD affinity; BOOL ret, dwm; LONG styleex; + HWND win;
if (!pGetWindowDisplayAffinity || !pSetWindowDisplayAffinity) { @@ -11559,6 +11776,8 @@ static void test_display_affinity( HWND win ) return; }
+ if (!init_test_windows(&win, NULL)) return; + ret = pGetWindowDisplayAffinity(NULL, NULL); ok(!ret, "GetWindowDisplayAffinity succeeded\n"); ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "Expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError()); @@ -11627,6 +11846,8 @@ static void test_display_affinity( HWND win ) ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%x\n", affinity);
SetWindowLongW(win, GWL_EXSTYLE, styleex); + + clean_test_windows(win, NULL); }
static struct destroy_data @@ -11797,8 +12018,10 @@ static void test_destroy_quit(void)
static void test_IsWindowEnabled(void) { + HWND hwnd, hwndMain; BOOL ret; - HWND hwnd; + + if (!init_test_windows(&hwndMain, NULL)) return;
ret = IsWindowEnabled(NULL); ok(!ret, "Expect IsWindowEnabled() return FALSE\n"); @@ -11814,6 +12037,8 @@ static void test_IsWindowEnabled(void) ret = IsWindowEnabled(hwnd); ok(!ret, "Expect IsWindowEnabled() return FALSE\n"); DestroyWindow(hwnd); + + clean_test_windows(hwndMain, NULL); }
static void test_window_placement(void) @@ -12435,9 +12660,12 @@ static void test_cancel_mode(void)
static void test_DragDetect(void) { + HWND hwndMain; POINT pt; BOOL ret;
+ if (!init_test_windows(&hwndMain, NULL)) return; + ok(!GetCapture(), "got capture window %p\n", GetCapture()); ok(!(GetKeyState( VK_LBUTTON ) & 0x8000), "got VK_LBUTTON\n");
@@ -12447,6 +12675,8 @@ static void test_DragDetect(void)
ok(!GetCapture(), "got capture window %p\n", GetCapture()); ok(!(GetKeyState( VK_LBUTTON ) & 0x8000), "got VK_LBUTTON\n"); + + clean_test_windows(hwndMain, NULL); }
START_TEST(win) @@ -12499,19 +12729,6 @@ START_TEST(win)
if (!RegisterWindowClasses()) assert(0);
- hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window", - WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | - WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE, - 100, 100, 200, 200, - 0, 0, GetModuleHandleA(NULL), NULL); - assert( hwndMain ); - - if(!SetForegroundWindow(hwndMain)) { - /* workaround for foreground lock timeout */ - simulate_click(101, 101); - ok(SetForegroundWindow(hwndMain), "SetForegroundWindow failed\n"); - } - SetLastError(0xdeafbeef); GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC);
@@ -12523,27 +12740,20 @@ START_TEST(win) test_FindWindow(); test_SetParent();
- hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2", - WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | - WS_MAXIMIZEBOX | WS_POPUP, - 100, 100, 200, 200, - 0, 0, GetModuleHandleA(NULL), NULL); - assert( hwndMain2 ); - - our_pid = GetWindowThreadProcessId(hwndMain, NULL); + our_pid = GetCurrentThreadId();
/* Add the tests below this line */ test_child_window_from_point(); test_window_from_point(argv[0]); - test_thick_child_size(hwndMain); + test_thick_child_size(); test_fullscreen(); test_hwnd_message(); - test_nonclient_area(hwndMain); + test_nonclient_area(); test_params(); test_GetWindowModuleFileName(); test_capture_1(); test_capture_2(); - test_capture_3(hwndMain, hwndMain2); + test_capture_3(); test_capture_4(); test_rtl_layout(); test_FlashWindow(); @@ -12555,26 +12765,26 @@ START_TEST(win)
test_mdi(); test_icons(); - test_SetWindowPos(hwndMain, hwndMain2); - test_SetMenu(hwndMain); - test_SetFocus(hwndMain); - test_SetActiveWindow(hwndMain); + test_SetWindowPos(); + test_SetMenu(); + test_SetFocus(); + test_SetActiveWindow(); test_NCRedraw();
- test_children_zorder(hwndMain); - test_popup_zorder(hwndMain2, hwndMain, WS_POPUP); - test_popup_zorder(hwndMain2, hwndMain, 0); + test_children_zorder(); + test_popup_zorder(WS_POPUP); + test_popup_zorder(0); test_GetLastActivePopup(); - test_keyboard_input(hwndMain); - test_mouse_input(hwndMain); - test_validatergn(hwndMain); - test_nccalcscroll( hwndMain); - test_scrollwindow( hwndMain); - test_scrollvalidate( hwndMain); - test_scrolldc( hwndMain); + test_keyboard_input(); + test_mouse_input(); + test_validatergn(); + test_nccalcscroll(); + test_scrollwindow(); + test_scrollvalidate(); + test_scrolldc(); test_scroll(); test_IsWindowUnicode(); - test_vis_rgn(hwndMain); + test_vis_rgn();
test_AdjustWindowRect(); test_window_styles(); @@ -12585,31 +12795,31 @@ START_TEST(win) test_SetWindowLong(); test_set_window_style(); test_ShowWindow(); - test_ShowWindow_owned(hwndMain); - test_ShowWindow_child(hwndMain); - test_ShowWindow_mdichild(hwndMain); + test_ShowWindow_owned(); + test_ShowWindow_child(); + test_ShowWindow_mdichild(); test_EnableWindow(); test_gettext(); test_GetUpdateRect(); test_Expose(); test_layered_window();
- test_SetForegroundWindow(hwndMain); - test_handles( hwndMain ); + test_SetForegroundWindow(); + test_handles(); test_winregion(); test_map_points(); test_update_region(); test_window_without_child_style(); test_smresult(); test_GetMessagePos(); - test_activateapp(hwndMain); + test_activateapp(); test_winproc_handles(argv[0]); test_deferwindowpos(); - test_LockWindowUpdate(hwndMain); + test_LockWindowUpdate(); test_desktop(); - test_display_affinity(hwndMain); + test_display_affinity(); test_hide_window(); - test_minimize_window(hwndMain); + test_minimize_window(); test_destroy_quit(); test_IsWindowEnabled(); test_window_placement(); @@ -12622,12 +12832,9 @@ START_TEST(win) /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook);
- DestroyWindow(hwndMain2); - DestroyWindow(hwndMain); - /* Make sure that following tests are executed last, under Windows they * tend to break the tests which are sensitive to z-order and activation - * state of hwndMain and hwndMain2 windows. + * state of windows. */ test_topmost();
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=106582
Your paranoid android.
=== w1064v1809 (32 bit report) ===
user32: win.c:9977: Test failed: WindowFromPoint returned 000301D4, expected 000202CE win.c:9984: Test failed: WindowFromPoint returned 000301D4, expected 000302B6 win.c:10068: Test failed: WindowFromPoint returned 000301D4, expected 000C0074 win.c:10076: Test failed: WindowFromPoint returned 000301D4, expected 000302B6 win.c:10005: Test failed: transparent window didn't get WM_NCHITTEST message win.c:10006: Test failed: button under static window didn't get WM_LBUTTONUP
=== w10pro64_ja (64 bit report) ===
user32: win.c:10578: Test failed: pos = 00c800c8 win.c:10582: Test failed: pos = 00c800c8 win.c:10586: Test failed: pos = 00c800c8
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10578: Test failed: pos = 00c800c8 win.c:10582: Test failed: pos = 00c800c8 win.c:10586: Test failed: pos = 00c800c8
=== debian11 (32 bit report) ===
user32: win.c:10772: Test failed: Expected foreground window 00FF00C8, got 008400B4 win.c:10774: Test failed: GetActiveWindow() = 00000000 win.c:10774: Test failed: GetFocus() = 00000000 win.c:10775: Test failed: Received WM_ACTIVATEAPP(1), did not expect it. win.c:10776: Test failed: Received WM_ACTIVATEAPP(0), did not expect it. win.c:10784: Test failed: Expected foreground window 00FF00C8, got 00000000 win.c:10786: Test failed: GetActiveWindow() = 00000000 win.c:10786: Test failed: GetFocus() = 00000000 win.c:10794: Test failed: Received WM_ACTIVATEAPP(1), did not expect it.
On 1/31/22 11:50, Marvin wrote:
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=106582
Your paranoid android.
=== w1064v1809 (32 bit report) ===
user32: win.c:9977: Test failed: WindowFromPoint returned 000301D4, expected 000202CE win.c:9984: Test failed: WindowFromPoint returned 000301D4, expected 000302B6 win.c:10068: Test failed: WindowFromPoint returned 000301D4, expected 000C0074 win.c:10076: Test failed: WindowFromPoint returned 000301D4, expected 000302B6 win.c:10005: Test failed: transparent window didn't get WM_NCHITTEST message win.c:10006: Test failed: button under static window didn't get WM_LBUTTONUP
=== w10pro64_ja (64 bit report) ===
user32: win.c:10578: Test failed: pos = 00c800c8 win.c:10582: Test failed: pos = 00c800c8 win.c:10586: Test failed: pos = 00c800c8
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10578: Test failed: pos = 00c800c8 win.c:10582: Test failed: pos = 00c800c8 win.c:10586: Test failed: pos = 00c800c8
=== debian11 (32 bit report) ===
user32: win.c:10772: Test failed: Expected foreground window 00FF00C8, got 008400B4 win.c:10774: Test failed: GetActiveWindow() = 00000000 win.c:10774: Test failed: GetFocus() = 00000000 win.c:10775: Test failed: Received WM_ACTIVATEAPP(1), did not expect it. win.c:10776: Test failed: Received WM_ACTIVATEAPP(0), did not expect it. win.c:10784: Test failed: Expected foreground window 00FF00C8, got 00000000 win.c:10786: Test failed: GetActiveWindow() = 00000000 win.c:10786: Test failed: GetFocus() = 00000000 win.c:10794: Test failed: Received WM_ACTIVATEAPP(1), did not expect it.
I think the patches help with some other failures such as pre-existing windows (like the firewall window problem after ntoskrnl.exe runs), but they apparently also add some flakiness. I'll resend without this one for now.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=48815 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 400c00ec238..ec12fdbf99d 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -169,8 +169,14 @@ static void check_active_state_(const char *file, int line, ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus()); }
-static BOOL ignore_message( UINT message ) +static BOOL ignore_message( UINT message, HWND hwnd ) { + WCHAR buffer[256]; + + if (GetClassNameW( hwnd, buffer, ARRAY_SIZE(buffer) ) == 22 && + !wcscmp( buffer, L"UserAdapterWindowClass" )) + return TRUE; + /* these are always ignored */ return (message >= 0xc000 || message == WM_GETICON || @@ -178,8 +184,7 @@ static BOOL ignore_message( UINT message ) message == WM_TIMER || message == WM_SYSTIMER || message == WM_TIMECHANGE || - message == WM_DEVICECHANGE || - message == 0x0060 /* undocumented, used by Win10 1709+ */); + message == WM_DEVICECHANGE); }
static BOOL init_test_windows( HWND *main_window, HWND *other_window ) @@ -4047,7 +4052,7 @@ static BOOL peek_message( MSG *msg ) do { ret = PeekMessageA(msg, 0, 0, 0, PM_REMOVE); - } while (ret && ignore_message(msg->message)); + } while (ret && ignore_message(msg->message, msg->hwnd)); return ret; }
@@ -4215,7 +4220,7 @@ static void test_mouse_input(void) /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) { - if (ignore_message(msg.message)) continue; + if (ignore_message(msg.message, msg.hwnd)) continue; ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message); DispatchMessageA(&msg);
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=106584
Your paranoid android.
=== w10pro64_ja (64 bit report) ===
user32: win.c:10583: Test failed: pos = 00c800c8 win.c:10587: Test failed: pos = 00c800c8 win.c:10591: Test failed: pos = 00c800c8
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10583: Test failed: pos = 00c800c8 win.c:10587: Test failed: pos = 00c800c8 win.c:10591: Test failed: pos = 00c800c8
Shows that it switches focus to some other process window and back, and only on some older Windows versions. Win10 simply returns 0 and does nothing.
Stop calling it elsewhere, as it makes focus go to an unpredictable window, which may very well not be ours.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51391 Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51130 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 214 +++++++++++++++++++++++++++++----------- 1 file changed, 155 insertions(+), 59 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index ec12fdbf99d..885f0476d0f 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -105,22 +105,6 @@ static void flush_events( BOOL remove_messages ) } }
-static BOOL wait_for_event(HANDLE event, int timeout) -{ - DWORD end_time = GetTickCount() + timeout; - MSG msg; - - do { - if(MsgWaitForMultipleObjects(1, &event, FALSE, timeout, QS_ALLINPUT) == WAIT_OBJECT_0) - return TRUE; - while(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) - DispatchMessageA(&msg); - timeout = end_time - GetTickCount(); - }while(timeout > 0); - - return FALSE; -} - /* check the values returned by the various parent/owner functions on a given window */ static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent, HWND gw_owner, HWND ga_root, HWND ga_root_owner ) @@ -187,6 +171,28 @@ static BOOL ignore_message( UINT message, HWND hwnd ) message == WM_DEVICECHANGE); }
+static DWORD wait_for_events( DWORD count, HANDLE *events, DWORD timeout ) +{ + DWORD ret, end = GetTickCount() + timeout; + MSG msg; + + while ((ret = MsgWaitForMultipleObjects( count, events, FALSE, timeout, QS_ALLINPUT )) <= count) + { + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageA( &msg ); + } + if (ret < count) return ret; + if (timeout == INFINITE) continue; + if (end <= GetTickCount()) timeout = 0; + else timeout = end - GetTickCount(); + } + + ok( ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %#x\n", ret ); + return ret; +} + static BOOL init_test_windows( HWND *main_window, HWND *other_window ) { DWORD style = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP; @@ -3517,6 +3523,130 @@ todo_wine clean_test_windows(hwnd, NULL); }
+static void test_SetActiveWindow_0_proc( char **argv ) +{ + HANDLE start_event, stop_event; + HWND hwnd, other, tmp; + BOOL ret; + + sscanf( argv[3], "%p", &other ); + start_event = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_start" ); + ok( start_event != 0, "CreateEventW failed, error %u\n", GetLastError() ); + stop_event = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_stop" ); + ok( stop_event != 0, "CreateEventW failed, error %u\n", GetLastError() ); + + hwnd = CreateWindowExA( 0, "static", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, NULL, NULL ); + ok( !!hwnd, "CreateWindowExA failed, error %u\n", GetLastError() ); + flush_events( TRUE ); + + ret = SetForegroundWindow( hwnd ); + ok( ret, "SetForegroundWindow failed, error %u\n", GetLastError() ); + + tmp = GetForegroundWindow(); + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + + SetLastError( 0xdeadbeef ); + tmp = SetActiveWindow( 0 ); + if (!tmp) ok( GetLastError() == 0xdeadbeef, "got error %u\n", GetLastError() ); + else /* < Win10 */ + { + ok( tmp == hwnd, "SetActiveWindow returned %p\n", tmp ); + todo_wine + ok( GetLastError() == 0, "got error %u\n", GetLastError() ); + + tmp = GetForegroundWindow(); + ok( tmp == other || tmp == 0, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == 0, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == 0, "GetFocus returned %p\n", tmp ); + + SetEvent( start_event ); + wait_for_events( 1, &stop_event, INFINITE ); + + tmp = GetForegroundWindow(); + todo_wine + ok( tmp == other, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == 0, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == 0, "GetFocus returned %p\n", tmp ); + } + + tmp = SetActiveWindow( 0 ); + ok( tmp == 0, "SetActiveWindow returned %p\n", tmp ); + tmp = GetForegroundWindow(); + todo_wine + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + todo_wine + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + todo_wine + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + + CloseHandle( start_event ); + CloseHandle( stop_event ); + DestroyWindow( hwnd ); +} + +static void test_SetActiveWindow_0( char **argv ) +{ + STARTUPINFOA startup = {.cb = sizeof(STARTUPINFOA)}; + PROCESS_INFORMATION info; + char cmdline[MAX_PATH]; + HANDLE events[3]; + HWND hwnd, tmp; + BOOL ret; + + if (!init_test_windows( &hwnd, NULL )) return; + SetWindowPos( hwnd, HWND_TOPMOST, 150, 150, 300, 300, SWP_FRAMECHANGED | SWP_SHOWWINDOW ); + flush_events( TRUE ); + + tmp = GetForegroundWindow(); + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + + events[1] = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_start" ); + ok( events[1] != 0, "CreateEventW failed, error %u\n", GetLastError() ); + events[2] = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_stop" ); + ok( events[2] != 0, "CreateEventW failed, error %u\n", GetLastError() ); + + sprintf( cmdline, "%s %s SetActiveWindow_0 %p", argv[0], argv[1], hwnd ); + ret = CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ); + ok( ret, "CreateProcessA failed, error %u\n", GetLastError() ); + + events[0] = info.hProcess; + if (wait_for_events( 2, events, INFINITE ) == 1) + { + tmp = GetForegroundWindow(); + todo_wine + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + todo_wine + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + todo_wine + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + SetEvent( events[2] ); + } + + wait_child_process( info.hProcess ); + CloseHandle( info.hProcess ); + CloseHandle( info.hThread ); + CloseHandle( events[1] ); + CloseHandle( events[2] ); + + clean_test_windows( hwnd, NULL ); +} + static void test_SetActiveWindow(void) { HWND hwnd, hwnd2, ret; @@ -3525,25 +3655,11 @@ static void test_SetActiveWindow(void)
flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); - SetFocus(0); - SetActiveWindow(0); check_wnd_state(0, 0, 0, 0);
ShowWindow(hwnd, SW_SHOW); check_wnd_state(hwnd, hwnd, hwnd, 0);
- SetLastError(0xdeadbeef); - ret = SetActiveWindow(0); - ok(ret == hwnd || broken(!ret) /* Win10 1809 */, "expected %p, got %p\n", hwnd, ret); - if (!ret) ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); - if (!GetActiveWindow()) /* doesn't always work on vista */ - { - check_wnd_state(0, 0, 0, 0); - ret = SetActiveWindow(hwnd); - ok(ret == 0, "SetActiveWindow returned %p instead of 0\n", ret); - } - check_wnd_state(hwnd, hwnd, hwnd, 0); - SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW); check_wnd_state(hwnd, hwnd, hwnd, 0);
@@ -3592,17 +3708,7 @@ static void test_SetActiveWindow(void) ret = SetActiveWindow(hwnd2); ok(ret == hwnd, "expected %p, got %p\n", hwnd, ret); check_wnd_state(hwnd, hwnd, hwnd, 0); - SetLastError(0xdeadbeef); - ret = SetActiveWindow(0); - ok(ret == hwnd || broken(!ret) /* Win10 1809 */, "expected %p, got %p\n", hwnd, ret); - if (!ret) ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); - if (!GetActiveWindow()) - { - ret = SetActiveWindow(hwnd2); - ok(ret == NULL, "expected NULL, got %p\n", ret); - todo_wine - check_active_state(hwnd, hwnd, hwnd); - } + DestroyWindow(hwnd2);
clean_test_windows(hwnd, NULL); @@ -3644,25 +3750,8 @@ static void test_SetForegroundWindow(void) LONG style;
if (!init_test_windows(&hwnd, NULL)) return; - - flush_events( TRUE ); - ShowWindow(hwnd, SW_HIDE); - SetFocus(0); - SetActiveWindow(0); - check_wnd_state(0, 0, 0, 0); - - ShowWindow(hwnd, SW_SHOW); check_wnd_state(hwnd, hwnd, hwnd, 0);
- SetLastError(0xdeadbeef); - hwnd2 = SetActiveWindow(0); - ok(hwnd2 == hwnd || broken(!hwnd2) /* Win10 1809 */, "expected %p, got %p\n", hwnd, hwnd2); - if (!hwnd2) ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); - if (GetActiveWindow() == hwnd) /* doesn't always work on vista */ - check_wnd_state(hwnd, hwnd, hwnd, 0); - else - check_wnd_state(0, 0, 0, 0); - ret = SetForegroundWindow(hwnd); if (!ret) { @@ -10066,7 +10155,7 @@ static void test_window_from_point(const char *argv0) startup.cb = sizeof(startup); ok(CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n"); - ok(wait_for_event(start_event, 1000), "didn't get start_event\n"); + ok(wait_for_events(1, &start_event, 1000) == 0, "didn't get start_event\n");
child = GetWindow(hwnd, GW_CHILD); win = WindowFromPoint(pt); @@ -12732,6 +12821,12 @@ START_TEST(win) return; }
+ if (argc == 4 && !strcmp( argv[2], "SetActiveWindow_0" )) + { + test_SetActiveWindow_0_proc( argv ); + return; + } + if (!RegisterWindowClasses()) assert(0);
SetLastError(0xdeafbeef); @@ -12773,6 +12868,7 @@ START_TEST(win) test_SetWindowPos(); test_SetMenu(); test_SetFocus(); + test_SetActiveWindow_0( argv ); test_SetActiveWindow(); test_NCRedraw();
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=106585
Your paranoid android.
=== w1064_2qxl (64 bit report) ===
user32: win.c:4403: Test failed: hwnd 0000000000390256/0000000000390256 message 0200 win.c:4406: Test failed: hwnd 0000000000390256/0000000000390256 message 0201
=== w10pro64_ja (64 bit report) ===
user32: win.c:10672: Test failed: pos = 00c800c8 win.c:10676: Test failed: pos = 00c800c8 win.c:10680: Test failed: pos = 00c800c8
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10672: Test failed: pos = 00c800c8 win.c:10676: Test failed: pos = 00c800c8 win.c:10680: Test failed: pos = 00c800c8
=== debian11 (32 bit Chinese:China report) ===
user32: win.c:10849: Test failed: Expected foreground window 00F700D0, got 0087005E
Can be reproduced randomly even without user32:monitor, for instance running user32:win in a fresh Win7 VM.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51392 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 885f0476d0f..639c8180e76 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -7289,7 +7289,7 @@ static void test_ShowWindow(void) { HWND hwnd; DWORD style; - RECT rcMain, rc, rcMinimized, rcClient, rcEmpty, rcMaximized, rcResized, rcNonClient; + RECT rcMain, rc, rcMinimized, rcClient, rcEmpty, rcMaximized, rcResized, rcNonClient, rcBroken; LPARAM ret; MONITORINFO mon_info; unsigned int i; @@ -7592,8 +7592,17 @@ static void test_ShowWindow(void) style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_MAXIMIZE, "Test %u: window should be maximized\n", i); GetWindowRect(hwnd, &rc); - ok(EqualRect(&rcMaximized, &rc), "Test %u: expected %s, got %s\n", - i, wine_dbgstr_rect(&rcMaximized), wine_dbgstr_rect(&rc)); + + rcBroken = rcMaximized; + if (test_style[i] & WS_THICKFRAME) + { + InflateRect(&rcBroken, -2, -2); + OffsetRect(&rcBroken, -2, -2); + } + + ok(EqualRect(&rcMaximized, &rc) || broken(EqualRect(&rcBroken, &rc)), + "Test %u: expected %s, got %s\n", i, wine_dbgstr_rect(&rcMaximized), + wine_dbgstr_rect(&rc));
ret = ShowWindow(hwnd, SW_RESTORE); ok(ret, "unexpected ret: %lu\n", ret);
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=106586
Your paranoid android.
=== w10pro64_ja (64 bit report) ===
user32: win.c:10681: Test failed: pos = 00c800c8 win.c:10685: Test failed: pos = 00c800c8 win.c:10689: Test failed: pos = 00c800c8
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10681: Test failed: pos = 00c800c8 win.c:10685: Test failed: pos = 00c800c8 win.c:10689: Test failed: pos = 00c800c8
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=106581
Your paranoid android.
=== w1064_tsign (32 bit report) ===
user32: win.c:4003: Test failed: message 0200 available