[PATCH resend 1/3] comctl32/tests: Add hold_key and release_key functions.
Angelo Haller
wine-devel at szanni.org
Thu Apr 28 08:20:09 CDT 2022
From: Angelo Haller <angelo at szanni.org>
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 at szanni.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 ca263cd644a..160925a073a 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -462,6 +462,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;
@@ -2356,7 +2380,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;
@@ -2423,10 +2446,7 @@ static void test_multiselect(void)
selected_count = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
ok(selected_count == 1, "expected 1, got %ld\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);
@@ -2441,10 +2461,7 @@ static void test_multiselect(void)
"Failed multiple selection %s. There should be %ld selected items (is %ld)\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);
--
2.36.0
More information about the wine-devel
mailing list