Fix or disable currently failing wxGTK GUI tests

Try to ensure that the GUI test suite passes so that buildbot has a
chance to warn us if/when anything breaks.
This commit is contained in:
VZ
2017-11-07 20:56:09 +01:00
committed by GitHub
15 changed files with 168 additions and 68 deletions

View File

@@ -397,7 +397,7 @@ void TextCtrlTestCase::Style()
#ifndef __WXOSX__
delete m_text;
// We need wxTE_RICH under windows for style support
CreateText(wxTE_RICH);
CreateText(wxTE_MULTILINE|wxTE_RICH);
// Red text on a white background
m_text->SetDefaultStyle(wxTextAttr(*wxRED, *wxWHITE));
@@ -431,20 +431,21 @@ void TextCtrlTestCase::Style()
wxTextAttr style;
// We have to check that styles are supported
if(m_text->GetStyle(3, style))
if ( !m_text->GetStyle(3, style) )
{
CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED);
CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE);
WARN("Retrieving text style not supported, skipping test.");
return;
}
CHECK( style.GetTextColour() == *wxRED );
CHECK( style.GetBackgroundColour() == *wxWHITE );
// And then setting the style
if(m_text->SetStyle(15, 18, style))
{
m_text->GetStyle(17, style);
REQUIRE( m_text->SetStyle(15, 18, style) );
CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED);
CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE);
}
REQUIRE( m_text->GetStyle(17, style) );
CHECK( style.GetTextColour() == *wxRED );
CHECK( style.GetBackgroundColour() == *wxWHITE );
#endif
}
@@ -603,7 +604,7 @@ void TextCtrlTestCase::PositionToCoordsRich2()
void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
{
delete m_text;
CreateText(style);
CreateText(style|wxTE_MULTILINE);
// Asking for invalid index should fail.
WX_ASSERT_FAILS_WITH_ASSERT( m_text->PositionToCoords(1) );
@@ -667,11 +668,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()
@@ -935,6 +956,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
for( long x = 0; x < maxLineLength_0+1; x++ )
{
long p = m_text->XYToPosition(x, y);
INFO("x=" << x << ", y=" << y);
CPPUNIT_ASSERT_EQUAL( pos_0[y][x], p );
}
@@ -951,6 +973,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
for( long x = 0; x < maxLineLength_1+1; x++ )
{
long p = m_text->XYToPosition(x, y);
INFO("x=" << x << ", y=" << y);
CPPUNIT_ASSERT_EQUAL( pos_1[y][x], p );
}
@@ -985,6 +1008,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
for( long x = 0; x < maxLineLength_2+1; x++ )
{
long p = m_text->XYToPosition(x, y);
INFO("x=" << x << ", y=" << y);
CPPUNIT_ASSERT_EQUAL( ref_pos_2[y][x], p );
}
@@ -1021,6 +1045,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
for( long x = 0; x < maxLineLength_3+1; x++ )
{
long p = m_text->XYToPosition(x, y);
INFO("x=" << x << ", y=" << y);
CPPUNIT_ASSERT_EQUAL( ref_pos_3[y][x], p );
}
@@ -1061,6 +1086,7 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
for( long x = 0; x < maxLineLength_4+1; x++ )
{
long p = m_text->XYToPosition(x, y);
INFO("x=" << x << ", y=" << y);
CPPUNIT_ASSERT_EQUAL( ref_pos_4[y][x], p );
}
}

View File

@@ -57,6 +57,10 @@ void TextEntryTestCase::TextChangeEvents()
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
updated.Clear();
entry->SetValue("");
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
updated.Clear();
entry->ChangeValue("bar");
CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );

View File

@@ -142,7 +142,7 @@ void WindowTestCase::FocusEvent()
m_window->SetFocus();
CPPUNIT_ASSERT_EQUAL(1, setfocus.GetCount());
WX_ASSERT_EVENT_OCCURS(setfocus, 1);
CPPUNIT_ASSERT(m_window->HasFocus());
wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY);

View File

