]> git.saurik.com Git - wxWidgets.git/blame - tests/controls/textctrltest.cpp
use a different known good face name under non-MSW
[wxWidgets.git] / tests / controls / textctrltest.cpp
CommitLineData
c0d9b217 1///////////////////////////////////////////////////////////////////////////////
f0f6a32d 2// Name: tests/controls/textctrltest.cpp
c0d9b217
VZ
3// Purpose: wxTextCtrl unit test
4// Author: Vadim Zeitlin
5// Created: 2007-09-25
6// RCS-ID: $Id$
7// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/app.h"
22 #include "wx/textctrl.h"
23#endif // WX_PRECOMP
24
f0f6a32d
VZ
25#include "textentrytest.h"
26
c0d9b217
VZ
27// ----------------------------------------------------------------------------
28// test class
29// ----------------------------------------------------------------------------
30
f0f6a32d 31class TextCtrlTestCase : public TextEntryTestCase
c0d9b217
VZ
32{
33public:
34 TextCtrlTestCase() { }
35
36 virtual void setUp();
37 virtual void tearDown();
38
39private:
f0f6a32d
VZ
40 virtual wxTextEntry *GetTestEntry() const { return m_text; }
41 virtual wxWindow *GetTestWindow() const { return m_text; }
42
c0d9b217 43 CPPUNIT_TEST_SUITE( TextCtrlTestCase );
f0f6a32d 44 wxTEXT_ENTRY_TESTS();
d911dc04 45 CPPUNIT_TEST( MultiLineReplace );
c0d9b217
VZ
46 CPPUNIT_TEST_SUITE_END();
47
d911dc04
VZ
48 void MultiLineReplace();
49
c0d9b217 50 wxTextCtrl *m_text;
c0d9b217
VZ
51
52 DECLARE_NO_COPY_CLASS(TextCtrlTestCase)
53};
54
55// register in the unnamed registry so that these tests are run by default
56CPPUNIT_TEST_SUITE_REGISTRATION( TextCtrlTestCase );
57
58// also include in it's own registry so that these tests can be run alone
59CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TextCtrlTestCase, "TextCtrlTestCase" );
60
61// ----------------------------------------------------------------------------
62// test initialization
63// ----------------------------------------------------------------------------
64
65void TextCtrlTestCase::setUp()
66{
67 m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
68}
69
70void TextCtrlTestCase::tearDown()
71{
72 delete m_text;
73 m_text = NULL;
74}
75
76// ----------------------------------------------------------------------------
77// tests themselves
78// ----------------------------------------------------------------------------
79
d911dc04
VZ
80void TextCtrlTestCase::MultiLineReplace()
81{
82 // we need a multiline control for this test so recreate it
83 delete m_text;
84 m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
85 wxDefaultPosition, wxDefaultSize,
86 wxTE_MULTILINE);
87
88 m_text->SetValue("Hello replace\n"
89 "0123456789012");
90 m_text->SetInsertionPoint(0);
91
92 m_text->Replace(6, 13, "changed");
93
94 CPPUNIT_ASSERT_EQUAL("Hello changed\n"
95 "0123456789012",
96 m_text->GetValue());
97 CPPUNIT_ASSERT_EQUAL(13, m_text->GetInsertionPoint());
98
99 m_text->Replace(13, -1, "");
100 CPPUNIT_ASSERT_EQUAL("Hello changed", m_text->GetValue());
101 CPPUNIT_ASSERT_EQUAL(13, m_text->GetInsertionPoint());
102}
103