]> git.saurik.com Git - wxWidgets.git/blob - tests/controls/treectrltest.cpp
Always send wxEVT_COMMAND_RICHTEXT_DELETE event if delete or back key pressed
[wxWidgets.git] / tests / controls / treectrltest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/treectrltest.cpp
3 // Purpose: wxTreeCtrl unit test
4 // Author: Vadim Zeitlin
5 // Created: 2008-11-26
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // (c) 2010 Steven Lamerton
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ----------------------------------------------------------------------------
12 // headers
13 // ----------------------------------------------------------------------------
14
15 #include "testprec.h"
16
17 #if wxUSE_TREECTRL
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/app.h"
25 #endif // WX_PRECOMP
26
27 #include "wx/artprov.h"
28 #include "wx/imaglist.h"
29 #include "wx/treectrl.h"
30 #include "wx/uiaction.h"
31 #include "testableframe.h"
32
33 // ----------------------------------------------------------------------------
34 // test class
35 // ----------------------------------------------------------------------------
36
37 class TreeCtrlTestCase : public CppUnit::TestCase
38 {
39 public:
40 TreeCtrlTestCase() { }
41
42 virtual void setUp();
43 virtual void tearDown();
44
45 private:
46 CPPUNIT_TEST_SUITE( TreeCtrlTestCase );
47 WXUISIM_TEST( ItemClick );
48 CPPUNIT_TEST( DeleteItem );
49 WXUISIM_TEST( LabelEdit );
50 WXUISIM_TEST( KeyDown );
51 #ifndef __WXGTK__
52 WXUISIM_TEST( CollapseExpandEvents );
53 WXUISIM_TEST( SelectionChange );
54 #endif // !__WXGTK__
55 WXUISIM_TEST( Menu );
56 CPPUNIT_TEST( ItemData );
57 CPPUNIT_TEST( Iteration );
58 CPPUNIT_TEST( Parent );
59 CPPUNIT_TEST( CollapseExpand );
60 CPPUNIT_TEST( AssignImageList );
61 CPPUNIT_TEST( Focus );
62 CPPUNIT_TEST( Bold );
63 CPPUNIT_TEST( Visible );
64 CPPUNIT_TEST( Sort );
65 WXUISIM_TEST( KeyNavigation );
66 CPPUNIT_TEST( HasChildren );
67 CPPUNIT_TEST( SelectItemSingle );
68 CPPUNIT_TEST( PseudoTest_MultiSelect );
69 CPPUNIT_TEST( SelectItemMulti );
70 CPPUNIT_TEST( PseudoTest_SetHiddenRoot );
71 CPPUNIT_TEST( HasChildren );
72 CPPUNIT_TEST_SUITE_END();
73
74 void ItemClick();
75 void DeleteItem();
76 void LabelEdit();
77 void KeyDown();
78 #ifndef __WXGTK__
79 void CollapseExpandEvents();
80 void SelectionChange();
81 #endif // !__WXGTK__
82 void Menu();
83 void ItemData();
84 void Iteration();
85 void Parent();
86 void CollapseExpand();
87 void AssignImageList();
88 void Focus();
89 void Bold();
90 void Visible();
91 void Sort();
92 void KeyNavigation();
93 void HasChildren();
94 void SelectItemSingle();
95 void SelectItemMulti();
96 void PseudoTest_MultiSelect() { ms_multiSelect = true; }
97 void PseudoTest_SetHiddenRoot() { ms_hiddenRoot = true; }
98
99 static bool ms_multiSelect;
100 static bool ms_hiddenRoot;
101
102 // the tree control itself
103 wxTreeCtrl *m_tree;
104
105 // and some of its items
106 wxTreeItemId m_root,
107 m_child1,
108 m_child2,
109 m_grandchild;
110
111 DECLARE_NO_COPY_CLASS(TreeCtrlTestCase)
112 };
113
114 // register in the unnamed registry so that these tests are run by default
115 CPPUNIT_TEST_SUITE_REGISTRATION( TreeCtrlTestCase );
116
117 // also include in its own registry so that these tests can be run alone
118 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreeCtrlTestCase, "TreeCtrlTestCase" );
119
120 // ----------------------------------------------------------------------------
121 // test initialization
122 // ----------------------------------------------------------------------------
123
124 bool TreeCtrlTestCase::ms_multiSelect = false;
125 bool TreeCtrlTestCase::ms_hiddenRoot = false;
126
127 void TreeCtrlTestCase::setUp()
128 {
129 m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow(),
130 wxID_ANY,
131 wxDefaultPosition,
132 wxSize(400, 200),
133 wxTR_DEFAULT_STYLE | wxTR_EDIT_LABELS);
134
135 if ( ms_multiSelect )
136 m_tree->ToggleWindowStyle(wxTR_MULTIPLE);
137
138 if ( ms_hiddenRoot )
139 m_tree->ToggleWindowStyle(wxTR_HIDE_ROOT); // actually set it
140
141 m_root = m_tree->AddRoot("root");
142 m_child1 = m_tree->AppendItem(m_root, "child1");
143 m_child2 = m_tree->AppendItem(m_root, "child2");
144 m_grandchild = m_tree->AppendItem(m_child1, "grandchild");
145
146 m_tree->SetSize(400, 200);
147 m_tree->ExpandAll();
148 m_tree->Refresh();
149 m_tree->Update();
150 }
151
152 void TreeCtrlTestCase::tearDown()
153 {
154 delete m_tree;
155 m_tree = NULL;
156
157 m_root =
158 m_child1 =
159 m_child2 =
160 m_grandchild = wxTreeItemId();
161 }
162
163 // ----------------------------------------------------------------------------
164 // the tests themselves
165 // ----------------------------------------------------------------------------
166
167 void TreeCtrlTestCase::HasChildren()
168 {
169 CPPUNIT_ASSERT( m_tree->HasChildren(m_root) );
170 CPPUNIT_ASSERT( m_tree->HasChildren(m_child1) );
171 CPPUNIT_ASSERT( !m_tree->HasChildren(m_child2) );
172 CPPUNIT_ASSERT( !m_tree->HasChildren(m_grandchild) );
173 }
174
175 void TreeCtrlTestCase::SelectItemSingle()
176 {
177 // this test should be only ran in single-selection control
178 CPPUNIT_ASSERT( !m_tree->HasFlag(wxTR_MULTIPLE) );
179
180 // initially nothing is selected
181 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child1) );
182
183 // selecting an item should make it selected
184 m_tree->SelectItem(m_child1);
185 CPPUNIT_ASSERT( m_tree->IsSelected(m_child1) );
186
187 // selecting it again shouldn't change anything
188 m_tree->SelectItem(m_child1);
189 CPPUNIT_ASSERT( m_tree->IsSelected(m_child1) );
190
191 // selecting another item should switch the selection to it
192 m_tree->SelectItem(m_child2);
193 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child1) );
194 CPPUNIT_ASSERT( m_tree->IsSelected(m_child2) );
195
196 // selecting it again still shouldn't change anything
197 m_tree->SelectItem(m_child2);
198 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child1) );
199 CPPUNIT_ASSERT( m_tree->IsSelected(m_child2) );
200
201 // deselecting an item should remove the selection entirely
202 m_tree->UnselectItem(m_child2);
203 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child1) );
204 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child2) );
205 }
206
207 void TreeCtrlTestCase::SelectItemMulti()
208 {
209 // this test should be only ran in multi-selection control
210 CPPUNIT_ASSERT( m_tree->HasFlag(wxTR_MULTIPLE) );
211
212 // initially nothing is selected
213 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child1) );
214
215 // selecting an item should make it selected
216 m_tree->SelectItem(m_child1);
217 CPPUNIT_ASSERT( m_tree->IsSelected(m_child1) );
218
219 // selecting it again shouldn't change anything
220 m_tree->SelectItem(m_child1);
221 CPPUNIT_ASSERT( m_tree->IsSelected(m_child1) );
222
223 // selecting another item shouldn't deselect the previously selected one
224 m_tree->SelectItem(m_child2);
225 CPPUNIT_ASSERT( m_tree->IsSelected(m_child1) );
226 CPPUNIT_ASSERT( m_tree->IsSelected(m_child2) );
227
228 // selecting it again still shouldn't change anything
229 m_tree->SelectItem(m_child2);
230 CPPUNIT_ASSERT( m_tree->IsSelected(m_child1) );
231 CPPUNIT_ASSERT( m_tree->IsSelected(m_child2) );
232
233 // deselecting one of the items should leave the others selected
234 m_tree->UnselectItem(m_child1);
235 CPPUNIT_ASSERT( !m_tree->IsSelected(m_child1) );
236 CPPUNIT_ASSERT( m_tree->IsSelected(m_child2) );
237 }
238
239 void TreeCtrlTestCase::ItemClick()
240 {
241 #if wxUSE_UIACTIONSIMULATOR
242 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
243 wxTestableFrame);
244
245 EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_ACTIVATED);
246 EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK);
247
248 wxUIActionSimulator sim;
249
250 wxRect pos;
251 m_tree->GetBoundingRect(m_child1, pos, true);
252
253 // We move in slightly so we are not on the edge
254 wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4);
255
256 sim.MouseMove(point);
257 wxYield();
258
259 sim.MouseDblClick();
260 wxYield();
261
262 sim.MouseClick(wxMOUSE_BTN_RIGHT);
263 wxYield();
264
265 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_ACTIVATED));
266 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK));
267 #endif // wxUSE_UIACTIONSIMULATOR
268 }
269
270 void TreeCtrlTestCase::DeleteItem()
271 {
272 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
273 wxTestableFrame);
274
275 EventCounter count(m_tree, wxEVT_COMMAND_TREE_DELETE_ITEM);
276
277 wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
278 m_tree->Delete(todelete);
279 // We do not test DeleteAllItems() as under some versions of Windows events
280 // are not generated.
281
282 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
283 }
284
285 #if wxUSE_UIACTIONSIMULATOR
286
287 void TreeCtrlTestCase::LabelEdit()
288 {
289 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
290 wxTestableFrame);
291
292 EventCounter count(m_tree, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT);
293 EventCounter count1(m_tree, wxEVT_COMMAND_TREE_END_LABEL_EDIT);
294
295 wxUIActionSimulator sim;
296
297 m_tree->SetFocusedItem(m_tree->GetRootItem());
298 m_tree->EditLabel(m_tree->GetRootItem());
299
300 sim.Text("newroottext");
301 wxYield();
302
303 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
304
305 sim.Char(WXK_RETURN);
306 wxYield();
307
308 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
309 }
310
311 void TreeCtrlTestCase::KeyDown()
312 {
313 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
314 wxTestableFrame);
315
316 EventCounter count(m_tree, wxEVT_COMMAND_TREE_KEY_DOWN);
317
318 wxUIActionSimulator sim;
319
320 m_tree->SetFocus();
321 sim.Text("aAbB");
322 wxYield();
323
324 CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
325 }
326
327 #if !defined(__WXGTK__)
328
329 void TreeCtrlTestCase::CollapseExpandEvents()
330 {
331 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
332 wxTestableFrame);
333
334 m_tree->CollapseAll();
335
336 EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
337 EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSING);
338 EventCounter count2(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDED);
339 EventCounter count3(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDING);
340
341 wxUIActionSimulator sim;
342
343 wxRect pos;
344 m_tree->GetBoundingRect(m_root, pos, true);
345
346 // We move in slightly so we are not on the edge
347 wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4);
348
349 sim.MouseMove(point);
350 wxYield();
351
352 sim.MouseDblClick();
353 wxYield();
354
355 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDING));
356 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDED));
357
358 sim.MouseDblClick();
359 wxYield();
360
361 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSING));
362 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSED));
363 }
364
365 void TreeCtrlTestCase::SelectionChange()
366 {
367 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
368 wxTestableFrame);
369
370 m_tree->ExpandAll();
371 m_tree->UnselectAll();
372
373 EventCounter count(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGED);
374 EventCounter count1(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGING);
375
376 wxUIActionSimulator sim;
377
378 wxRect poschild1, poschild2;
379 m_tree->GetBoundingRect(m_child1, poschild1, true);
380 m_tree->GetBoundingRect(m_child1, poschild2, true);
381
382 // We move in slightly so we are not on the edge
383 wxPoint point1 = m_tree->ClientToScreen(poschild1.GetPosition()) + wxPoint(4, 4);
384 wxPoint point2 = m_tree->ClientToScreen(poschild2.GetPosition()) + wxPoint(4, 4);
385
386 sim.MouseMove(point1);
387 wxYield();
388
389 sim.MouseClick();
390 wxYield();
391
392 sim.MouseMove(point2);
393 wxYield();
394
395 sim.MouseClick();
396 wxYield();
397
398 CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGED));
399 CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGING));
400 }
401
402 #endif // !__WXGTK__
403
404 void TreeCtrlTestCase::Menu()
405 {
406 wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
407 wxTestableFrame);
408
409 EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_MENU);
410 wxUIActionSimulator sim;
411
412 wxRect pos;
413 m_tree->GetBoundingRect(m_child1, pos, true);
414
415 // We move in slightly so we are not on the edge
416 wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4);
417
418 sim.MouseMove(point);
419 wxYield();
420
421 sim.MouseClick(wxMOUSE_BTN_RIGHT);
422 wxYield();
423
424 CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_MENU));
425 }
426
427 #endif // wxUSE_UIACTIONSIMULATOR
428
429 void TreeCtrlTestCase::ItemData()
430 {
431 wxTreeItemData* child1data = new wxTreeItemData();
432 wxTreeItemData* appenddata = new wxTreeItemData();
433 wxTreeItemData* insertdata = new wxTreeItemData();
434
435 m_tree->SetItemData(m_child1, child1data);
436
437 CPPUNIT_ASSERT_EQUAL(child1data, m_tree->GetItemData(m_child1));
438 CPPUNIT_ASSERT_EQUAL(m_child1, child1data->GetId());
439
440 wxTreeItemId append = m_tree->AppendItem(m_root, "new", -1, -1, appenddata);
441
442 CPPUNIT_ASSERT_EQUAL(appenddata, m_tree->GetItemData(append));
443 CPPUNIT_ASSERT_EQUAL(append, appenddata->GetId());
444
445 wxTreeItemId insert = m_tree->InsertItem(m_root, m_child1, "new", -1, -1,
446 insertdata);
447
448 CPPUNIT_ASSERT_EQUAL(insertdata, m_tree->GetItemData(insert));
449 CPPUNIT_ASSERT_EQUAL(insert, insertdata->GetId());
450 }
451
452 void TreeCtrlTestCase::Iteration()
453 {
454 // Get first / next / last child
455 wxTreeItemIdValue cookie;
456 CPPUNIT_ASSERT_EQUAL(m_tree->GetFirstChild(m_root, cookie), m_child1);
457 CPPUNIT_ASSERT_EQUAL(m_tree->GetNextChild(m_root, cookie),
458 m_tree->GetLastChild(m_root));
459 CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetLastChild(m_root));
460
461 // Get next / previous sibling
462 CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetNextSibling(m_child1));
463 CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetPrevSibling(m_child2));
464 }
465
466 void TreeCtrlTestCase::Parent()
467 {
468 CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetRootItem());
469 CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetItemParent(m_child1));
470 CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetItemParent(m_child2));
471 CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetItemParent(m_grandchild));
472 }
473
474 void TreeCtrlTestCase::CollapseExpand()
475 {
476 m_tree->ExpandAll();
477
478 CPPUNIT_ASSERT(m_tree->IsExpanded(m_root));
479 CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1));
480
481 m_tree->CollapseAll();
482
483 CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root));
484 CPPUNIT_ASSERT(!m_tree->IsExpanded(m_child1));
485
486 m_tree->ExpandAllChildren(m_root);
487
488 CPPUNIT_ASSERT(m_tree->IsExpanded(m_root));
489 CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1));
490
491 m_tree->CollapseAllChildren(m_child1);
492
493 CPPUNIT_ASSERT(!m_tree->IsExpanded(m_child1));
494
495 m_tree->Expand(m_child1);
496
497 CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1));
498
499 m_tree->Collapse(m_root);
500
501 CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root));
502 CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1));
503
504 m_tree->CollapseAndReset(m_root);
505
506 CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root));
507 }
508
509 void TreeCtrlTestCase::AssignImageList()
510 {
511 wxSize size(16, 16);
512
513 wxImageList *imagelist = new wxImageList(size.x, size.y);
514 imagelist->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size));
515
516 wxImageList *statelist = new wxImageList(size.x, size.y);
517 statelist->Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size));
518
519 m_tree->AssignImageList(imagelist);
520 m_tree->AssignStateImageList(statelist);
521
522 CPPUNIT_ASSERT_EQUAL(imagelist, m_tree->GetImageList());
523 CPPUNIT_ASSERT_EQUAL(statelist, m_tree->GetStateImageList());
524 }
525
526 void TreeCtrlTestCase::Focus()
527 {
528 #if !defined(__WXGTK__) && !defined(__WXOSX__)
529 m_tree->SetFocusedItem(m_child1);
530
531 CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetFocusedItem());
532
533 m_tree->ClearFocusedItem();
534
535 CPPUNIT_ASSERT(!m_tree->GetFocusedItem());
536 #endif
537 }
538
539 void TreeCtrlTestCase::Bold()
540 {
541 CPPUNIT_ASSERT(!m_tree->IsBold(m_child1));
542
543 m_tree->SetItemBold(m_child1);
544
545 CPPUNIT_ASSERT(m_tree->IsBold(m_child1));
546
547 m_tree->SetItemBold(m_child1, false);
548
549 CPPUNIT_ASSERT(!m_tree->IsBold(m_child1));
550 }
551
552 void TreeCtrlTestCase::Visible()
553 {
554 m_tree->CollapseAll();
555
556 CPPUNIT_ASSERT(m_tree->IsVisible(m_root));
557 CPPUNIT_ASSERT(!m_tree->IsVisible(m_child1));
558
559 m_tree->EnsureVisible(m_grandchild);
560
561 CPPUNIT_ASSERT(m_tree->IsVisible(m_grandchild));
562
563 m_tree->ExpandAll();
564
565 CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetFirstVisibleItem());
566 CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetNextVisible(m_root));
567 CPPUNIT_ASSERT_EQUAL(m_grandchild, m_tree->GetNextVisible(m_child1));
568 CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetNextVisible(m_grandchild));
569
570 CPPUNIT_ASSERT(!m_tree->GetNextVisible(m_child2));
571 CPPUNIT_ASSERT(!m_tree->GetPrevVisible(m_root));
572 }
573
574 void TreeCtrlTestCase::Sort()
575 {
576 wxTreeItemId zitem = m_tree->AppendItem(m_root, "zzzz");
577 wxTreeItemId aitem = m_tree->AppendItem(m_root, "aaaa");
578
579 m_tree->SortChildren(m_root);
580
581 wxTreeItemIdValue cookie;
582
583 CPPUNIT_ASSERT_EQUAL(aitem, m_tree->GetFirstChild(m_root, cookie));
584 CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetNextChild(m_root, cookie));
585 CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetNextChild(m_root, cookie));
586 CPPUNIT_ASSERT_EQUAL(zitem, m_tree->GetNextChild(m_root, cookie));
587 }
588
589 void TreeCtrlTestCase::KeyNavigation()
590 {
591 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
592 wxUIActionSimulator sim;
593
594 m_tree->CollapseAll();
595
596 m_tree->SelectItem(m_root);
597
598 m_tree->SetFocus();
599 sim.Char(WXK_RIGHT);
600 wxYield();
601
602 CPPUNIT_ASSERT(m_tree->IsExpanded(m_root));
603
604 sim.Char(WXK_LEFT);
605 wxYield();
606
607 CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root));
608
609 sim.Char(WXK_RIGHT);
610 sim.Char(WXK_DOWN);
611 wxYield();
612
613 CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetSelection());
614
615 sim.Char(WXK_DOWN);
616 wxYield();
617
618 CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetSelection());
619 #endif
620 }
621
622 #endif //wxUSE_TREECTRL