From 9dbf063a75773a25b991cd8170d729fd195149bc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2021 19:15:50 +0200 Subject: [PATCH] Fix ProcessEnter unit tests when running it on its own with wxGTK Apparently setting focus doesn't work until a mouse click is simulated to bring up the main test window to the front. This happened implicitly when running the full test suite, due to e.g. doing it in wxButton unit tests, which come before wxComboBox::ProcessEnter test, but not when running just this test (or wxTextCtrl::ProcessEnter) on its own. Make the test self-contained by simulating a mouse click before simulating pressing "Enter". --- tests/controls/textentrytest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/controls/textentrytest.cpp b/tests/controls/textentrytest.cpp index e24db45622..ee689bad64 100644 --- a/tests/controls/textentrytest.cpp +++ b/tests/controls/textentrytest.cpp @@ -464,7 +464,21 @@ private: void SimulateEnter() { wxUIActionSimulator sim; + + // Calling SetFocus() is somehow not enough to give the focus to this + // window when running this test with wxGTK, apparently because the + // dialog itself needs to be raised to the front first, so simulate a + // click doing this. + sim.MouseMove(m_control->GetScreenPosition() + wxPoint(5, 5)); + wxYield(); + sim.MouseClick(); + wxYield(); + + // Note that clicking it is still not enough to give it focus with + // wxGTK neither, so we still need to call SetFocus() nevertheless: but + // now it works. m_control->SetFocus(); + sim.Char(WXK_RETURN); }