// Test various tree traversal methods. void TreeListCtrlTestCase::Traversal() { // GetParent() tests: wxTreeListItem root = m_treelist->GetRootItem(); CPPUNIT_ASSERT( !m_treelist->GetItemParent(root) ); CPPUNIT_ASSERT_EQUAL( root, m_treelist->GetItemParent(m_code) ); CPPUNIT_ASSERT_EQUAL( m_code, m_treelist->GetItemParent(m_code_osx) ); // GetFirstChild() and GetNextSibling() tests: CPPUNIT_ASSERT_EQUAL( m_code, m_treelist->GetFirstChild(root) ); CPPUNIT_ASSERT_EQUAL ( m_code_osx, m_treelist->GetNextSibling ( m_treelist->GetNextSibling ( m_treelist->GetFirstChild(m_code) ) ) ); // Get{First,Next}Item() test: unsigned numItems = 0; for ( wxTreeListItem item = m_treelist->GetFirstItem(); item.IsOk(); item = m_treelist->GetNextItem(item) ) { numItems++; } CPPUNIT_ASSERT_EQUAL( m_numItems, numItems ); }
wxTreeListItem TreeListCtrlTestCase::AddItem(const char *label, wxTreeListItem parent, const char *numFiles, const char *size) { if ( !parent.IsOk() ) parent = m_treelist->GetRootItem(); wxTreeListItem item = m_treelist->AppendItem(parent, label); m_treelist->SetItemText(item, 1, numFiles); m_treelist->SetItemText(item, 2, size); m_numItems++; return item; }