Remove a check for SetFocus() return value. It's useless and SetFocus() returns NULL because there is no previous focus window, skipping following tests unintentionally. And cleanup some code.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/tests/dialog.c | 102 ++++++++++++++----------------------- 1 file changed, 39 insertions(+), 63 deletions(-)
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index 070ddcebb7..b72f08816d 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -148,6 +148,11 @@ static const h_entry hierarchy [] = { {0, 0, 0, 0} };
+static DWORD get_button_style(HWND button) +{ + return GetWindowLongW(button, GWL_STYLE) & BS_TYPEMASK; +} + static BOOL CreateWindows (HINSTANCE hinst) { const h_entry *p = hierarchy; @@ -155,7 +160,7 @@ static BOOL CreateWindows (HINSTANCE hinst) while (p->id != 0) { DWORD style, exstyle; - char ctrlname[9]; + char ctrlname[16];
/* Basically assert that the hierarchy is valid and track the * maximum control number @@ -633,76 +638,47 @@ static void test_WM_NEXTDLGCTL(void) * BS_DEFPUSHBUTTON with out making it default. */
- /* - * Keep the focus on Edit control. - */ - - if ( SetFocus( g_hwndTestDlgEdit ) ) - { - ok ((GetFocus() == g_hwndTestDlgEdit), "Focus didn't set on Edit control\n"); + /* Keep the focus on Edit control. */ + SetFocus(g_hwndTestDlgEdit); + ok((GetFocus() == g_hwndTestDlgEdit), "Focus didn't set on Edit control\n");
- /* - * Test message WM_NEXTDLGCTL - */ - DefDlgProcA( g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0 ); - ok ((GetFocus() == g_hwndTestDlgBut1), "Focus didn't move to first button\n"); + /* Test message WM_NEXTDLGCTL */ + DefDlgProcA(g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0); + ok((GetFocus() == g_hwndTestDlgBut1), "Focus didn't move to first button\n");
- /* - * Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" - */ - dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); - ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); - - /* - * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and - * the style of default button changed to BS_PUSHBUTTON. - */ - if ( IDCANCEL == (LOWORD(dwVal)) ) - { - ok ( ((GetWindowLongA( g_hwndTestDlgBut1, GWL_STYLE)) & BS_DEFPUSHBUTTON), - "Button1 style not set to BS_DEFPUSHBUTTON\n" ); - - ok ( !((GetWindowLongA( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON), - "Button2's style not changed to BS_PUSHBUTTON\n" ); - } + /* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" */ + dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); + ok(IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
- /* - * Move focus to Button2 using "WM_NEXTDLGCTL" - */ - DefDlgProcA( g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0 ); - ok ((GetFocus() == g_hwndTestDlgBut2), "Focus didn't move to second button\n"); + /* + * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and + * the style of default button changed to BS_PUSHBUTTON. + */ + ok(get_button_style(g_hwndTestDlgBut1) == BS_DEFPUSHBUTTON, "Button1's style not set to BS_DEFPUSHBUTTON"); + ok(get_button_style(g_hwndTestDlgBut2) == BS_PUSHBUTTON, "Button2's style not set to BS_PUSHBUTTON");
- /* - * Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" - */ - dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); - ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); + /* Move focus to Button2 using "WM_NEXTDLGCTL" */ + DefDlgProcA(g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0); + ok((GetFocus() == g_hwndTestDlgBut2), "Focus didn't move to second button\n");
- /* - * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and - * the style of button which lost the focus changed to BS_PUSHBUTTON. - */ - if ( IDCANCEL == (LOWORD(dwVal)) ) - { - ok ( ((GetWindowLongA( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON), - "Button2 style not set to BS_DEFPUSHBUTTON\n" ); + /* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" */ + dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); + ok(IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
- ok ( !((GetWindowLongA( g_hwndTestDlgBut1, GWL_STYLE)) & BS_DEFPUSHBUTTON), - "Button1's style not changed to BS_PUSHBUTTON\n" ); - } + /* + * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and + * the style of button which lost the focus changed to BS_PUSHBUTTON. + */ + ok(get_button_style(g_hwndTestDlgBut1) == BS_PUSHBUTTON, "Button1's style not set to BS_PUSHBUTTON"); + ok(get_button_style(g_hwndTestDlgBut2) == BS_DEFPUSHBUTTON, "Button2's style not set to BS_DEFPUSHBUTTON");
- /* - * Move focus to Edit control using "WM_NEXTDLGCTL" - */ - DefDlgProcA( g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0 ); - ok ((GetFocus() == g_hwndTestDlgEdit), "Focus didn't move to Edit control\n"); + /* Move focus to Edit control using "WM_NEXTDLGCTL" */ + DefDlgProcA(g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0); + ok((GetFocus() == g_hwndTestDlgEdit), "Focus didn't move to Edit control\n");
- /* - * Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" - */ - dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); - ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); - } + /* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" */ + dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); + ok(IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
/* test nested default buttons */
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=55808
Your paranoid android.
=== wvistau64 (task log) ===
Task errors: The previous 1 run(s) terminated abnormally