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".
This commit is contained in:
Vadim Zeitlin 2021-07-22 19:15:50 +02:00
parent e6bac095ca
commit 9dbf063a75

View File

@ -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);
}