X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/80cc5fc7ad102221a1ce9e160eac3c29a0586664..395f3aa8bdd6b9844d59ba159b597cef61638caf:/tests/controls/listctrltest.cpp diff --git a/tests/controls/listctrltest.cpp b/tests/controls/listctrltest.cpp index 21325d6957..c1920461c9 100644 --- a/tests/controls/listctrltest.cpp +++ b/tests/controls/listctrltest.cpp @@ -19,9 +19,10 @@ #ifndef WX_PRECOMP #include "wx/app.h" - #include "wx/listctrl.h" #endif // WX_PRECOMP +#include "wx/listctrl.h" + // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- @@ -39,11 +40,13 @@ private: #ifdef wxHAS_LISTCTRL_COLUMN_ORDER CPPUNIT_TEST( ColumnsOrder ); #endif // wxHAS_LISTCTRL_COLUMN_ORDER + CPPUNIT_TEST( ItemRect ); CPPUNIT_TEST_SUITE_END(); #ifdef wxHAS_LISTCTRL_COLUMN_ORDER void ColumnsOrder(); #endif // wxHAS_LISTCTRL_COLUMN_ORDER + void ItemRect(); wxListCtrl *m_list; @@ -63,6 +66,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListCtrlTestCase, "ListCtrlTestCase" ); void ListCtrlTestCase::setUp() { m_list = new wxListCtrl(wxTheApp->GetTopWindow()); + m_list->SetWindowStyle(wxLC_REPORT); } void ListCtrlTestCase::tearDown() @@ -141,3 +145,33 @@ void ListCtrlTestCase::ColumnsOrder() } #endif // wxHAS_LISTCTRL_COLUMN_ORDER + +void ListCtrlTestCase::ItemRect() +{ + // set up for the test + m_list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); + m_list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); + m_list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); + + m_list->InsertItem(0, "Item 0"); + m_list->SetItem(0, 1, "first column"); + m_list->SetItem(0, 1, "second column"); + + // do test + wxRect r; + CPPUNIT_ASSERT( !m_list->GetItemRect(1, r) ); + CPPUNIT_ASSERT( m_list->GetItemRect(0, r) ); + CPPUNIT_ASSERT_EQUAL( 150, r.GetWidth() ); + + CPPUNIT_ASSERT( m_list->GetSubItemRect(0, 0, r) ); + CPPUNIT_ASSERT_EQUAL( 60, r.GetWidth() ); + + CPPUNIT_ASSERT( m_list->GetSubItemRect(0, 1, r) ); + CPPUNIT_ASSERT_EQUAL( 50, r.GetWidth() ); + + CPPUNIT_ASSERT( m_list->GetSubItemRect(0, 2, r) ); + CPPUNIT_ASSERT_EQUAL( 40, r.GetWidth() ); + + WX_ASSERT_FAILS_WITH_ASSERT( m_list->GetSubItemRect(0, 3, r) ); +} +