From ed783b95f87743c6e97620a265eb1921dcd138e1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 15 Oct 2019 03:18:28 +0200 Subject: [PATCH] Add a hack to make wxGrid UI unit test pass This is an ugly workaround for a mysterious problem occurring with the simulated "Enter" presses under GTK, but it's worth it, as it allows all grid tests, including the ones using wxUIActionSimulator, to pass now under wxGTK2 (a couple of tests still fail under wxGTK3). --- tests/controls/gridtest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/controls/gridtest.cpp b/tests/controls/gridtest.cpp index bae013388d..d2c42b4441 100644 --- a/tests/controls/gridtest.cpp +++ b/tests/controls/gridtest.cpp @@ -818,6 +818,16 @@ void GridTestCase::ReadOnly() CPPUNIT_ASSERT(m_grid->IsReadOnly(1, 1)); 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); CPPUNIT_ASSERT(m_grid->IsCurrentCellReadOnly());