From e599e26395e005a7a1fb2265f7ee20df8658a04c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 29 Jan 2019 00:08:44 +0100 Subject: [PATCH 1/2] Test that showing a TLW generates wxActivateEvent Wait until wxEVT_ACTIVATE arrives and check that it does. --- tests/toplevel/toplevel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/toplevel/toplevel.cpp b/tests/toplevel/toplevel.cpp index 3e94f12c8d..5a2d83025f 100644 --- a/tests/toplevel/toplevel.cpp +++ b/tests/toplevel/toplevel.cpp @@ -45,7 +45,13 @@ static void TopLevelWindowShowTest(wxTopLevelWindow* tlw) CHECK(!tlw->IsActive()); #endif + // Note that at least under MSW, ShowWithoutActivating() still generates + // wxActivateEvent, so we must only start counting these events after the + // end of the tests above. + EventCounter countActivate(tlw, wxEVT_ACTIVATE); + tlw->Show(true); + countActivate.WaitEvent(); // wxGTK needs many event loop iterations before the TLW becomes active and // this doesn't happen in this test, so avoid checking for it. From f9323e4b87c6ea50dc46c70c85a661da397661d5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 29 Jan 2019 00:16:52 +0100 Subject: [PATCH 2/2] Enable tests for wxTopLevelWindow::IsActive() for wxGTK too After the addition of EventCounter::WaitEvent() call in the previous commit these checks pass as well (with another WaitEvent() added to wait for deactivation event as well). --- tests/toplevel/toplevel.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/toplevel/toplevel.cpp b/tests/toplevel/toplevel.cpp index 5a2d83025f..7f4a09fca6 100644 --- a/tests/toplevel/toplevel.cpp +++ b/tests/toplevel/toplevel.cpp @@ -53,18 +53,14 @@ static void TopLevelWindowShowTest(wxTopLevelWindow* tlw) tlw->Show(true); countActivate.WaitEvent(); - // wxGTK needs many event loop iterations before the TLW becomes active and - // this doesn't happen in this test, so avoid checking for it. -#ifndef __WXGTK__ CHECK(tlw->IsActive()); -#endif CHECK(tlw->IsShown()); tlw->Hide(); CHECK(!tlw->IsShown()); -#ifndef __WXGTK__ + + countActivate.WaitEvent(); CHECK(!tlw->IsActive()); -#endif } TEST_CASE("wxTopLevel::Show", "[tlw][show]")