Module: wine Branch: oldstable Commit: 9513e43d9ca997ec4468397e26be36ed655b3f1e URL: https://gitlab.winehq.org/wine/wine/-/commit/9513e43d9ca997ec4468397e26be36e...
Author: Angelo Haller angelo@szanni.org Date: Thu Apr 28 08:20:09 2022 -0500
comctl32/tests: Add hold_key and release_key functions.
Add functions to simulate the holding of keys like SHIFT, CTRL,...
Move existing SHIFT key press emulation to these functions.
Signed-off-by: Angelo Haller angelo@szanni.org Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 2d78448464f8e3d4f4e7419c42559de515acfcd2) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/comctl32/tests/listview.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 236a9d14372..ffdb30bcaca 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -461,6 +461,30 @@ static const struct message listview_end_label_edit_kill_focus[] = { { 0 } };
+static void hold_key(int vk) +{ + BYTE kstate[256]; + BOOL res; + + res = GetKeyboardState(kstate); + ok(res, "GetKeyboardState failed.\n"); + kstate[vk] |= 0x80; + res = SetKeyboardState(kstate); + ok(res, "SetKeyboardState failed.\n"); +} + +static void release_key(int vk) +{ + BYTE kstate[256]; + BOOL res; + + res = GetKeyboardState(kstate); + ok(res, "GetKeyboardState failed.\n"); + kstate[vk] &= ~0x80; + res = SetKeyboardState(kstate); + ok(res, "SetKeyboardState failed.\n"); +} + static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; @@ -2355,7 +2379,6 @@ static void test_multiselect(void) int i, j; static const int items=5; DWORD item_count; - BYTE kstate[256]; select_task task; LONG_PTR style; LVITEMA item; @@ -2422,10 +2445,7 @@ static void test_multiselect(void) selected_count = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); ok(selected_count == 1, "expected 1, got %d\n", selected_count);
- /* Set SHIFT key pressed */ - GetKeyboardState(kstate); - kstate[VK_SHIFT]=0x80; - SetKeyboardState(kstate); + hold_key(VK_SHIFT);
for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) { r = SendMessageA(hwnd, WM_KEYDOWN, task.loopVK, 0); @@ -2440,10 +2460,7 @@ static void test_multiselect(void) "Failed multiple selection %s. There should be %d selected items (is %d)\n", task.descr, item_count, selected_count);
- /* Set SHIFT key released */ - GetKeyboardState(kstate); - kstate[VK_SHIFT]=0x00; - SetKeyboardState(kstate); + release_key(VK_SHIFT); } DestroyWindow(hwnd);