textctrltest.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/controls/textctrltest.cpp
  3. // Purpose: wxTextCtrl unit test
  4. // Author: Vadim Zeitlin
  5. // Created: 2007-09-25
  6. // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
  7. ///////////////////////////////////////////////////////////////////////////////
  8. // ----------------------------------------------------------------------------
  9. // headers
  10. // ----------------------------------------------------------------------------
  11. #include "testprec.h"
  12. #if wxUSE_TEXTCTRL
  13. #ifdef __BORLANDC__
  14. #pragma hdrstop
  15. #endif
  16. #ifndef WX_PRECOMP
  17. #include "wx/app.h"
  18. #include "wx/textctrl.h"
  19. #endif // WX_PRECOMP
  20. #include "wx/scopeguard.h"
  21. #include "textentrytest.h"
  22. #include "testableframe.h"
  23. #include "asserthelper.h"
  24. #include "wx/uiaction.h"
  25. static const int TEXT_HEIGHT = 200;
  26. // ----------------------------------------------------------------------------
  27. // test class
  28. // ----------------------------------------------------------------------------
  29. class TextCtrlTestCase : public TextEntryTestCase, public CppUnit::TestCase
  30. {
  31. public:
  32. TextCtrlTestCase() { }
  33. virtual void setUp();
  34. virtual void tearDown();
  35. private:
  36. virtual wxTextEntry *GetTestEntry() const { return m_text; }
  37. virtual wxWindow *GetTestWindow() const { return m_text; }
  38. #define SINGLE_AND_MULTI_TESTS() \
  39. WXUISIM_TEST( ReadOnly ); \
  40. CPPUNIT_TEST( StreamInput ); \
  41. CPPUNIT_TEST( Redirector )
  42. CPPUNIT_TEST_SUITE( TextCtrlTestCase );
  43. // These tests run for single line text controls.
  44. wxTEXT_ENTRY_TESTS();
  45. WXUISIM_TEST( MaxLength );
  46. SINGLE_AND_MULTI_TESTS();
  47. // Now switch to the multi-line text controls.
  48. CPPUNIT_TEST( PseudoTestSwitchToMultiLineStyle );
  49. // Rerun some of the tests above. Notice that not all of them pass, so
  50. // we can't just use wxTEXT_ENTRY_TESTS() here. For some of them it's
  51. // normal, e.g. Hint() test isn't supposed to work for multi-line
  52. // controls. Others, such as InsertionPoint() and TextChangeEvents()
  53. // don't pass neither but this could be a bug.
  54. CPPUNIT_TEST( SetValue );
  55. CPPUNIT_TEST( Selection );
  56. CPPUNIT_TEST( Replace );
  57. WXUISIM_TEST( Editable );
  58. CPPUNIT_TEST( CopyPaste );
  59. CPPUNIT_TEST( UndoRedo );
  60. SINGLE_AND_MULTI_TESTS();
  61. // All tests from now on are for multi-line controls only.
  62. CPPUNIT_TEST( MultiLineReplace );
  63. //WXUISIM_TEST( ProcessEnter );
  64. WXUISIM_TEST( Url );
  65. CPPUNIT_TEST( Style );
  66. CPPUNIT_TEST( FontStyle );
  67. CPPUNIT_TEST( Lines );
  68. CPPUNIT_TEST( LogTextCtrl );
  69. CPPUNIT_TEST( LongText );
  70. CPPUNIT_TEST( PositionToCoords );
  71. CPPUNIT_TEST( PositionToCoordsRich );
  72. CPPUNIT_TEST( PositionToCoordsRich2 );
  73. CPPUNIT_TEST_SUITE_END();
  74. void PseudoTestSwitchToMultiLineStyle()
  75. {
  76. ms_style = wxTE_MULTILINE;
  77. }
  78. void MultiLineReplace();
  79. void ReadOnly();
  80. void MaxLength();
  81. void StreamInput();
  82. void Redirector();
  83. //void ProcessEnter();
  84. void Url();
  85. void Style();
  86. void FontStyle();
  87. void Lines();
  88. void LogTextCtrl();
  89. void LongText();
  90. void PositionToCoords();
  91. void PositionToCoordsRich();
  92. void PositionToCoordsRich2();
  93. void DoPositionToCoordsTestWithStyle(long style);
  94. // Create the control with the following styles added to ms_style which may
  95. // (or not) already contain wxTE_MULTILINE.
  96. void CreateText(long extraStyles);
  97. wxTextCtrl *m_text;
  98. static long ms_style;
  99. DECLARE_NO_COPY_CLASS(TextCtrlTestCase)
  100. };
  101. // register in the unnamed registry so that these tests are run by default
  102. CPPUNIT_TEST_SUITE_REGISTRATION( TextCtrlTestCase );
  103. // also include in its own registry so that these tests can be run alone
  104. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TextCtrlTestCase, "TextCtrlTestCase" );
  105. // ----------------------------------------------------------------------------
  106. // test initialization
  107. // ----------------------------------------------------------------------------
  108. // This is 0 initially and set to wxTE_MULTILINE later to allow running the
  109. // same tests for both single and multi line controls.
  110. long TextCtrlTestCase::ms_style = 0;
  111. void TextCtrlTestCase::CreateText(long extraStyles)
  112. {
  113. wxSize size;
  114. if ( ms_style == wxTE_MULTILINE )
  115. size = wxSize(400, TEXT_HEIGHT);
  116. m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
  117. wxDefaultPosition, size,
  118. ms_style | extraStyles);
  119. }
  120. void TextCtrlTestCase::setUp()
  121. {
  122. CreateText(ms_style);
  123. }
  124. void TextCtrlTestCase::tearDown()
  125. {
  126. wxDELETE(m_text);
  127. }
  128. // ----------------------------------------------------------------------------
  129. // tests themselves
  130. // ----------------------------------------------------------------------------
  131. void TextCtrlTestCase::MultiLineReplace()
  132. {
  133. m_text->SetValue("Hello replace\n"
  134. "0123456789012");
  135. m_text->SetInsertionPoint(0);
  136. m_text->Replace(6, 13, "changed");
  137. CPPUNIT_ASSERT_EQUAL("Hello changed\n"
  138. "0123456789012",
  139. m_text->GetValue());
  140. CPPUNIT_ASSERT_EQUAL(13, m_text->GetInsertionPoint());
  141. m_text->Replace(13, -1, "");
  142. CPPUNIT_ASSERT_EQUAL("Hello changed", m_text->GetValue());
  143. CPPUNIT_ASSERT_EQUAL(13, m_text->GetInsertionPoint());
  144. }
  145. void TextCtrlTestCase::ReadOnly()
  146. {
  147. #if wxUSE_UIACTIONSIMULATOR
  148. // we need a read only control for this test so recreate it
  149. delete m_text;
  150. CreateText(wxTE_READONLY);
  151. EventCounter updated(m_text, wxEVT_TEXT);
  152. m_text->SetFocus();
  153. wxUIActionSimulator sim;
  154. sim.Text("abcdef");
  155. wxYield();
  156. CPPUNIT_ASSERT_EQUAL("", m_text->GetValue());
  157. CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
  158. // SetEditable() is supposed to override wxTE_READONLY
  159. m_text->SetEditable(true);
  160. #ifdef __WXOSX__
  161. // a ready only text field might not have been focusable at all
  162. m_text->SetFocus();
  163. #endif
  164. sim.Text("abcdef");
  165. wxYield();
  166. CPPUNIT_ASSERT_EQUAL("abcdef", m_text->GetValue());
  167. CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
  168. #endif
  169. }
  170. void TextCtrlTestCase::MaxLength()
  171. {
  172. #if wxUSE_UIACTIONSIMULATOR
  173. EventCounter updated(m_text, wxEVT_TEXT);
  174. EventCounter maxlen(m_text, wxEVT_TEXT_MAXLEN);
  175. m_text->SetFocus();
  176. m_text->SetMaxLength(10);
  177. wxUIActionSimulator sim;
  178. sim.Text("abcdef");
  179. wxYield();
  180. CPPUNIT_ASSERT_EQUAL(0, maxlen.GetCount());
  181. sim.Text("ghij");
  182. wxYield();
  183. CPPUNIT_ASSERT_EQUAL(0, maxlen.GetCount());
  184. CPPUNIT_ASSERT_EQUAL(10, updated.GetCount());
  185. maxlen.Clear();
  186. updated.Clear();
  187. sim.Text("k");
  188. wxYield();
  189. CPPUNIT_ASSERT_EQUAL(1, maxlen.GetCount());
  190. CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
  191. maxlen.Clear();
  192. updated.Clear();
  193. m_text->SetMaxLength(0);
  194. sim.Text("k");
  195. wxYield();
  196. CPPUNIT_ASSERT_EQUAL(0, maxlen.GetCount());
  197. CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
  198. #endif
  199. }
  200. void TextCtrlTestCase::StreamInput()
  201. {
  202. #ifndef __WXOSX__
  203. {
  204. // Ensure we use decimal point and not a comma.
  205. char * const locOld = setlocale(LC_NUMERIC, "C");
  206. wxON_BLOCK_EXIT2( setlocale, (int)LC_NUMERIC, locOld );
  207. *m_text << "stringinput"
  208. << 10
  209. << 1000L
  210. << 3.14f
  211. << 2.71
  212. << 'a'
  213. << L'b';
  214. }
  215. CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71ab", m_text->GetValue());
  216. m_text->SetValue("");
  217. #if wxHAS_TEXT_WINDOW_STREAM
  218. std::ostream stream(m_text);
  219. // We don't test a wide character as this is not a wide stream
  220. stream << "stringinput"
  221. << 10
  222. << 1000L
  223. << 3.14f
  224. << 2.71
  225. << 'a';
  226. stream.flush();
  227. CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71a", m_text->GetValue());
  228. #endif // wxHAS_TEXT_WINDOW_STREAM
  229. #endif // !__WXOSX__
  230. }
  231. void TextCtrlTestCase::Redirector()
  232. {
  233. #if wxHAS_TEXT_WINDOW_STREAM && wxUSE_STD_IOSTREAM
  234. wxStreamToTextRedirector redirect(m_text);
  235. std::cout << "stringinput"
  236. << 10
  237. << 1000L
  238. << 3.14f
  239. << 2.71
  240. << 'a';
  241. CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71a", m_text->GetValue());
  242. #endif
  243. }
  244. #if 0
  245. void TextCtrlTestCase::ProcessEnter()
  246. {
  247. #if wxUSE_UIACTIONSIMULATOR
  248. wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
  249. wxTestableFrame);
  250. EventCounter count(m_text, wxEVT_TEXT_ENTER);
  251. m_text->SetFocus();
  252. wxUIActionSimulator sim;
  253. sim.Char(WXK_RETURN);
  254. wxYield();
  255. CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_TEXT_ENTER));
  256. // we need a text control with wxTE_PROCESS_ENTER for this test
  257. delete m_text;
  258. CreateText(wxTE_PROCESS_ENTER);
  259. m_text->SetFocus();
  260. sim.Char(WXK_RETURN);
  261. wxYield();
  262. CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_TEXT_ENTER));
  263. #endif
  264. }
  265. #endif
  266. void TextCtrlTestCase::Url()
  267. {
  268. #if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__)
  269. delete m_text;
  270. CreateText(wxTE_RICH | wxTE_AUTO_URL);
  271. EventCounter url(m_text, wxEVT_TEXT_URL);
  272. m_text->AppendText("http://www.wxwidgets.org");
  273. wxUIActionSimulator sim;
  274. sim.MouseMove(m_text->ClientToScreen(wxPoint(5, 5)));
  275. sim.MouseClick();
  276. wxYield();
  277. CPPUNIT_ASSERT_EQUAL(1, url.GetCount());
  278. #endif
  279. }
  280. void TextCtrlTestCase::Style()
  281. {
  282. #ifndef __WXOSX__
  283. delete m_text;
  284. // We need wxTE_RICH under windows for style support
  285. CreateText(wxTE_RICH);
  286. // Red text on a white background
  287. m_text->SetDefaultStyle(wxTextAttr(*wxRED, *wxWHITE));
  288. CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetTextColour(), *wxRED);
  289. CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetBackgroundColour(),
  290. *wxWHITE);
  291. m_text->AppendText("red on white ");
  292. // Red text on a grey background
  293. m_text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY));
  294. CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetTextColour(), *wxRED);
  295. CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetBackgroundColour(),
  296. *wxLIGHT_GREY);
  297. m_text->AppendText("red on grey ");
  298. // Blue text on a grey background
  299. m_text->SetDefaultStyle(wxTextAttr(*wxBLUE));
  300. CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetTextColour(), *wxBLUE);
  301. CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetBackgroundColour(),
  302. *wxLIGHT_GREY);
  303. m_text->AppendText("blue on grey");
  304. // Get getting the style at a specific location
  305. wxTextAttr style;
  306. // We have to check that styles are supported
  307. if(m_text->GetStyle(3, style))
  308. {
  309. CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED);
  310. CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE);
  311. }
  312. // And then setting the style
  313. if(m_text->SetStyle(15, 18, style))
  314. {
  315. m_text->GetStyle(17, style);
  316. CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED);
  317. CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE);
  318. }
  319. #endif
  320. }
  321. void TextCtrlTestCase::FontStyle()
  322. {
  323. // We need wxTE_RICH under MSW and wxTE_MULTILINE under GTK for style
  324. // support so recreate the control with these styles.
  325. delete m_text;
  326. CreateText(wxTE_RICH);
  327. // Check that we get back the same font from GetStyle() after setting it
  328. // with SetDefaultStyle().
  329. wxFont fontIn(14,
  330. wxFONTFAMILY_DEFAULT,
  331. wxFONTSTYLE_NORMAL,
  332. wxFONTWEIGHT_NORMAL);
  333. wxTextAttr attrIn;
  334. attrIn.SetFont(fontIn);
  335. if ( !m_text->SetDefaultStyle(attrIn) )
  336. {
  337. // Skip the test if the styles are not supported.
  338. return;
  339. }
  340. m_text->AppendText("Default font size 14");
  341. wxTextAttr attrOut;
  342. m_text->GetStyle(5, attrOut);
  343. CPPUNIT_ASSERT( attrOut.HasFont() );
  344. wxFont fontOut = attrOut.GetFont();
  345. #ifdef __WXMSW__
  346. // Under MSW we get back an encoding in the font even though we hadn't
  347. // specified it originally. It's not really a problem but we need this hack
  348. // to prevent the assert below from failing because of it.
  349. fontOut.SetEncoding(fontIn.GetEncoding());
  350. #endif
  351. CPPUNIT_ASSERT_EQUAL( fontIn, fontOut );
  352. // Also check the same for SetStyle().
  353. fontIn.SetPointSize(10);
  354. fontIn.SetWeight(wxFONTWEIGHT_BOLD);
  355. attrIn.SetFont(fontIn);
  356. m_text->SetStyle(0, 6, attrIn);
  357. m_text->GetStyle(4, attrOut);
  358. CPPUNIT_ASSERT( attrOut.HasFont() );
  359. fontOut = attrOut.GetFont();
  360. #ifdef __WXMSW__
  361. fontOut.SetEncoding(fontIn.GetEncoding());
  362. #endif
  363. CPPUNIT_ASSERT_EQUAL( fontIn, fontOut );
  364. }
  365. void TextCtrlTestCase::Lines()
  366. {
  367. m_text->SetValue("line1\nline2\nlong long line 3");
  368. m_text->Refresh();
  369. m_text->Update();
  370. CPPUNIT_ASSERT_EQUAL(3, m_text->GetNumberOfLines());
  371. CPPUNIT_ASSERT_EQUAL(5, m_text->GetLineLength(0));
  372. CPPUNIT_ASSERT_EQUAL("line2", m_text->GetLineText(1));
  373. CPPUNIT_ASSERT_EQUAL(16, m_text->GetLineLength(2));
  374. m_text->AppendText("\n\nMore text on line 5");
  375. CPPUNIT_ASSERT_EQUAL(5, m_text->GetNumberOfLines());
  376. CPPUNIT_ASSERT_EQUAL(0, m_text->GetLineLength(3));
  377. CPPUNIT_ASSERT_EQUAL("", m_text->GetLineText(3));
  378. // Verify that wrapped lines count as 2 lines.
  379. //
  380. // This currently doesn't work neither in wxGTK nor wxOSX/Cocoa, see
  381. // #12366, where GetNumberOfLines() always returns the number of logical,
  382. // not physical, lines.
  383. m_text->AppendText("\n" + wxString(50, '1') + ' ' + wxString(50, '2'));
  384. #if defined(__WXGTK__) || defined(__WXOSX_COCOA__)
  385. CPPUNIT_ASSERT_EQUAL(6, m_text->GetNumberOfLines());
  386. #else
  387. CPPUNIT_ASSERT_EQUAL(7, m_text->GetNumberOfLines());
  388. #endif
  389. }
  390. void TextCtrlTestCase::LogTextCtrl()
  391. {
  392. CPPUNIT_ASSERT(m_text->IsEmpty());
  393. wxLogTextCtrl* logtext = new wxLogTextCtrl(m_text);
  394. wxLog* old = wxLog::SetActiveTarget(logtext);
  395. logtext->LogText("text");
  396. delete wxLog::SetActiveTarget(old);
  397. CPPUNIT_ASSERT(!m_text->IsEmpty());
  398. }
  399. void TextCtrlTestCase::LongText()
  400. {
  401. delete m_text;
  402. CreateText(wxTE_MULTILINE|wxTE_DONTWRAP);
  403. const int numLines = 1000;
  404. const int lenPattern = 100;
  405. int i;
  406. // Pattern for the line.
  407. wxChar linePattern[lenPattern+1];
  408. for (i = 0; i < lenPattern - 1; i++)
  409. {
  410. linePattern[i] = wxChar('0' + i % 10);
  411. }
  412. linePattern[WXSIZEOF(linePattern) - 1] = wxChar('\0');
  413. // Fill the control.
  414. m_text->SetMaxLength(15000);
  415. for (i = 0; i < numLines; i++)
  416. {
  417. m_text->AppendText(wxString::Format(wxT("[%3d] %s\n"), i, linePattern));
  418. }
  419. // Check the content.
  420. for (i = 0; i < numLines; i++)
  421. {
  422. wxString pattern = wxString::Format(wxT("[%3d] %s"), i, linePattern);
  423. wxString line = m_text->GetLineText(i);
  424. CPPUNIT_ASSERT_EQUAL( line, pattern );
  425. }
  426. }
  427. void TextCtrlTestCase::PositionToCoords()
  428. {
  429. DoPositionToCoordsTestWithStyle(0);
  430. }
  431. void TextCtrlTestCase::PositionToCoordsRich()
  432. {
  433. DoPositionToCoordsTestWithStyle(wxTE_RICH);
  434. }
  435. void TextCtrlTestCase::PositionToCoordsRich2()
  436. {
  437. DoPositionToCoordsTestWithStyle(wxTE_RICH2);
  438. }
  439. void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
  440. {
  441. delete m_text;
  442. CreateText(style);
  443. // Asking for invalid index should fail.
  444. WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(1) );
  445. // Getting position shouldn't return wxDefaultPosition except if the method
  446. // is not implemented at all in the current port.
  447. const wxPoint pos0 = m_text->PositionToCoords(0);
  448. if ( pos0 == wxDefaultPosition )
  449. {
  450. #if defined(__WXMSW__) || defined(__WXGTK20__)
  451. CPPUNIT_FAIL( "PositionToCoords() unexpectedly failed." );
  452. #endif
  453. return;
  454. }
  455. CPPUNIT_ASSERT(pos0.x >= 0);
  456. CPPUNIT_ASSERT(pos0.y >= 0);
  457. m_text->SetValue("Hello");
  458. wxYield(); // Let GTK layout the control correctly.
  459. // Position of non-first character should be positive.
  460. const long posHello4 = m_text->PositionToCoords(4).x;
  461. CPPUNIT_ASSERT( posHello4 > 0 );
  462. // Asking for position beyond the last character should succeed and return
  463. // reasonable result.
  464. CPPUNIT_ASSERT( m_text->PositionToCoords(5).x > posHello4 );
  465. // But asking for the next position should fail.
  466. WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(6) );
  467. // Test getting the coordinates of the last character when it is in the
  468. // beginning of a new line to exercise MSW code which has specific logic
  469. // for it.
  470. m_text->AppendText("\n");
  471. const wxPoint posLast = m_text->PositionToCoords(m_text->GetLastPosition());
  472. CPPUNIT_ASSERT_EQUAL( pos0.x, posLast.x );
  473. CPPUNIT_ASSERT( posLast.y > 0 );
  474. // Add enough contents to the control to make sure it has a scrollbar.
  475. m_text->SetValue("First line" + wxString(50, '\n') + "Last line");
  476. m_text->SetInsertionPoint(0);
  477. wxYield(); // Let GTK layout the control correctly.
  478. // This shouldn't change anything for the first position coordinates.
  479. CPPUNIT_ASSERT_EQUAL( pos0, m_text->PositionToCoords(0) );
  480. // And the last one must be beyond the window boundary and so not be
  481. // visible -- but getting its coordinate should still work.
  482. CPPUNIT_ASSERT
  483. (
  484. m_text->PositionToCoords(m_text->GetLastPosition()).y > TEXT_HEIGHT
  485. );
  486. // Now make it scroll to the end and check that the first position now has
  487. // negative offset as its above the visible part of the window while the
  488. // last position is in its bounds.
  489. m_text->SetInsertionPointEnd();
  490. CPPUNIT_ASSERT( m_text->PositionToCoords(0).y < 0 );
  491. CPPUNIT_ASSERT
  492. (
  493. m_text->PositionToCoords(m_text->GetInsertionPoint()).y <= TEXT_HEIGHT
  494. );
  495. }
  496. #endif //wxUSE_TEXTCTRL