[PATCH v5 0/3] MR4794: comctl32/combo: Add tests for keypresses showing search functionality
In preparation to fix https://bugs.winehq.org/show_bug.cgi?id=56104 and https://bugs.winehq.org/show_bug.cgi?id=42898 -- v5: comctl32/listbox: Add tests for keypresses showing search functionality. comctl32/combo: Add tests for keypresses showing search functionality. comctl32/listbox: Close a few leaked window handles. https://gitlab.winehq.org/wine/wine/-/merge_requests/4794
From: Fabian Maurer <dark.shadow4(a)web.de> --- dlls/comctl32/tests/listbox.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index aba91384d15..1e023d5f372 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -735,6 +735,7 @@ static void test_LB_SETCURSEL(void) ok(ret == -1, "Unexpected anchor index %d.\n", ret); DestroyWindow(hLB); + DestroyWindow(parent); } static void test_LB_SETSEL(void) @@ -2484,6 +2485,7 @@ static void test_WM_MEASUREITEM(void) data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0); ok(data == (LRESULT)strings[0], "data = %08Ix, expected %p\n", data, strings[0]); + DestroyWindow(listbox); DestroyWindow(parent); parent = create_parent(); @@ -2491,6 +2493,8 @@ static void test_WM_MEASUREITEM(void) data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0); ok(!data, "data = %08Ix\n", data); + DestroyWindow(listbox); + DestroyWindow(parent); /* LBS_HASSTRINGS */ parent = create_parent(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4794
From: Fabian Maurer <dark.shadow4(a)web.de> --- dlls/comctl32/tests/combo.c | 139 ++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 4a58b8763a4..1040b863b13 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -57,6 +57,22 @@ static char *textBuffer = NULL; static BOOL received_end_edit = FALSE; +/* try to make sure pending X events have been processed before continuing */ +static void flush_events(void) +{ + MSG msg; + int diff = 200; + int min_timeout = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + diff = time - GetTickCount(); + } +} + static void get_combobox_info(HWND hwnd, COMBOBOXINFO *info) { BOOL ret; @@ -1514,6 +1530,128 @@ static void test_comboex_CBEN_GETDISPINFO(void) DestroyWindow(combo); } +#define ok_selected_value(list, selected) \ + _ok_selected_value(list, selected, __LINE__) +static void _ok_selected_value(HWND combo, const char *selected, int line) +{ + char buffer[20] = {0}; + int index = SendMessageA(combo, CB_GETCURSEL, 0, 0); + SendMessageA(combo, CB_GETLBTEXT, index, (LPARAM)buffer); + ok_(__FILE__, line)(!strcmp(buffer, selected), "Got %s\n", buffer); +} + +static void test_combo_keypresses(void) +{ + HWND combo; + BOOL dropped; + int i; + const char *strings_to_add[] = { + "b_eta", "a_lpha", "be_ta", "al_pha", "beta", "alpha", "gamma", "epsilon", "le" + }; + + /* Test with an unsorted combo box */ + + combo = create_combobox(CBS_DROPDOWNLIST); + + for (i = 0; i < ARRAY_SIZE(strings_to_add); i++) + { + SendMessageA(combo, CB_ADDSTRING, 0, (LPARAM)strings_to_add[i]); + } + + SendMessageA(combo, WM_CHAR, (WPARAM)'a', 0); + ok_selected_value(combo, "a_lpha"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'l', 0); + ok_selected_value(combo, "le"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'p', 0); + ok_selected_value(combo, "le"); + + SendMessageA(combo, CB_SHOWDROPDOWN, TRUE, 0); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + ok(dropped, "Expected combo box to be dropped\n"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'b', 0); + ok_selected_value(combo, "b_eta"); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'e', 0); + ok_selected_value(combo, "epsilon"); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'t', 0); + ok_selected_value(combo, "epsilon"); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + DestroyWindow(combo); + + /* Test with a sorted combo box */ + + combo = create_combobox(CBS_DROPDOWNLIST | CBS_SORT); + + for (i = 0; i < ARRAY_SIZE(strings_to_add); i++) + { + SendMessageA(combo, CB_ADDSTRING, 0, (LPARAM)strings_to_add[i]); + } + + SendMessageA(combo, WM_CHAR, (WPARAM)'a', 0); + todo_wine + ok_selected_value(combo, "a_lpha"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'l', 0); + todo_wine + ok_selected_value(combo, "al_pha"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'p', 0); + todo_wine + ok_selected_value(combo, "alpha"); + + SendMessageA(combo, CB_SHOWDROPDOWN, TRUE, 0); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + ok(dropped, "Expected combo box to be dropped\n"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'b', 0); + ok_selected_value(combo, "b_eta"); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'e', 0); + todo_wine + ok_selected_value(combo, "be_ta"); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + SendMessageA(combo, WM_CHAR, (WPARAM)'t', 0); + todo_wine + ok_selected_value(combo, "beta"); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + /* Windows needs a certain time to pass until it starts a new search */ + + SendMessageA(combo, WM_CHAR, (WPARAM)'a', 0); + todo_wine + ok_selected_value(combo, "beta"); + + Sleep(2100); + flush_events(); + + SendMessageA(combo, WM_CHAR, (WPARAM)'a', 0); + todo_wine + ok_selected_value(combo, "a_lpha"); + + DestroyWindow(combo); +} + START_TEST(combo) { ULONG_PTR ctx_cookie; @@ -1565,6 +1703,7 @@ START_TEST(combo) test_combo_dropdown_size(0); test_combo_dropdown_size(CBS_NOINTEGRALHEIGHT); test_combo_ctlcolor(); + test_combo_keypresses(); cleanup(); unload_v6_module(ctx_cookie, hCtx); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4794
From: Fabian Maurer <dark.shadow4(a)web.de> --- dlls/comctl32/tests/listbox.c | 102 ++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index 1e023d5f372..399df20cb6d 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -76,6 +76,22 @@ static unsigned hash_Ly(const char *str) return hash; } +/* try to make sure pending X events have been processed before continuing */ +static void flush_events(void) +{ + MSG msg; + int diff = 200; + int min_timeout = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + diff = time - GetTickCount(); + } +} + static const char * const strings[4] = { "First added", "Second added", @@ -2756,6 +2772,91 @@ static void test_LB_FINDSTRING(void) DestroyWindow( listbox ); } +#define ok_selected_value(list, selected) \ + _ok_selected_value(list, selected, __LINE__) +static void _ok_selected_value(HWND list, const char *selected, int line) +{ + char buffer[20] = {0}; + int index = SendMessageA(list, LB_GETCURSEL, 0, 0); + SendMessageA(list, LB_GETTEXT, index, (LPARAM)buffer); + ok_(__FILE__, line)(!strcmp(buffer, selected), "Got %s\n", buffer); +} + +static void test_keypresses(void) +{ + HWND list; + int i; + const char *strings_to_add[] = { + "b_eta", "a_lpha", "be_ta", "al_pha", "beta", "alpha", "gamma", "epsilon", "le" + }; + + /* Test with an unsorted list */ + + list = CreateWindowA(WC_LISTBOXA, "TestList", (LBS_STANDARD & ~LBS_SORT), 0, 0, 100, 100, NULL, NULL, NULL, 0); + ok(list != NULL, "Failed to create listbox window.\n"); + + for (i = 0; i < ARRAY_SIZE(strings_to_add); i++) + { + SendMessageA(list, LB_ADDSTRING, 0, (LPARAM)strings_to_add[i]); + } + + SendMessageA(list, WM_CHAR, (WPARAM)'a', 0); + ok_selected_value(list, "a_lpha"); + + SendMessageA(list, WM_CHAR, (WPARAM)'l', 0); + ok_selected_value(list, "le"); + + SendMessageA(list, WM_CHAR, (WPARAM)'p', 0); + ok_selected_value(list, "le"); + + SendMessageA(list, WM_CHAR, (WPARAM)'b', 0); + ok_selected_value(list, "b_eta"); + + SendMessageA(list, WM_CHAR, (WPARAM)'e', 0); + ok_selected_value(list, "epsilon"); + + SendMessageA(list, WM_CHAR, (WPARAM)'t', 0); + ok_selected_value(list, "epsilon"); + + DestroyWindow(list); + + /* Test with a sorted list */ + + list = CreateWindowA(WC_LISTBOXA, "TestList", LBS_STANDARD, 0, 0, 100, 100, NULL, NULL, NULL, 0); + + for (i = 0; i < ARRAY_SIZE(strings_to_add); i++) + { + SendMessageA(list, LB_ADDSTRING, 0, (LPARAM)strings_to_add[i]); + } + + SendMessageA(list, WM_CHAR, (WPARAM)'a', 0); + todo_wine + ok_selected_value(list, "a_lpha"); + + SendMessageA(list, WM_CHAR, (WPARAM)'l', 0); + todo_wine + ok_selected_value(list, "al_pha"); + + SendMessageA(list, WM_CHAR, (WPARAM)'p', 0); + todo_wine + ok_selected_value(list, "alpha"); + + /* Windows needs a certain time to pass until it starts a new search */ + + SendMessageA(list, WM_CHAR, (WPARAM)'b', 0); + todo_wine + ok_selected_value(list, "alpha"); + + Sleep(2100); + flush_events(); + + SendMessageA(list, WM_CHAR, (WPARAM)'b', 0); + todo_wine + ok_selected_value(list, "b_eta"); + + DestroyWindow(list); +} + START_TEST(listbox) { ULONG_PTR ctx_cookie; @@ -2786,6 +2887,7 @@ START_TEST(listbox) test_LB_SETSEL(); test_LBS_NODATA(); test_LB_FINDSTRING(); + test_keypresses(); unload_v6_module(ctx_cookie, hCtx); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4794
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=149774 Your paranoid android. === w864 (32 bit report) === comctl32: listbox.c:1326: Test failed: SendMessage(LB_DIR, DDL_DRIVES, *) filled with 10 entries, expected 11 listbox.c:1389: Test failed: SendMessage(LB_DIR, DDL_DIRECTORY|DDL_DRIVES) filled with 12 entries, expected 13
On Tue Nov 19 13:39:53 2024 +0000, Zhiyi Zhang wrote:
It's still missing for this commit. Sorry, fixed now...
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/4794#note_88038
This merge request was approved by Zhiyi Zhang. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4794
participants (4)
-
Fabian Maurer -
Fabian Maurer (@DarkShadow44) -
Marvin -
Zhiyi Zhang (@zhiyi)