Merge branch 'ui-tests-fixes'
Attempt to work around failures in UI tests under AppVeyor. See #24162.
This commit is contained in:
commit
bac0aa0e83
1 changed files with 117 additions and 40 deletions
|
|
@ -194,6 +194,41 @@ void FitGridToMulticell(TestableGrid* grid, const Multicell& multi)
|
|||
}
|
||||
}
|
||||
|
||||
// Function used to wait until the given predicate becomes true or timeout
|
||||
// expires or the mouse moves away, in which case the test is abandoned.
|
||||
bool
|
||||
WaitForEventAt(
|
||||
const wxPoint& pos,
|
||||
const char* what,
|
||||
const std::function<bool ()>& pred,
|
||||
int timeout = 500
|
||||
)
|
||||
{
|
||||
wxStopWatch sw;
|
||||
for ( ;; )
|
||||
{
|
||||
wxYield();
|
||||
|
||||
if ( pred() )
|
||||
break;
|
||||
|
||||
if ( wxGetMousePosition() != pos )
|
||||
{
|
||||
WARN("Mouse unexpectedly moved to " << wxGetMousePosition()
|
||||
<< " from the expected " << pos << "; skipping test");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( sw.Time() > timeout )
|
||||
{
|
||||
FAIL("Timed out waiting for " << what);
|
||||
break; // unreachable
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace Catch
|
||||
|
|
@ -439,13 +474,18 @@ TEST_CASE_METHOD(GridTestCase, "Grid::CellClick", "[grid]")
|
|||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
if ( !WaitForEventAt(point, "mouse click to be processed", [&]() {
|
||||
return lclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
CHECK(lclick.GetCount() == 1);
|
||||
lclick.Clear();
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
if ( !WaitForEventAt(point, "double click to be processed", [&]() {
|
||||
return lclick.GetCount() != 0 || ldclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
|
||||
//A double click event sends a single click event first
|
||||
//test to ensure this still happens in the future
|
||||
|
|
@ -453,13 +493,18 @@ TEST_CASE_METHOD(GridTestCase, "Grid::CellClick", "[grid]")
|
|||
CHECK(ldclick.GetCount() == 1);
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
if ( !WaitForEventAt(point, "right click to be processed", [&]() {
|
||||
return rclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
CHECK(rclick.GetCount() == 1);
|
||||
rclick.Clear();
|
||||
|
||||
sim.MouseDblClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
if ( !WaitForEventAt(point, "right double click to be processed", [&]() {
|
||||
return rclick.GetCount() != 0 || rdclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
|
||||
CHECK(rclick.GetCount() == 1);
|
||||
CHECK(rdclick.GetCount() == 1);
|
||||
|
|
@ -537,9 +582,13 @@ TEST_CASE_METHOD(GridTestCase, "Grid::LabelClick", "[grid]")
|
|||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
SECTION("Default") {}
|
||||
SECTION("Native header") { m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { m_grid->SetUseNativeColLabels(); }
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header") { desc = "native header"; m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { desc = "native labels"; m_grid->SetUseNativeColLabels(); }
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
EventCounter lclick(m_grid, wxEVT_GRID_LABEL_LEFT_CLICK);
|
||||
EventCounter ldclick(m_grid, wxEVT_GRID_LABEL_LEFT_DCLICK);
|
||||
|
|
@ -555,29 +604,32 @@ TEST_CASE_METHOD(GridTestCase, "Grid::LabelClick", "[grid]")
|
|||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
WaitFor("mouse click to be processed", [&]() {
|
||||
return lclick.GetCount() != 0;
|
||||
});
|
||||
if ( !WaitForEventAt(pos, "mouse click to be processed", [&]() {
|
||||
return lclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
CHECK(lclick.GetCount() == 1);
|
||||
|
||||
sim.MouseDblClick();
|
||||
WaitFor("mouse double click to be processed", [&]() {
|
||||
return ldclick.GetCount() != 0;
|
||||
});
|
||||
if ( !WaitForEventAt(pos, "mouse double click to be processed", [&]() {
|
||||
return ldclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
CHECK(ldclick.GetCount() == 1);
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
WaitFor("mouse right click to be processed", [&]() {
|
||||
return rclick.GetCount() != 0;
|
||||
});
|
||||
|
||||
if ( !WaitForEventAt(pos, "mouse right click to be processed", [&]() {
|
||||
return rclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
CHECK(rclick.GetCount() == 1);
|
||||
rclick.Clear();
|
||||
|
||||
sim.MouseDblClick(wxMOUSE_BTN_RIGHT);
|
||||
WaitFor("mouse right double click to be processed", [&]() {
|
||||
return rclick.GetCount() != 0;
|
||||
});
|
||||
if ( !WaitForEventAt(pos, "mouse right double click to be processed", [&]() {
|
||||
return rclick.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
|
||||
if ( m_grid->IsUsingNativeHeader() )
|
||||
{
|
||||
|
|
@ -599,9 +651,13 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SortClick", "[grid]")
|
|||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
SECTION("Default") {}
|
||||
SECTION("Native header") { m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { m_grid->SetUseNativeColLabels(); }
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header") { desc = "native header"; m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { desc = "native labels"; m_grid->SetUseNativeColLabels(); }
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
m_grid->SetSortingColumn(0);
|
||||
|
||||
|
|
@ -616,10 +672,10 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SortClick", "[grid]")
|
|||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
WaitFor("mouse click to be processed", [&]() {
|
||||
return sort.GetCount() != 0;
|
||||
});
|
||||
|
||||
if ( !WaitForEventAt(pos, "mouse click to be processed", [&]() {
|
||||
return sort.GetCount() != 0;
|
||||
}) )
|
||||
return;
|
||||
CHECK(sort.GetCount() == 1);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1057,8 +1113,12 @@ TEST_CASE_METHOD(GridTestCase, "Grid::AddRowCol", "[grid]")
|
|||
|
||||
TEST_CASE_METHOD(GridTestCase, "Grid::DeleteAndAddRowCol", "[grid]")
|
||||
{
|
||||
SECTION("Default") {}
|
||||
SECTION("Native header") { m_grid->UseNativeColHeader(); }
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header") { desc = "native header"; m_grid->UseNativeColHeader(); }
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
CHECK(m_grid->GetNumberRows() == 10);
|
||||
CHECK(m_grid->GetNumberCols() == 2);
|
||||
|
|
@ -1089,9 +1149,13 @@ TEST_CASE_METHOD(GridTestCase, "Grid::DeleteAndAddRowCol", "[grid]")
|
|||
|
||||
TEST_CASE_METHOD(GridTestCase, "Grid::ColumnOrder", "[grid]")
|
||||
{
|
||||
SECTION("Default") {}
|
||||
SECTION("Native header") { m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { m_grid->SetUseNativeColLabels(); }
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header") { desc = "native header"; m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { desc = "native labels"; m_grid->SetUseNativeColLabels(); }
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
m_grid->AppendCols(2);
|
||||
|
||||
|
|
@ -1504,8 +1568,12 @@ TEST_CASE_METHOD(GridTestCase, "Grid::ResizeScrolledHeader", "[grid]")
|
|||
|
||||
wxSKIP_AUTOMATIC_TEST_IF_GTK2();
|
||||
|
||||
SECTION("Default") {}
|
||||
SECTION("Native header") { m_grid->UseNativeColHeader(); }
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header") { desc = "native header"; m_grid->UseNativeColHeader(); }
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
int const startwidth = m_grid->GetColSize(0);
|
||||
int const draglength = 100;
|
||||
|
|
@ -1555,7 +1623,9 @@ TEST_CASE_METHOD(GridTestCase, "Grid::ColumnMinWidth", "[grid]")
|
|||
|
||||
wxSKIP_AUTOMATIC_TEST_IF_GTK2();
|
||||
|
||||
SECTION("Default") {}
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header")
|
||||
{
|
||||
// For some unknown reason, this test fails under AppVeyor even though
|
||||
|
|
@ -1564,9 +1634,12 @@ TEST_CASE_METHOD(GridTestCase, "Grid::ColumnMinWidth", "[grid]")
|
|||
if ( IsAutomaticTest() )
|
||||
return;
|
||||
|
||||
desc = "native header";
|
||||
m_grid->UseNativeColHeader();
|
||||
}
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
int const startminwidth = m_grid->GetColMinimalAcceptableWidth();
|
||||
m_grid->SetColMinimalAcceptableWidth(startminwidth*2);
|
||||
int const newminwidth = m_grid->GetColMinimalAcceptableWidth();
|
||||
|
|
@ -1612,9 +1685,13 @@ void GridTestCase::CheckFirstColAutoSize(int expected)
|
|||
|
||||
TEST_CASE_METHOD(GridTestCase, "Grid::AutoSizeColumn", "[grid]")
|
||||
{
|
||||
SECTION("Default") {}
|
||||
SECTION("Native header") { m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { m_grid->SetUseNativeColLabels(); }
|
||||
wxString desc;
|
||||
|
||||
SECTION("Default") { desc = "default header"; }
|
||||
SECTION("Native header") { desc = "native header"; m_grid->UseNativeColHeader(); }
|
||||
SECTION("Native labels") { desc = "native labels"; m_grid->SetUseNativeColLabels(); }
|
||||
|
||||
INFO("Using " << desc);
|
||||
|
||||
// Hardcoded extra margin for the columns used in grid.cpp.
|
||||
const int margin = m_grid->FromDIP(10);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue