From: Angelo Haller angelo@szanni.org
This is a resend of the follow up on the listview LVN_ODSTATECHANGED fixes I sent in a while ago. These are the missing tests that were requested for the fixes that I will resubmit once this gets merged.
The first two patches are fairly straight forward: refactoring and adding basic tests. The third one adds a new message test sequence.
I have tried to use one of the existing PARENT_SEQ_INDEX sequences, it just turns out that that particular sequence gets spammed with many unrelated messages. Many messages that are being sent out of order and/or that concern other listview aspects: LVN_GETDISPINFOA NM_CUSTOMDRAW WM_CHANGEUISTATE
Hence I introduced a new PARENT_ODSTATECHANGED_SEQ_INDEX to enable better testing of ownerdata listviews.
Warning: I have had access to the Windows Research Kernel (WRK) 1.2 ~10 years ago. These changes are regarding comctrl32 & tests which are NOT part of the WRK. As outlined in https://wiki.winehq.org/Developer_FAQ this should therefore satisfy the requirement of ONLY submitting patches to components I have NOT had access to.
Angelo Haller (3): comctl32/tests: Add hold_key and release_key functions. comctl32/tests: Add multi select tests for ownerdata listviews. comctl32/tests: Add change sequence for ownerdata listviews.
dlls/comctl32/tests/listview.c | 114 ++++++++++++++++++++++++++++++--- 1 file changed, 105 insertions(+), 9 deletions(-)
Signed-off-by: Angelo Haller angelo@szanni.org
From: Angelo Haller angelo@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@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);
From: Angelo Haller angelo@szanni.org
Add tests for selecting multiple items in ownerdata listviews by using SHIFT/CTRL and arrow keys.
Signed-off-by: Angelo Haller angelo@szanni.org --- dlls/comctl32/tests/listview.c | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 160925a073a..124f463908e 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -3530,6 +3530,56 @@ static void test_ownerdata(void) DestroyWindow(hwnd); }
+static void test_ownerdata_multiselect(void) +{ + HWND hwnd; + DWORD res; + LVITEMA item; + + hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT); + ok(hwnd != NULL, "failed to create a listview window\n"); + res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 20, 0); + expect(1, res); + res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); + expect(0, res); + + memset(&item, 0, sizeof(item)); + item.state = LVIS_SELECTED | LVIS_FOCUSED; + item.stateMask = LVIS_SELECTED | LVIS_FOCUSED; + res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item); + expect(TRUE, res); + res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); + expect(1, res); + + res = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, 0); + expect(0, res); + + hold_key(VK_SHIFT); + + res = SendMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0); + expect(0, res); + res = SendMessageA(hwnd, WM_KEYUP, VK_DOWN, 0); + expect(0, res); + + res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); + expect(2, res); + + hold_key(VK_CONTROL); + + res = SendMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0); + expect(0, res); + res = SendMessageA(hwnd, WM_KEYUP, VK_DOWN, 0); + expect(0, res); + + release_key(VK_CONTROL); + release_key(VK_SHIFT); + + res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); + expect(3, res); + + DestroyWindow(hwnd); +} + static void test_norecompute(void) { static CHAR testA[] = "test"; @@ -6878,6 +6928,7 @@ START_TEST(listview) test_subitem_rect(); test_sorting(); test_ownerdata(); + test_ownerdata_multiselect(); test_norecompute(); test_nosortheader(); test_setredraw(); @@ -6937,6 +6988,7 @@ START_TEST(listview) test_columns(); test_sorting(); test_ownerdata(); + test_ownerdata_multiselect(); test_norecompute(); test_nosortheader(); test_indentation();
From: Angelo Haller angelo@szanni.org
Add a new test sequence for ownerdata listviews that logs solely item change notifications for single and multiple items changing. Use it in the ownerdata multiselect tests.
Signed-off-by: Angelo Haller angelo@szanni.org --- dlls/comctl32/tests/listview.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 124f463908e..6ac7f53137d 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -37,6 +37,7 @@ enum seq_index { PARENT_SEQ_INDEX, PARENT_FULL_SEQ_INDEX, PARENT_CD_SEQ_INDEX, + PARENT_ODSTATECHANGED_SEQ_INDEX, LISTVIEW_SEQ_INDEX, EDITBOX_SEQ_INDEX, COMBINED_SEQ_INDEX, @@ -254,6 +255,14 @@ static const struct message ownerdata_deselect_all_parent_seq[] = { { 0 } };
+static const struct message ownerdata_multiselect_odstatechanged_seq[] = { + { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED }, + { WM_NOTIFY, sent|id, 0, 0, LVN_ODSTATECHANGED }, + { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED }, + { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED }, + { 0 } +}; + static const struct message change_all_parent_seq[] = { { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING }, { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED }, @@ -523,6 +532,10 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP add_message(sequences, PARENT_SEQ_INDEX, &msg); add_message(sequences, COMBINED_SEQ_INDEX, &msg); } + /* log change messages for single and multiple items changing in ownerdata listviews */ + if (message == WM_NOTIFY && (msg.id == LVN_ITEMCHANGED || msg.id == LVN_ODSTATECHANGED)) + add_message(sequences, PARENT_ODSTATECHANGED_SEQ_INDEX, &msg); + add_message(sequences, PARENT_FULL_SEQ_INDEX, &msg);
switch (message) @@ -3556,8 +3569,15 @@ static void test_ownerdata_multiselect(void)
hold_key(VK_SHIFT);
+ flush_sequences(sequences, NUM_MSG_SEQUENCES); + res = SendMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0); expect(0, res); + + ok_sequence(sequences, PARENT_ODSTATECHANGED_SEQ_INDEX, + ownerdata_multiselect_odstatechanged_seq, + "ownerdata select multiple notification", TRUE); + res = SendMessageA(hwnd, WM_KEYUP, VK_DOWN, 0); expect(0, res);
@@ -3566,8 +3586,15 @@ static void test_ownerdata_multiselect(void)
hold_key(VK_CONTROL);
+ flush_sequences(sequences, NUM_MSG_SEQUENCES); + res = SendMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0); expect(0, res); + + ok_sequence(sequences, PARENT_ODSTATECHANGED_SEQ_INDEX, + ownerdata_multiselect_odstatechanged_seq, + "ownerdata select multiple notification", TRUE); + res = SendMessageA(hwnd, WM_KEYUP, VK_DOWN, 0); expect(0, res);