Module: wine Branch: master Commit: 1f051b8a7dd78c3adbb9687a5d681e275ffaeb49 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1f051b8a7dd78c3adbb9687a5d...
Author: Tomasz Jezierski developers@tefnet.pl Date: Mon May 19 16:17:22 2008 +0200
comctl32: Conformance test for multiple selection in listbox.
---
dlls/comctl32/tests/listview.c | 76 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 91f9d00..790d8b6 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -1127,6 +1127,81 @@ static void test_getorigin(void)
}
+static void test_multiselect(void) +{ + typedef struct t_select_task + { + const char *descr; + int initPos; + int loopVK; + int count; + int result; + } select_task; + + HWND hwnd; + DWORD r; + int i,j,item_count,selected_count; + static const int items=5; + BYTE kstate[256]; + select_task task; + + static struct t_select_task task_list[] = { + { "using VK_DOWN", 0, VK_DOWN, -1, -1 }, + { "using VK_UP", -1, VK_UP, -1, -1 }, + { "using VK_END", 0, VK_END, 1, -1 }, + { "using VK_HOME", -1, VK_HOME, 1, -1 } + }; + + + hwnd = create_listview_control(); + + for (i=0;i<items;i++) { + insert_item(hwnd, 0); + } + + item_count = (int)SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0); + + expect(items,item_count); + + for (i=0;i<4;i++) { + task = task_list[i]; + + /* deselect all items */ + ListView_SetItemState(hwnd, -1, 0, LVIS_SELECTED); + SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1); + + /* set initial position */ + SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, (task.initPos == -1 ? item_count : task.initPos)); + ListView_SetItemState(hwnd,(task.initPos == -1 ? item_count -1 : task.initPos),LVIS_SELECTED ,LVIS_SELECTED); + + selected_count = (int)SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); + + ok(selected_count == 1, "There should be only one selected item at the begining (is %d)\n",selected_count); + + /* Set SHIFT key pressed */ + GetKeyboardState(kstate); + kstate[VK_SHIFT]=0x80; + SetKeyboardState(kstate); + + for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) { + r = SendMessage(hwnd, WM_KEYDOWN, task.loopVK, 0); + expect(0,r); + r = SendMessage(hwnd, WM_KEYUP, task.loopVK, 0); + expect(0,r); + } + + selected_count = (int)SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0); + + ok((task.result == -1 ? item_count : task.result) == selected_count, "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); + } + DestroyWindow(hwnd); +} + START_TEST(listview) { HMODULE hComctl32; @@ -1163,4 +1238,5 @@ START_TEST(listview) test_item_position(); test_columns(); test_getorigin(); + test_multiselect(); }