Make wxUIActionSimulator works more reliably on GTK/X11

Add wxXSync class which adds delays between the synthesized events
sufficient for them to be processed by the higher layers (X, GTK).

This makes it possible to run the UI tests by default with wxGTK.

Closes https://github.com/wxWidgets/wxWidgets/pull/1845
This commit is contained in:
ali kettab
2020-05-07 02:45:17 +01:00
committed by Vadim Zeitlin
parent fb5c13ed00
commit 59ad9f46e6
18 changed files with 202 additions and 160 deletions

View File

@@ -145,38 +145,12 @@ TEST_CASE_METHOD(GridTestCase, "Grid::CellEdit", "[grid]")
sim.Text("abab");
// We need to wait until the editor is really shown under GTK, consider
// that it happens once it gets focus.
#ifdef __WXGTK__
for ( wxStopWatch sw; wxWindow::FindFocus() == m_grid; )
{
if ( sw.Time() > 250 )
{
WARN("Editor control not shown until timeout expiration");
break;
}
wxYield();
}
#endif // __WXGTK__
wxYield();
sim.Char(WXK_RETURN);
wxYield();
#ifdef __WXGTK__
for ( wxStopWatch sw; wxWindow::FindFocus() != m_grid; )
{
if ( sw.Time() > 250 )
{
WARN("Editor control not hidden until timeout expiration");
break;
}
wxYield();
}
#endif // __WXGTK__
CHECK(m_grid->GetCellValue(1, 1) == "abab");
CHECK(created.GetCount() == 1);
@@ -388,11 +362,16 @@ TEST_CASE_METHOD(GridTestCase, "Grid::Size", "[grid]")
// TODO on OSX resizing interactively works, but not automated
// Grid could not pass the test under GTK, OSX, and Universal.
// So there may has bug in Grid implementation
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) && !defined(__WXOSX__) \
&& !defined(__WXUNIVERSAL__)
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__) && !defined(__WXUNIVERSAL__)
if ( !EnableUITests() )
return;
#ifdef __WXGTK20__
// Works locally, but not when run on Travis CI.
if ( IsAutomaticTest() )
return;
#endif
EventCounter colsize(m_grid, wxEVT_GRID_COL_SIZE);
EventCounter rowsize(m_grid, wxEVT_GRID_ROW_SIZE);
@@ -400,7 +379,6 @@ TEST_CASE_METHOD(GridTestCase, "Grid::Size", "[grid]")
wxPoint pt = m_grid->ClientToScreen(wxPoint(m_grid->GetRowLabelSize() +
m_grid->GetColSize(0), 5));
sim.MouseMove(pt);
wxYield();
@@ -419,6 +397,7 @@ TEST_CASE_METHOD(GridTestCase, "Grid::Size", "[grid]")
m_grid->GetRowSize(0)));
sim.MouseDragDrop(pt.x, pt.y, pt.x, pt.y + 50);
wxYield();
CHECK(rowsize.GetCount() == 1);
@@ -1072,15 +1051,6 @@ TEST_CASE_METHOD(GridTestCase, "Grid::ReadOnly", "[grid]")
m_grid->SetFocus();
#ifdef __WXGTK__
// This is a mystery, but we somehow get WXK_RETURN generated by the
// previous test (Editable) in this one. In spite of wxYield() in that
// test, the key doesn't get dispatched there and we have to consume it
// here before setting the current grid cell, as getting WXK_RETURN later
// would move the selection down, to a non read-only cell.
wxYield();
#endif // __WXGTK__
m_grid->SetGridCursor(1, 1);
CHECK(m_grid->IsCurrentCellReadOnly());
@@ -1161,10 +1131,16 @@ TEST_CASE_METHOD(GridTestCase, "Grid::WindowAsEditorControl", "[grid]")
TEST_CASE_METHOD(GridTestCase, "Grid::ResizeScrolledHeader", "[grid]")
{
// TODO this test currently works only under Windows unfortunately
#if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__)
#if wxUSE_UIACTIONSIMULATOR && (defined(__WXMSW__) || defined(__WXGTK__))
if ( !EnableUITests() )
return;
#ifdef __WXGTK20__
// Works locally, but not when run on Travis CI.
if ( IsAutomaticTest() )
return;
#endif
SECTION("Default") {}
SECTION("Native header") { m_grid->UseNativeColHeader(); }
@@ -1206,10 +1182,16 @@ TEST_CASE_METHOD(GridTestCase, "Grid::ResizeScrolledHeader", "[grid]")
TEST_CASE_METHOD(GridTestCase, "Grid::ColumnMinWidth", "[grid]")
{
// TODO this test currently works only under Windows unfortunately
#if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__)
#if wxUSE_UIACTIONSIMULATOR && (defined(__WXMSW__) || defined(__WXGTK__))
if ( !EnableUITests() )
return;
#ifdef __WXGTK20__
// Works locally, but not when run on Travis CI.
if ( IsAutomaticTest() )
return;
#endif
SECTION("Default") {}
SECTION("Native header")
{