@@ -127,6 +127,11 @@ private:
wxDECLARE_EVENT_TABLE();
};
// Avoid gcc warning about some of the functions defined by the expansion of
// the event table macros being unused: they are indeed unused, but we still
// want to have them to check that they compile.
wxGCC_WARNING_SUPPRESS(unused-function)
wxBEGIN_EVENT_TABLE(MyClassWithEventTable, wxEvtHandler)
EVT_IDLE(MyClassWithEventTable::OnIdle)
@@ -138,6 +143,8 @@ wxBEGIN_EVENT_TABLE(MyClassWithEventTable, wxEvtHandler)
//EVT_IDLE(MyClassWithEventTable::OnAnotherEvent)
wxEND_EVENT_TABLE()
wxGCC_WARNING_RESTORE(unused-function)
} // anonymous namespace

View File

@@ -16,9 +16,7 @@
#pragma hdrstop
#endif
// FIXME: As all the other tests involving wxUIActionSimulator, this one is
// broken under OS X, the test window siply never gets any events.
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__)
#if wxUSE_UIACTIONSIMULATOR
#ifndef WX_PRECOMP
#include "wx/app.h"
@@ -204,12 +202,12 @@ public:
private:
CPPUNIT_TEST_SUITE( KeyboardEventTestCase );
CPPUNIT_TEST( NormalLetter );
CPPUNIT_TEST( NormalSpecial );
CPPUNIT_TEST( CtrlLetter );
CPPUNIT_TEST( CtrlSpecial );
CPPUNIT_TEST( ShiftLetter );
CPPUNIT_TEST( ShiftSpecial );
WXUISIM_TEST( NormalLetter );
WXUISIM_TEST( NormalSpecial );
WXUISIM_TEST( CtrlLetter );
WXUISIM_TEST( CtrlSpecial );
WXUISIM_TEST( ShiftLetter );
WXUISIM_TEST( ShiftSpecial );
CPPUNIT_TEST_SUITE_END();
void NormalLetter();

View File

@@ -37,7 +37,12 @@
// some tests there. But this should be fixed and the tests reenabled
// because wxPaintEvent propagation in wxScrolledWindow is a perfect
// example of fragile code that could be broken under OS X.
#ifndef __WXOSX__
//
// FIXME: Under GTK+ 3 the test is broken because a simple wxYield() is not
// enough to map the frame. It should be also fixed there by waiting for
// it to come up, with some timeout, but for now it always fails, so
// it's useless to run it.
#if !defined(__WXOSX__) && !defined(__WXGTK3__)
#define CAN_TEST_PAINT_EVENTS
#endif

View File

@@ -416,10 +416,12 @@ wxTestGLogHandler(const gchar* domain,
const gchar* message,
gpointer data)
{
fprintf(stderr, "** GTK log message while running %s(): ",
fprintf(stderr, "\n*** GTK log message while running %s(): ",
wxGetCurrentTestName().c_str());
g_log_default_handler(domain, level, message, data);
fprintf(stderr, "\n");
}
#endif // __WXGTK__

View File

@@ -73,7 +73,7 @@ void TopLevelWindowTestCase::FrameShowTest()
void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow* tlw)
{
CPPUNIT_ASSERT(!tlw->IsShown());
CHECK(!tlw->IsShown());
wxTextCtrl* textCtrl = new wxTextCtrl(tlw, -1, "test");
textCtrl->SetFocus();
@@ -81,19 +81,26 @@ void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow* tlw)
// only run this test on platforms where ShowWithoutActivating is implemented.
#if defined(__WXMSW__) || defined(__WXMAC__)
tlw->ShowWithoutActivating();
CPPUNIT_ASSERT(tlw->IsShown());
CPPUNIT_ASSERT(!tlw->IsActive());
CHECK(tlw->IsShown());
CHECK(!tlw->IsActive());
tlw->Hide();
CPPUNIT_ASSERT(!tlw->IsShown());
CPPUNIT_ASSERT(!tlw->IsActive());
CHECK(!tlw->IsShown());
CHECK(!tlw->IsActive());
#endif
tlw->Show(true);
CPPUNIT_ASSERT(tlw->IsActive());
CPPUNIT_ASSERT(tlw->IsShown());
// wxGTK needs many event loop iterations before the TLW becomes active and
// this doesn't happen in this test, so avoid checking for it.
#ifndef __WXGTK__
CHECK(tlw->IsActive());
#endif
CHECK(tlw->IsShown());
tlw->Hide();
CPPUNIT_ASSERT(!tlw->IsShown());
CPPUNIT_ASSERT(tlw->IsActive());
CHECK(!tlw->IsShown());
#ifndef __WXGTK__
CHECK(tlw->IsActive());
#endif
}