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>
This commit is contained in:
parent
753fbb28d5
commit
2d78448464
|
@ -462,6 +462,30 @@ static const struct message listview_end_label_edit_kill_focus[] = {
|
||||||
{ 0 }
|
{ 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 LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static LONG defwndproc_counter = 0;
|
static LONG defwndproc_counter = 0;
|
||||||
|
@ -2356,7 +2380,6 @@ static void test_multiselect(void)
|
||||||
int i, j;
|
int i, j;
|
||||||
static const int items=5;
|
static const int items=5;
|
||||||
DWORD item_count;
|
DWORD item_count;
|
||||||
BYTE kstate[256];
|
|
||||||
select_task task;
|
select_task task;
|
||||||
LONG_PTR style;
|
LONG_PTR style;
|
||||||
LVITEMA item;
|
LVITEMA item;
|
||||||
|
@ -2423,10 +2446,7 @@ static void test_multiselect(void)
|
||||||
selected_count = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
|
selected_count = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
|
||||||
ok(selected_count == 1, "expected 1, got %ld\n", selected_count);
|
ok(selected_count == 1, "expected 1, got %ld\n", selected_count);
|
||||||
|
|
||||||
/* Set SHIFT key pressed */
|
hold_key(VK_SHIFT);
|
||||||
GetKeyboardState(kstate);
|
|
||||||
kstate[VK_SHIFT]=0x80;
|
|
||||||
SetKeyboardState(kstate);
|
|
||||||
|
|
||||||
for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) {
|
for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) {
|
||||||
r = SendMessageA(hwnd, WM_KEYDOWN, task.loopVK, 0);
|
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",
|
"Failed multiple selection %s. There should be %ld selected items (is %ld)\n",
|
||||||
task.descr, item_count, selected_count);
|
task.descr, item_count, selected_count);
|
||||||
|
|
||||||
/* Set SHIFT key released */
|
release_key(VK_SHIFT);
|
||||||
GetKeyboardState(kstate);
|
|
||||||
kstate[VK_SHIFT]=0x00;
|
|
||||||
SetKeyboardState(kstate);
|
|
||||||
}
|
}
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue