mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
Merge branch 'combo' into 'master'
comctl32/combo: Add tests for keypresses showing search functionality See merge request wine/wine!4794
This commit is contained in:
commit
183d77b19d
2 changed files with 245 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
@ -735,6 +751,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 +2501,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 +2509,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();
|
||||
|
@ -2752,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;
|
||||
|
@ -2782,6 +2887,7 @@ START_TEST(listbox)
|
|||
test_LB_SETSEL();
|
||||
test_LBS_NODATA();
|
||||
test_LB_FINDSTRING();
|
||||
test_keypresses();
|
||||
|
||||
unload_v6_module(ctx_cookie, hCtx);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue