]> git.saurik.com Git - wxWidgets.git/commitdiff
Avoid asserts due to not overriding OnGetItemText() in VirtListCtrlTestCase.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 16 Nov 2010 22:38:26 +0000 (22:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 16 Nov 2010 22:38:26 +0000 (22:38 +0000)
A virtual list control must override wxListCtrl::OnGetItemText() method and
wxMSW native implementation asserts if this is not the case (the generic one
should arguably do it as well).

Avoid the asserts by providing a dummy implementation of OnGetItemText() in
the unit test.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/controls/virtlistctrltest.cpp

index ea049042f4617452410f0977f430904df9da6564..1d52ce5df5f642acd2308c9760f7210a08d41425 100644 (file)
@@ -61,9 +61,26 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VirtListCtrlTestCase, "VirtListCtrlTestCa
 
 void VirtListCtrlTestCase::setUp()
 {
-    m_list = new wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
-                            wxPoint(0, 0), wxSize(400, 200),
-                            wxLC_REPORT | wxLC_VIRTUAL);
+    // Define a class overriding OnGetItemText() which must be overridden for
+    // any virtual list control.
+    class VirtListCtrl : public wxListCtrl
+    {
+    public:
+        VirtListCtrl()
+            : wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
+                         wxPoint(0, 0), wxSize(400, 200),
+                         wxLC_REPORT | wxLC_VIRTUAL)
+        {
+        }
+
+    protected:
+        virtual wxString OnGetItemText(long item, long column) const
+        {
+            return wxString::Format("Row %ld, col %ld", item, column);
+        }
+    };
+
+    m_list = new VirtListCtrl;
 }
 
 void VirtListCtrlTestCase::tearDown()