In preparation to fix https://bugs.winehq.org/show_bug.cgi?id=56104 and https://bugs.winehq.org/show_bug.cgi?id=42898
-- v2: comctl32/listbox: Add tests for keypresses showing search functionality comctl32/combo: Add tests for keypresses showing search functionality
From: Fabian Maurer dark.shadow4@web.de
--- dlls/comctl32/tests/combo.c | 128 ++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+)
diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 4a58b8763a4..8bfe57c835d 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -1514,6 +1514,133 @@ static void test_comboex_CBEN_GETDISPINFO(void) DestroyWindow(combo); }
+static void get_selected_value(HWND combo, char* selected) +{ + int index; + selected[0] = 0; + index = SendMessageA(combo, CB_GETCURSEL, 0, 0); + SendMessageA(combo, CB_GETLBTEXT, index, (LPARAM)selected); +} + +static void test_combo_keypresses(void) +{ + HWND combo; + BOOL dropped; + int i; + char selected[20]; + 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); + get_selected_value(combo, selected); + ok(!strcmp(selected, "a_lpha"), "Got %s\n", selected); + + SendMessageA(combo, WM_CHAR, (WPARAM)'l', 0); + get_selected_value(combo, selected); + ok(!strcmp(selected, "le"), "Got %s\n", selected); + + SendMessageA(combo, WM_CHAR, (WPARAM)'p', 0); + get_selected_value(combo, selected); + ok(!strcmp(selected, "le"), "Got %s\n", selected); + + 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); + get_selected_value(combo, selected); + ok(!strcmp(selected, "b_eta"), "Got %s\n", selected); + 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); + get_selected_value(combo, selected); + ok(!strcmp(selected, "epsilon"), "Got %s\n", selected); + 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); + get_selected_value(combo, selected); + ok(!strcmp(selected, "epsilon"), "Got %s\n", selected); + 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); + get_selected_value(combo, selected); + todo_wine + ok(!strcmp(selected, "a_lpha"), "Got %s\n", selected); + + SendMessageA(combo, WM_CHAR, (WPARAM)'l', 0); + get_selected_value(combo, selected); + todo_wine + ok(!strcmp(selected, "al_pha"), "Got %s\n", selected); + + SendMessageA(combo, WM_CHAR, (WPARAM)'p', 0); + get_selected_value(combo, selected); + todo_wine + ok(!strcmp(selected, "alpha"), "Got %s\n", selected); + + 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); + get_selected_value(combo, selected); + ok(!strcmp(selected, "b_eta"), "Got %s\n", selected); + 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); + get_selected_value(combo, selected); + todo_wine + ok(!strcmp(selected, "be_ta"), "Got %s\n", selected); + 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); + get_selected_value(combo, selected); + todo_wine + ok(!strcmp(selected, "beta"), "Got %s\n", selected); + 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); + get_selected_value(combo, selected); + todo_wine + ok(!strcmp(selected, "beta"), "Got %s\n", selected); + + DestroyWindow(combo); +} + START_TEST(combo) { ULONG_PTR ctx_cookie; @@ -1565,6 +1692,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);
From: Fabian Maurer dark.shadow4@web.de
--- dlls/comctl32/tests/listbox.c | 98 +++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index aba91384d15..b0b1bb8ca8c 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -2752,6 +2752,103 @@ static void test_LB_FINDSTRING(void) DestroyWindow( listbox ); }
+static void get_selected_value(HWND list, char* selected) +{ + int index; + selected[0] = 0; + index = SendMessageA(list, LB_GETCURSEL, 0, 0); + SendMessageA(list, LB_GETTEXT, index, (LPARAM)selected); +} + +static void test_keypresses(void) +{ + HWND list; + int i; + char selected[20]; + 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); + get_selected_value(list, selected); + ok(!strcmp(selected, "a_lpha"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'l', 0); + get_selected_value(list, selected); + ok(!strcmp(selected, "le"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'p', 0); + get_selected_value(list, selected); + ok(!strcmp(selected, "le"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'b', 0); + get_selected_value(list, selected); + ok(!strcmp(selected, "b_eta"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'e', 0); + get_selected_value(list, selected); + ok(!strcmp(selected, "epsilon"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'t', 0); + get_selected_value(list, selected); + ok(!strcmp(selected, "epsilon"), "Got %s\n", selected); + + 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); + get_selected_value(list, selected); + todo_wine + ok(!strcmp(selected, "a_lpha"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'l', 0); + get_selected_value(list, selected); + todo_wine + ok(!strcmp(selected, "al_pha"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'p', 0); + get_selected_value(list, selected); + todo_wine + ok(!strcmp(selected, "alpha"), "Got %s\n", selected); + + /* Windows needs a certain time to pass until it starts a new search */ + + SendMessageA(list, WM_CHAR, (WPARAM)'b', 0); + get_selected_value(list, selected); + todo_wine + ok(!strcmp(selected, "alpha"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'e', 0); + get_selected_value(list, selected); + todo_wine + ok(!strcmp(selected, "alpha"), "Got %s\n", selected); + + SendMessageA(list, WM_CHAR, (WPARAM)'t', 0); + get_selected_value(list, selected); + todo_wine + ok(!strcmp(selected, "alpha"), "Got %s\n", selected); + + DestroyWindow(list); +} + START_TEST(listbox) { ULONG_PTR ctx_cookie; @@ -2782,6 +2879,7 @@ START_TEST(listbox) test_LB_SETSEL(); test_LBS_NODATA(); test_LB_FINDSTRING(); + test_keypresses();
unload_v6_module(ctx_cookie, hCtx); }
On Sat Jan 20 21:08:42 2024 +0000, Fabian Maurer wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/4794/diffs?diff_id=94712&start_sha=bf571f6d25d0b812e8af4d62ced84fc2461a141a#d363145366f39f7c551133bb42fbbea9c2ebcac0_1527_1527)
Updated the tests, and took the opportunity to add a bit more to clarify the functionality I want to implement.
On Sat Jan 20 21:08:48 2024 +0000, Fabian Maurer wrote:
Updated the tests, and took the opportunity to add a bit more to clarify the functionality I want to implement.
Any feedback on the new version?
Can someone help me get this reviewed so it can be upstreamed? It's been so long...
On Sat Oct 5 23:19:45 2024 +0000, Fabian Maurer wrote:
Can someone help me get this reviewed so it can be upstreamed? It's been so long...
I will review this MR.
Zhiyi Zhang (@zhiyi) commented about dlls/comctl32/tests/listbox.c:
- get_selected_value(list, selected);
- todo_wine
- ok(!strcmp(selected, "al_pha"), "Got %s\n", selected);
- SendMessageA(list, WM_CHAR, (WPARAM)'p', 0);
- get_selected_value(list, selected);
- todo_wine
- ok(!strcmp(selected, "alpha"), "Got %s\n", selected);
- /* Windows needs a certain time to pass until it starts a new search */
- SendMessageA(list, WM_CHAR, (WPARAM)'b', 0);
- get_selected_value(list, selected);
- todo_wine
- ok(!strcmp(selected, "alpha"), "Got %s\n", selected);
The following tests seem unnecessary.
Zhiyi Zhang (@zhiyi) commented about dlls/comctl32/tests/combo.c:
- SendMessageA(combo, WM_CHAR, (WPARAM)'t', 0);
- get_selected_value(combo, selected);
- todo_wine
- ok(!strcmp(selected, "beta"), "Got %s\n", selected);
- 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);
- get_selected_value(combo, selected);
- todo_wine
- ok(!strcmp(selected, "beta"), "Got %s\n", selected);
Could you also test that after a timeout, you can start a new search with the same control? Same for the listbox tests.
On Fri Nov 15 15:40:59 2024 +0000, Zhiyi Zhang wrote:
Could you also test that after a timeout, you can start a new search with the same control? Same for the listbox tests.
You mean add a delay to make the timeout pass? I avoided that since I didn't want to prolong the tests with Sleep.
On Fri Nov 15 20:26:07 2024 +0000, Fabian Maurer wrote:
You mean add a delay to make the timeout pass? I avoided that since I didn't want to prolong the tests with Sleep.
A couple hundred milliseconds should be enough and acceptable.