Add a layout hack to PositionToCoords() unit test for wxGTK
The text control needs a few event loop iterations in order to layout itself correctly, so give it up to 1 second to do it in order to avoid spurious test failures that occurred if just a single call to wxYield() were done (or, worse, none at all as it was the case before). Also log the value returned by PositionToCoords() in case of test failures.
This commit is contained in:
@@ -667,11 +667,31 @@ void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
|
||||
// last position is in its bounds.
|
||||
m_text->SetInsertionPointEnd();
|
||||
|
||||
CPPUNIT_ASSERT( m_text->PositionToCoords(0).y < 0 );
|
||||
CPPUNIT_ASSERT
|
||||
(
|
||||
m_text->PositionToCoords(m_text->GetInsertionPoint()).y <= TEXT_HEIGHT
|
||||
);
|
||||
const int pos = m_text->GetInsertionPoint();
|
||||
|
||||
// wxGTK needs to yield here to update the text control.
|
||||
#ifdef __WXGTK__
|
||||
wxStopWatch sw;
|
||||
while ( m_text->PositionToCoords(0).y == 0 ||
|
||||
m_text->PositionToCoords(pos).y > TEXT_HEIGHT )
|
||||
{
|
||||
if ( sw.Time() > 1000 )
|
||||
{
|
||||
FAIL("Timed out waiting for wxTextCtrl update.");
|
||||
break;
|
||||
}
|
||||
|
||||
wxYield();
|
||||
}
|
||||
#endif // __WXGTK__
|
||||
|
||||
wxPoint coords = m_text->PositionToCoords(0);
|
||||
INFO("First position coords = " << coords);
|
||||
CPPUNIT_ASSERT( coords.y < 0 );
|
||||
|
||||
coords = m_text->PositionToCoords(pos);
|
||||
INFO("Position is " << pos << ", coords = " << coords);
|
||||
CPPUNIT_ASSERT( coords.y <= TEXT_HEIGHT );
|
||||
}
|
||||
|
||||
void TextCtrlTestCase::PositionToXYMultiLine()
|
||||
|
Reference in New Issue
Block a user