In preparation to fix https://bugs.winehq.org/show_bug.cgi?id=56104 and https://bugs.winehq.org/show_bug.cgi?id=42898
From: Fabian Maurer dark.shadow4@web.de
--- dlls/comctl32/tests/combo.c | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 4a58b8763a4..bea5c38f1c5 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -1514,6 +1514,85 @@ 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(BOOL sort) +{ + HWND combo = create_combobox(CBS_DROPDOWNLIST | (sort ? CBS_SORT : 0)); + BOOL dropped; + int i; + char selected[20]; + const char* results[2][3]; + const char* strings_to_add[] = { + "b_eta", "a_lpha", "be_ta", "al_pha", "beta", "alpha", "gamma", "epsilon", "le" + }; + const char* results_normal[][3] = { + {"a_lpha", "le", "le"}, + {"b_eta", "epsilon", "epsilon"} + }; + const char* results_sorted[][3] = { + {"a_lpha", "al_pha", "alpha"}, + {"b_eta", "be_ta", "beta"} + }; + + memcpy(results, sort ? results_sorted : results_normal, sizeof(results)); + + 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_if(sort) + ok(!strcmp(selected, results[0][0]), "sort %d - Got %s\n", sort, selected); + + SendMessageA(combo, WM_CHAR, (WPARAM)'l', 0); + get_selected_value(combo, selected); + todo_wine_if(sort) + ok(!strcmp(selected, results[0][1]), "sort %d - Got %s\n", sort, selected); + + SendMessageA(combo, WM_CHAR, (WPARAM)'p', 0); + get_selected_value(combo, selected); + todo_wine_if(sort) + ok(!strcmp(selected, results[0][2]), "sort %d - Got %s\n", sort, 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, results[1][0]), "sort %d - Got %s\n", sort, 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_if(sort) + ok(!strcmp(selected, results[1][1]), "sort %d - Got %s\n", sort, 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_if(sort) + ok(!strcmp(selected, results[1][2]), "sort %d - Got %s\n", sort, selected); + dropped = SendMessageA(combo, CB_GETDROPPEDSTATE, 0, 0); + todo_wine + ok(dropped, "Expected combo box to be dropped\n"); + + DestroyWindow(combo); +} + START_TEST(combo) { ULONG_PTR ctx_cookie; @@ -1565,6 +1644,8 @@ START_TEST(combo) test_combo_dropdown_size(0); test_combo_dropdown_size(CBS_NOINTEGRALHEIGHT); test_combo_ctlcolor(); + test_combo_keypresses(FALSE); + test_combo_keypresses(TRUE);
cleanup(); unload_v6_module(ctx_cookie, hCtx);
Nikolay Sivov (@nsivov) commented about dlls/comctl32/tests/combo.c:
- }
- SendMessageA(combo, WM_CHAR, (WPARAM)'a', 0);
- get_selected_value(combo, selected);
- todo_wine_if(sort)
- ok(!strcmp(selected, results[0][0]), "sort %d - Got %s\n", sort, selected);
- SendMessageA(combo, WM_CHAR, (WPARAM)'l', 0);
- get_selected_value(combo, selected);
- todo_wine_if(sort)
- ok(!strcmp(selected, results[0][1]), "sort %d - Got %s\n", sort, selected);
- SendMessageA(combo, WM_CHAR, (WPARAM)'p', 0);
- get_selected_value(combo, selected);
- todo_wine_if(sort)
- ok(!strcmp(selected, results[0][2]), "sort %d - Got %s\n", sort, selected);
It would be more readable to have some strings here explicitly tested, without [x][y] on some array.
Nikolay Sivov (@nsivov) commented about dlls/comctl32/tests/combo.c:
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(BOOL sort) +{
- HWND combo = create_combobox(CBS_DROPDOWNLIST | (sort ? CBS_SORT : 0));
If this really needs a function argument, which is questionable, it might as well use style bit directly as that argument.
On Sun Jan 7 20:56:06 2024 +0000, Nikolay Sivov wrote:
It would be more readable to have some strings here explicitly tested, without [x][y] on some array.
``` if (sort) todo_wine ok(!strcmp(selected, "string1"), "sort %d - Got %s\n", sort, selected); else ok(!strcmp(selected, "string2"), "sort %d - Got %s\n", sort, selected);
```
``` ok(!strcmp(selected, sort ? "string1" : "string2"), "sort %d - Got %s\n", sort, selected); ``` Like one of those? Or something different?
On Sun Jan 7 21:02:31 2024 +0000, Fabian Maurer wrote:
if (sort) todo_wine ok(!strcmp(selected, "string1"), "sort %d - Got %s\n", sort, selected); else ok(!strcmp(selected, "string2"), "sort %d - Got %s\n", sort, selected);
ok(!strcmp(selected, sort ? "string1" : "string2"), "sort %d - Got %s\n", sort, selected);
Like one of those? Or something different?
I would just duplicate test calls.
On Sun Jan 7 20:56:07 2024 +0000, Nikolay Sivov wrote:
If this really needs a function argument, which is questionable, it might as well use style bit directly as that argument.
Well, I want to repeat the test for different styles, with different results. I could use the style as argument and use `BOOL sort = style & CSB_SORT;` if that's better? Or how would you do it?
On Sun Jan 7 21:04:02 2024 +0000, Nikolay Sivov wrote:
I would just duplicate test calls.
Like, copy the entire function and just change the strings?