1 /* Unit tests for treeview.
3 * Copyright 2005 Krzysztof Foltman
4 * Copyright 2007 Christopher James Peterson
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
35 #define NUM_MSG_SEQUENCES 1
36 #define LISTVIEW_SEQ_INDEX 0
38 static struct msg_sequence *MsgSequences[NUM_MSG_SEQUENCES];
40 static const struct message FillRootSeq[] = {
41 { TVM_INSERTITEM, sent },
42 { TVM_GETITEM, sent },
43 { TVM_INSERTITEM, sent },
47 static const struct message DoTest1Seq[] = {
48 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
49 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
50 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
51 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
52 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
53 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
57 static const struct message DoTest2Seq[] = {
58 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
59 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
60 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
61 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
62 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
63 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
67 static const struct message DoFocusTestSeq[] = {
68 { TVM_INSERTITEM, sent },
69 { TVM_INSERTITEM, sent },
70 { WM_WINDOWPOSCHANGING, sent|defwinproc },
71 { WM_NCCALCSIZE, sent|wparam|defwinproc, 0x00000001 },
72 { WM_WINDOWPOSCHANGED, sent|defwinproc },
73 { WM_SIZE, sent|defwinproc },
74 { WM_WINDOWPOSCHANGING, sent },
75 { WM_NCCALCSIZE, sent|wparam, 0x00000001 },
76 { WM_WINDOWPOSCHANGED, sent },
77 { WM_SIZE, sent|defwinproc },
78 { WM_WINDOWPOSCHANGING, sent|defwinproc },
79 { WM_NCCALCSIZE, sent|wparam|defwinproc, 0x00000001 },
80 { WM_WINDOWPOSCHANGED, sent|defwinproc },
81 { WM_SIZE, sent|defwinproc },
82 { TVM_SELECTITEM, sent|wparam, 0x00000009 },
83 /* The following end up out of order in wine */
84 { WM_PAINT, sent|defwinproc },
85 { WM_NCPAINT, sent|wparam|defwinproc, 0x00000001 },
86 { WM_ERASEBKGND, sent|defwinproc },
87 { TVM_EDITLABEL, sent },
88 { WM_COMMAND, sent|wparam|defwinproc, 0x04000000 },
89 { WM_COMMAND, sent|wparam|defwinproc, 0x03000000 },
90 { WM_PARENTNOTIFY, sent|wparam|defwinproc, 0x00000001 },
91 { WM_KILLFOCUS, sent|defwinproc },
92 { WM_PAINT, sent|defwinproc },
93 { WM_IME_SETCONTEXT, sent|defwinproc|optional },
94 { WM_COMMAND, sent|wparam|defwinproc, 0x01000000},
95 { WM_ERASEBKGND, sent|defwinproc },
96 { WM_CTLCOLOREDIT, sent|defwinproc|optional },
97 { WM_CTLCOLOREDIT, sent|defwinproc|optional },
101 static const struct message TestGetSetBkColorSeq[] = {
102 { TVM_GETBKCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
103 { TVM_SETBKCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
104 { TVM_GETBKCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
105 { TVM_SETBKCOLOR, sent|wparam|lparam, 0x00000000, 0x00ffffff },
106 { TVM_GETBKCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
107 { TVM_SETBKCOLOR, sent|wparam|lparam, 0x00000000, 0xffffffff },
111 static const struct message TestGetSetImageListSeq[] = {
112 { TVM_SETIMAGELIST, sent|wparam|lparam, 0x00000000, 0x00000000 },
113 { TVM_GETIMAGELIST, sent|wparam|lparam, 0x00000000, 0x00000000 },
117 static const struct message TestGetSetIndentSeq[] = {
118 { TVM_SETINDENT, sent|wparam|lparam, 0x00000000, 0x00000000 },
119 { TVM_GETINDENT, sent|wparam|lparam, 0x00000000, 0x00000000 },
120 /* The actual amount to indent is dependent on the system for this message */
121 { TVM_SETINDENT, sent },
122 { TVM_GETINDENT, sent|wparam|lparam, 0x00000000, 0x00000000 },
126 static const struct message TestGetSetInsertMarkColorSeq[] = {
127 { TVM_SETINSERTMARKCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
128 { TVM_GETINSERTMARKCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
132 static const struct message TestGetSetItemSeq[] = {
133 { TVM_GETITEM, sent },
134 { TVM_SETITEM, sent },
135 { TVM_GETITEM, sent },
136 { TVM_SETITEM, sent },
140 static const struct message TestGetSetItemHeightSeq[] = {
141 { TVM_GETITEMHEIGHT, sent|wparam|lparam, 0x00000000, 0x00000000 },
142 { TVM_SETITEMHEIGHT, sent|wparam|lparam, 0xffffffff, 0x00000000 },
143 { TVM_GETITEMHEIGHT, sent|wparam|lparam, 0x00000000, 0x00000000 },
144 { TVM_SETITEMHEIGHT, sent|lparam, 0xcccccccc, 0x00000000 },
145 { TVM_GETITEMHEIGHT, sent|wparam|lparam, 0x00000000, 0x00000000 },
146 { TVM_SETITEMHEIGHT, sent|wparam|lparam, 0x00000009, 0x00000000 },
147 { WM_WINDOWPOSCHANGING, sent|defwinproc },
148 { WM_NCCALCSIZE, sent|wparam|defwinproc, 0x00000001 },
149 { WM_WINDOWPOSCHANGED, sent|defwinproc },
150 { WM_SIZE, sent|defwinproc },
151 { TVM_GETITEMHEIGHT, sent|wparam|lparam, 0x00000000, 0x00000000 },
155 static const struct message TestGetSetScrollTimeSeq[] = {
156 { TVM_SETSCROLLTIME, sent|wparam|lparam, 0x00000014, 0x00000000 },
157 { TVM_GETSCROLLTIME, sent|wparam|lparam, 0x00000000, 0x00000000 },
161 static const struct message TestGetSetTextColorSeq[] = {
162 { TVM_GETTEXTCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
163 { TVM_SETTEXTCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
164 { TVM_GETTEXTCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
165 { TVM_SETTEXTCOLOR, sent|wparam|lparam, 0x00000000, 0x00ffffff },
166 { TVM_GETTEXTCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
167 { TVM_SETTEXTCOLOR, sent|wparam|lparam, 0x00000000, 0xffffffff },
171 static const struct message TestGetSetToolTipsSeq[] = {
172 { WM_COMMAND, sent|wparam, 0x02000000 },
173 { WM_PARENTNOTIFY, sent|wparam|defwinproc, 0x00020002 },
174 { TVM_SETTOOLTIPS, sent|wparam|lparam, 0x00000000, 0x00000000 },
175 { TVM_GETTOOLTIPS, sent|wparam|lparam, 0x00000000, 0x00000000 },
179 static const struct message TestGetSetUnicodeFormatSeq[] = {
180 { TVM_SETUNICODEFORMAT, sent|wparam|lparam, 0x00000001, 0x00000000 },
181 { TVM_GETUNICODEFORMAT, sent|wparam|lparam, 0x00000000, 0x00000000 },
182 { TVM_SETUNICODEFORMAT, sent|wparam|lparam, 0x00000000, 0x00000000 },
183 { TVM_GETUNICODEFORMAT, sent|wparam|lparam, 0x00000000, 0x00000000 },
184 { TVM_SETUNICODEFORMAT, sent|wparam|lparam, 0x00000000, 0x00000000 },
188 static HWND hMainWnd;
190 static HWND hTree, hEdit;
191 static HTREEITEM hRoot, hChild;
194 static char sequence[256];
196 static void Clear(void)
202 static void AddItem(char ch)
204 sequence[pos++] = ch;
205 sequence[pos] = '\0';
208 static void IdentifyItem(HTREEITEM hItem)
210 if (hItem == hRoot) {
214 if (hItem == hChild) {
225 static void FillRoot(void)
229 static CHAR root[] = "Root",
234 ins.hParent = TVI_ROOT;
235 ins.hInsertAfter = TVI_ROOT;
236 U(ins).item.mask = TVIF_TEXT;
237 U(ins).item.pszText = root;
238 hRoot = TreeView_InsertItem(hTree, &ins);
241 /* UMLPad 1.15 depends on this being not -1 (I_IMAGECALLBACK) */
243 tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
244 SendMessage( hTree, TVM_GETITEM, 0, (LPARAM)&tvi );
245 ok(tvi.iImage == 0, "tvi.iImage=%d\n", tvi.iImage);
246 ok(tvi.iSelectedImage == 0, "tvi.iSelectedImage=%d\n", tvi.iSelectedImage);
250 ins.hInsertAfter = TVI_FIRST;
251 U(ins).item.mask = TVIF_TEXT;
252 U(ins).item.pszText = child;
253 hChild = TreeView_InsertItem(hTree, &ins);
257 ok(!strcmp(sequence, "AB."), "Item creation\n");
260 static void DoTest1(void)
263 r = TreeView_SelectItem(hTree, NULL);
266 r = TreeView_SelectItem(hTree, hRoot);
268 r = TreeView_SelectItem(hTree, hRoot);
270 r = TreeView_SelectItem(hTree, NULL);
272 r = TreeView_SelectItem(hTree, NULL);
274 r = TreeView_SelectItem(hTree, hRoot);
276 ok(!strcmp(sequence, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test\n");
279 static void DoTest2(void)
282 r = TreeView_SelectItem(hTree, NULL);
285 r = TreeView_SelectItem(hTree, hRoot);
287 r = TreeView_SelectItem(hTree, hRoot);
289 r = TreeView_SelectItem(hTree, hChild);
291 r = TreeView_SelectItem(hTree, hChild);
293 r = TreeView_SelectItem(hTree, hRoot);
295 ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test\n");
298 static void DoFocusTest(void)
301 static CHAR child1[] = "Edit",
302 child2[] = "A really long string";
303 HTREEITEM hChild1, hChild2;
305 /* This test verifies that when a label is being edited, scrolling
306 * the treeview does not cause the label to lose focus. To test
307 * this, first some additional entries are added to generate
311 ins.hInsertAfter = hChild;
312 U(ins).item.mask = TVIF_TEXT;
313 U(ins).item.pszText = child1;
314 hChild1 = TreeView_InsertItem(hTree, &ins);
316 ins.hInsertAfter = hChild1;
317 U(ins).item.mask = TVIF_TEXT;
318 U(ins).item.pszText = child2;
319 hChild2 = TreeView_InsertItem(hTree, &ins);
322 ShowWindow(hMainWnd,SW_SHOW);
323 /* Using SendMessageA since Win98 doesn't have default unicode support */
324 SendMessageA(hTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hChild);
325 hEdit = TreeView_EditLabel(hTree, hChild);
326 ScrollWindowEx(hTree, -10, 0, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN);
327 ok(GetFocus() == hEdit, "Edit control should have focus\n");
330 static void TestGetSetBkColor(void)
332 COLORREF crColor = RGB(0,0,0);
335 /* If the value is -1, the control is using the system color for the background color. */
336 crColor = (COLORREF)SendMessage( hTree, TVM_GETBKCOLOR, 0, 0 );
337 ok(crColor == -1, "Default background color reported as 0x%.8x\n", crColor);
340 /* Test for black background */
341 SendMessage( hTree, TVM_SETBKCOLOR, 0, (LPARAM)RGB(0,0,0) );
342 crColor = (COLORREF)SendMessage( hTree, TVM_GETBKCOLOR, 0, 0 );
343 ok(crColor == RGB(0,0,0), "Black background color reported as 0x%.8x\n", crColor);
345 /* Test for white background */
346 SendMessage( hTree, TVM_SETBKCOLOR, 0, (LPARAM)RGB(255,255,255) );
347 crColor = (COLORREF)SendMessage( hTree, TVM_GETBKCOLOR, 0, 0 );
348 ok(crColor == RGB(255,255,255), "White background color reported as 0x%.8x\n", crColor);
350 /* Reset the default background */
351 SendMessage( hTree, TVM_SETBKCOLOR, 0, -1 );
354 static void TestGetSetImageList(void)
356 HIMAGELIST hImageList = NULL;
358 /* Test a NULL HIMAGELIST */
359 SendMessage( hTree, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)hImageList );
360 hImageList = (HIMAGELIST)SendMessage( hTree, TVM_GETIMAGELIST, TVSIL_NORMAL, 0 );
361 ok(hImageList == NULL, "NULL image list, reported as 0x%p, expected 0.\n", hImageList);
363 /* TODO: Test an actual image list */
366 static void TestGetSetIndent(void)
369 int ulMinIndent = -1;
370 int ulMoreThanTwiceMin = -1;
372 /* Finding the minimum indent */
373 SendMessage( hTree, TVM_SETINDENT, 0, 0 );
374 ulMinIndent = (int)SendMessage( hTree, TVM_GETINDENT, 0, 0 );
376 /* Checking an indent that is more than twice the default indent */
377 ulMoreThanTwiceMin = 2*ulMinIndent+1;
378 SendMessage( hTree, TVM_SETINDENT, ulMoreThanTwiceMin, 0 );
379 ulIndent = (DWORD)SendMessage( hTree, TVM_GETINDENT, 0, 0 );
380 ok(ulIndent == ulMoreThanTwiceMin, "Indent reported as %d, expected %d\n", ulIndent, ulMoreThanTwiceMin);
383 static void TestGetSetInsertMarkColor(void)
385 COLORREF crColor = RGB(0,0,0);
386 SendMessage( hTree, TVM_SETINSERTMARKCOLOR, 0, crColor );
387 crColor = (COLORREF)SendMessage( hTree, TVM_GETINSERTMARKCOLOR, 0, 0 );
388 ok(crColor == RGB(0,0,0), "Insert mark color reported as 0x%.8x, expected 0x00000000\n", crColor);
391 static void TestGetSetItem(void)
393 TVITEM tviRoot = {0};
394 int nBufferSize = 80;
395 char szBuffer[80] = {0};
397 /* Test the root item */
398 tviRoot.hItem = hRoot;
399 tviRoot.mask = TVIF_TEXT;
400 tviRoot.cchTextMax = nBufferSize;
401 tviRoot.pszText = szBuffer;
402 SendMessage( hTree, TVM_GETITEM, 0, (LPARAM)&tviRoot );
403 ok(!strcmp("Root", szBuffer), "GetItem: szBuffer=\"%s\", expected \"Root\"\n", szBuffer);
405 /* Change the root text */
406 strncpy(szBuffer, "Testing123", nBufferSize);
407 SendMessage( hTree, TVM_SETITEM, 0, (LPARAM)&tviRoot );
408 memset(szBuffer, 0, nBufferSize);
409 SendMessage( hTree, TVM_GETITEM, 0, (LPARAM)&tviRoot );
410 ok(!strcmp("Testing123", szBuffer), "GetItem: szBuffer=\"%s\", expected \"Testing123\"\n", szBuffer);
412 /* Reset the root text */
413 memset(szBuffer, 0, nBufferSize);
414 strncpy(szBuffer, "Root", nBufferSize);
415 SendMessage( hTree, TVM_SETITEM, 0, (LPARAM)&tviRoot );
418 static void TestGetSetItemHeight(void)
423 /* Assuming default height to begin with */
424 ulOldHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
426 /* Explicitly setting and getting the default height */
427 SendMessage( hTree, TVM_SETITEMHEIGHT, -1, 0 );
428 ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
429 ok(ulNewHeight == ulOldHeight, "Default height not set properly, reported %d, expected %d\n", ulNewHeight, ulOldHeight);
431 /* Explicitly setting and getting the height of twice the normal */
432 SendMessage( hTree, TVM_SETITEMHEIGHT, 2*ulOldHeight, 0 );
433 ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
434 ok(ulNewHeight == 2*ulOldHeight, "New height not set properly, reported %d, expected %d\n", ulNewHeight, 2*ulOldHeight);
436 /* Assuming tree doesn't have TVS_NONEVENHEIGHT set, so a set of 9 will round down to 8 */
437 SendMessage( hTree, TVM_SETITEMHEIGHT, 9, 0 );
438 ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
439 ok(ulNewHeight == 8, "Uneven height not set properly, reported %d, expected %d\n", ulNewHeight, 8);
442 static void TestGetSetScrollTime(void)
444 int ulExpectedTime = 20;
446 SendMessage( hTree, TVM_SETSCROLLTIME, ulExpectedTime, 0 );
447 ulTime = (int)SendMessage( hTree, TVM_GETSCROLLTIME, 0, 0 );
448 ok(ulTime == ulExpectedTime, "Scroll time reported as %d, expected %d\n", ulTime, ulExpectedTime);
451 static void TestGetSetTextColor(void)
453 /* If the value is -1, the control is using the system color for the text color. */
454 COLORREF crColor = RGB(0,0,0);
455 crColor = (COLORREF)SendMessage( hTree, TVM_GETTEXTCOLOR, 0, 0 );
456 ok(crColor == -1, "Default text color reported as 0x%.8x\n", crColor);
458 /* Test for black text */
459 SendMessage( hTree, TVM_SETTEXTCOLOR, 0, (LPARAM)RGB(0,0,0) );
460 crColor = (COLORREF)SendMessage( hTree, TVM_GETTEXTCOLOR, 0, 0 );
461 ok(crColor == RGB(0,0,0), "Black text color reported as 0x%.8x\n", crColor);
463 /* Test for white text */
464 SendMessage( hTree, TVM_SETTEXTCOLOR, 0, (LPARAM)RGB(255,255,255) );
465 crColor = (COLORREF)SendMessage( hTree, TVM_GETTEXTCOLOR, 0, 0 );
466 ok(crColor == RGB(255,255,255), "White text color reported as 0x%.8x\n", crColor);
468 /* Reset the default text color */
469 SendMessage( hTree, TVM_SETTEXTCOLOR, 0, -1 );
472 static void TestGetSetToolTips(void)
474 HWND hwndLastToolTip = NULL;
477 /* show even WS_POPUP treeview don't send NM_TOOLTIPSCREATED */
478 hPopupTreeView = CreateWindow(WC_TREEVIEW, NULL, WS_POPUP|WS_VISIBLE, 0, 0, 100, 100, hMainWnd, NULL, NULL, NULL);
479 DestroyWindow(hPopupTreeView);
481 /* Testing setting a NULL ToolTip */
482 SendMessage( hTree, TVM_SETTOOLTIPS, 0, 0 );
483 hwndLastToolTip = (HWND)SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 );
484 ok(hwndLastToolTip == NULL, "NULL tool tip, reported as 0x%p, expected 0.\n", hwndLastToolTip);
486 /* TODO: Add a test of an actual tooltip */
489 static void TestGetSetUnicodeFormat(void)
491 BOOL bPreviousSetting = 0;
492 BOOL bNewSetting = 0;
495 bPreviousSetting = (BOOL)SendMessage( hTree, TVM_SETUNICODEFORMAT, 1, 0 );
496 bNewSetting = (BOOL)SendMessage( hTree, TVM_GETUNICODEFORMAT, 0, 0 );
497 ok(bNewSetting == 1, "Unicode setting did not work.\n");
500 SendMessage( hTree, TVM_SETUNICODEFORMAT, 0, 0 );
501 bNewSetting = (BOOL)SendMessage( hTree, TVM_GETUNICODEFORMAT, 0, 0 );
502 ok(bNewSetting == 0, "ANSI setting did not work.\n");
504 /* Revert to original setting */
505 SendMessage( hTree, TVM_SETUNICODEFORMAT, (LPARAM)bPreviousSetting, 0 );
508 static void TestGetSet(void)
510 /* TVM_GETBKCOLOR and TVM_SETBKCOLOR */
511 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
513 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetBkColorSeq,
514 "TestGetSetBkColor", FALSE);
516 /* TVM_GETIMAGELIST and TVM_SETIMAGELIST */
517 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
518 TestGetSetImageList();
519 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetImageListSeq,
520 "TestGetImageList", FALSE);
522 /* TVM_SETINDENT and TVM_GETINDENT */
523 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
525 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetIndentSeq,
526 "TestGetSetIndent", FALSE);
528 /* TVM_GETINSERTMARKCOLOR and TVM_GETINSERTMARKCOLOR */
529 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
530 TestGetSetInsertMarkColor();
531 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetInsertMarkColorSeq,
532 "TestGetSetInsertMarkColor", FALSE);
534 /* TVM_GETITEM and TVM_SETITEM */
535 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
537 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetItemSeq,
538 "TestGetSetItem", FALSE);
540 /* TVM_GETITEMHEIGHT and TVM_SETITEMHEIGHT */
541 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
542 TestGetSetItemHeight();
543 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetItemHeightSeq,
544 "TestGetSetItemHeight", FALSE);
546 /* TVM_GETSCROLLTIME and TVM_SETSCROLLTIME */
547 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
548 TestGetSetScrollTime();
549 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetScrollTimeSeq,
550 "TestGetSetScrollTime", FALSE);
552 /* TVM_GETTEXTCOLOR and TVM_SETTEXTCOLOR */
553 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
554 TestGetSetTextColor();
555 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetTextColorSeq,
556 "TestGetSetTextColor", FALSE);
558 /* TVM_GETTOOLTIPS and TVM_SETTOOLTIPS */
559 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
560 TestGetSetToolTips();
561 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetToolTipsSeq,
562 "TestGetSetToolTips", TRUE);
564 /* TVM_GETUNICODEFORMAT and TVM_SETUNICODEFORMAT */
565 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
566 TestGetSetUnicodeFormat();
567 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, TestGetSetUnicodeFormatSeq,
568 "TestGetSetUnicodeFormat", FALSE);
571 /* This function hooks in and records all messages to the treeview control */
572 static LRESULT WINAPI TreeviewWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
574 static long defwndproc_counter = 0;
577 WNDPROC lpOldProc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
579 msg.message = message;
580 msg.flags = sent|wparam|lparam;
581 if (defwndproc_counter) msg.flags |= defwinproc;
584 add_message(MsgSequences, LISTVIEW_SEQ_INDEX, &msg);
586 defwndproc_counter++;
587 ret = CallWindowProcA(lpOldProc, hwnd, message, wParam, lParam);
588 defwndproc_counter--;
593 static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
601 hTree = CreateWindowExA(WS_EX_CLIENTEDGE, WC_TREEVIEWA, NULL, WS_CHILD|WS_VISIBLE|
602 TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS|TVS_EDITLABELS,
603 0, 0, 120, 100, hWnd, (HMENU)100, GetModuleHandleA(0), 0);
607 /* Record the old WNDPROC so we can call it after recording the messages */
608 pOldWndProc = (WNDPROC)SetWindowLongPtrA(hTree, GWLP_WNDPROC, (LONG_PTR)TreeviewWndProc);
609 SetWindowLongPtrA(hTree, GWLP_USERDATA, (LONG_PTR)pOldWndProc);
615 NMHDR *pHdr = (NMHDR *)lParam;
617 ok(pHdr->code != NM_FIRST - 19, "Treeview should not send NM_TOOLTIPSCREATED\n");
618 if (pHdr->idFrom == 100) {
619 NMTREEVIEWA *pTreeView = (LPNMTREEVIEWA) lParam;
621 case TVN_SELCHANGINGA:
623 IdentifyItem(pTreeView->itemOld.hItem);
624 IdentifyItem(pTreeView->itemNew.hItem);
626 case TVN_SELCHANGEDA:
628 IdentifyItem(pTreeView->itemOld.hItem);
629 IdentifyItem(pTreeView->itemNew.hItem);
637 MoveWindow(hTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
645 return DefWindowProcA(hWnd, msg, wParam, lParam);
655 InitCommonControls();
656 init_msg_sequences(MsgSequences, NUM_MSG_SEQUENCES);
658 wc.style = CS_HREDRAW | CS_VREDRAW;
661 wc.hInstance = GetModuleHandleA(NULL);
663 wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
664 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
665 wc.lpszMenuName = NULL;
666 wc.lpszClassName = "MyTestWnd";
667 wc.lpfnWndProc = MyWndProc;
671 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
672 CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0);
674 if ( !ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n") )
677 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
679 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, FillRootSeq, "FillRoot", FALSE);
681 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
683 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, DoTest1Seq, "DoTest1", FALSE);
685 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
687 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, DoTest2Seq, "DoTest2", FALSE);
689 flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
691 ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, DoFocusTestSeq, "DoFocusTest", TRUE);
693 /* Sequences tested inside due to number */
696 PostMessageA(hMainWnd, WM_CLOSE, 0, 0);
697 while(GetMessageA(&msg,0,0,0)) {
698 TranslateMessage(&msg);
699 DispatchMessageA(&msg);