From b4eb5438a429f6ec6e2ca7a7d92fc10fa1b05e2e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 1 Apr 2020 22:48:19 +0200 Subject: [PATCH] Add a unit test for wxTextCtrl event generation on creation Check that creating a wxTextCtrl doesn't generate any events to verify that this problem doesn't exist in other ports, after fixing it in wxGTK in 3e7e7dd24c (Avoid generating wxEVT_TEXT when wxTextCtrl initial value is not empty, 2020-04-01). --- tests/controls/textctrltest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 90990c0d2b..795adcd981 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -1422,4 +1422,22 @@ TEST_CASE("wxTextCtrl::LongPaste", "[wxTextCtrl][clipboard][paste]") #endif // wxUSE_CLIPBOARD +TEST_CASE("wxTextCtrl::EventsOnCreate", "[wxTextCtrl][event]") +{ + wxWindow* const parent = wxTheApp->GetTopWindow(); + + EventCounter updated(parent, wxEVT_TEXT); + + wxScopedPtr text(new wxTextCtrl(parent, wxID_ANY, "Hello")); + + // Creating the control shouldn't result in any wxEVT_TEXT events. + CHECK( updated.GetCount() == 0 ); + + // Check that modifying using SetValue() it does generate the event, just + // to verify that this test works (there are more detailed tests for this + // in TextEntryTestCase::TextChangeEvents()). + text->SetValue("Bye"); + CHECK( updated.GetCount() == 1 ); +} + #endif //wxUSE_TEXTCTRL