]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/textctrltest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/textctrltest.cpp
3 // Purpose: wxTextCtrl unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
22 #include "wx/textctrl.h"
25 #include "textentrytest.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class TextCtrlTestCase
: public TextEntryTestCase
34 TextCtrlTestCase() { }
37 virtual void tearDown();
40 virtual wxTextEntry
*GetTestEntry() const { return m_text
; }
41 virtual wxWindow
*GetTestWindow() const { return m_text
; }
43 CPPUNIT_TEST_SUITE( TextCtrlTestCase
);
45 CPPUNIT_TEST( MultiLineReplace
);
46 CPPUNIT_TEST_SUITE_END();
48 void MultiLineReplace();
52 DECLARE_NO_COPY_CLASS(TextCtrlTestCase
)
55 // register in the unnamed registry so that these tests are run by default
56 CPPUNIT_TEST_SUITE_REGISTRATION( TextCtrlTestCase
);
58 // also include in it's own registry so that these tests can be run alone
59 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TextCtrlTestCase
, "TextCtrlTestCase" );
61 // ----------------------------------------------------------------------------
62 // test initialization
63 // ----------------------------------------------------------------------------
65 void TextCtrlTestCase::setUp()
67 m_text
= new wxTextCtrl(wxTheApp
->GetTopWindow(), wxID_ANY
);
70 void TextCtrlTestCase::tearDown()
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 void TextCtrlTestCase::MultiLineReplace()
82 // we need a multiline control for this test so recreate it
84 m_text
= new wxTextCtrl(wxTheApp
->GetTopWindow(), wxID_ANY
, "",
85 wxDefaultPosition
, wxDefaultSize
,
88 m_text
->SetValue("Hello replace\n"
90 m_text
->SetInsertionPoint(0);
92 m_text
->Replace(6, 13, "changed");
94 CPPUNIT_ASSERT_EQUAL("Hello changed\n"
97 CPPUNIT_ASSERT_EQUAL(13, m_text
->GetInsertionPoint());
99 m_text
->Replace(13, -1, "");
100 CPPUNIT_ASSERT_EQUAL("Hello changed", m_text
->GetValue());
101 CPPUNIT_ASSERT_EQUAL(13, m_text
->GetInsertionPoint());