From 31a09c3b7bc0b89e59c77a1f361c095536046fe9 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 29 Oct 2007 18:32:34 -0700 Subject: [PATCH] comctl32: Add tab insert item / get focus test. --- dlls/comctl32/tests/tab.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/dlls/comctl32/tests/tab.c b/dlls/comctl32/tests/tab.c index 784901d92b2..51bb067132c 100644 --- a/dlls/comctl32/tests/tab.c +++ b/dlls/comctl32/tests/tab.c @@ -233,6 +233,26 @@ static const struct message getset_tooltip_parent_seq[] = { { 0 } }; +static const struct message insert_focus_seq[] = { + { TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 }, + { TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 }, + { TCM_INSERTITEM, sent|wparam, 1 }, + { TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 }, + { TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 }, + { TCM_INSERTITEM, sent|wparam, 2 }, + { WM_NOTIFYFORMAT, sent|defwinproc, }, + { WM_QUERYUISTATE, sent|defwinproc, }, + { WM_PARENTNOTIFY, sent|defwinproc, }, + { TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 }, + { TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 }, + { TCM_SETCURFOCUS, sent|wparam|lparam, -1, 0 }, + { TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 }, + { TCM_INSERTITEM, sent|wparam, 3 }, + { TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 }, + { 0 } +}; + + static HWND create_tabcontrol (DWORD style, DWORD mask) { @@ -810,6 +830,75 @@ static void test_getters_setters(HWND parent_wnd, INT nTabs) DestroyWindow(hTab); } +static void test_insert_focus(HWND parent_wnd) +{ + HWND hTab; + INT nTabsRetrieved; + INT r; + TCITEM tcNewTab; + DWORD mask = TCIF_TEXT|TCIF_IMAGE; + static char tabName[] = "TAB"; + tcNewTab.mask = mask; + tcNewTab.pszText = tabName; + + ok(parent_wnd != NULL, "no parent window!\n"); + + hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, mask, 0); + ok(hTab != NULL, "Failed to create tab control\n"); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0); + expect(0, nTabsRetrieved); + + r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); + expect(-1, r); + + tcNewTab.iImage = 1; + r = SendMessage(hTab, TCM_INSERTITEM, 1, (LPARAM) &tcNewTab); + expect(0, r); + + nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0); + expect(1, nTabsRetrieved); + + r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); + todo_wine { + expect(0, r); + } + + tcNewTab.iImage = 2; + r = SendMessage(hTab, TCM_INSERTITEM, 2, (LPARAM) &tcNewTab); + expect(1, r); + + nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0); + expect(2, nTabsRetrieved); + + r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); + todo_wine { + expect(0, r); + } + + r = SendMessage(hTab, TCM_SETCURFOCUS, -1, 0); + expect(0, r); + + r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); + expect(-1, r); + + tcNewTab.iImage = 3; + r = SendMessage(hTab, TCM_INSERTITEM, 3, (LPARAM) &tcNewTab); + expect(2, r); + + r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); + todo_wine { + expect(2, r); + } + + ok_sequence(sequences, TAB_SEQ_INDEX, insert_focus_seq, "insert_focus test sequence", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "insert_focus parent test sequence", FALSE); + + DestroyWindow(hTab); +} + START_TEST(tab) { HWND parent_wnd; @@ -842,5 +931,8 @@ START_TEST(tab) /* Testing getters and setters with 5 tabs */ test_getters_setters(parent_wnd, 5); + + test_insert_focus(parent_wnd); + DestroyWindow(parent_wnd); } -- 2.11.4.GIT