Ensure that test windows are destroyed in TLW unit test
Don't leave the maximized frame created in the test case for getting events from it lying around needlessly.
This commit is contained in:
@@ -26,6 +26,25 @@
|
|||||||
|
|
||||||
#include "testableframe.h"
|
#include "testableframe.h"
|
||||||
|
|
||||||
|
class DestroyOnScopeExit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DestroyOnScopeExit(wxTopLevelWindow* tlw)
|
||||||
|
: m_tlw(tlw)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~DestroyOnScopeExit()
|
||||||
|
{
|
||||||
|
m_tlw->Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxTopLevelWindow* const m_tlw;
|
||||||
|
|
||||||
|
wxDECLARE_NO_COPY_CLASS(DestroyOnScopeExit);
|
||||||
|
};
|
||||||
|
|
||||||
static void TopLevelWindowShowTest(wxTopLevelWindow* tlw)
|
static void TopLevelWindowShowTest(wxTopLevelWindow* tlw)
|
||||||
{
|
{
|
||||||
CHECK(!tlw->IsShown());
|
CHECK(!tlw->IsShown());
|
||||||
@@ -68,15 +87,17 @@ TEST_CASE("wxTopLevel::Show", "[tlw][show]")
|
|||||||
SECTION("Dialog")
|
SECTION("Dialog")
|
||||||
{
|
{
|
||||||
wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
|
wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
|
||||||
|
DestroyOnScopeExit destroy(dialog);
|
||||||
|
|
||||||
TopLevelWindowShowTest(dialog);
|
TopLevelWindowShowTest(dialog);
|
||||||
dialog->Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Frame")
|
SECTION("Frame")
|
||||||
{
|
{
|
||||||
wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
|
wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
|
||||||
|
DestroyOnScopeExit destroy(frame);
|
||||||
|
|
||||||
TopLevelWindowShowTest(frame);
|
TopLevelWindowShowTest(frame);
|
||||||
frame->Destroy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +105,7 @@ TEST_CASE("wxTopLevel::Show", "[tlw][show]")
|
|||||||
TEST_CASE("wxTopLevel::ShowEvent", "[tlw][show][event]")
|
TEST_CASE("wxTopLevel::ShowEvent", "[tlw][show][event]")
|
||||||
{
|
{
|
||||||
wxFrame* const frame = new wxFrame(NULL, wxID_ANY, "Maximized frame");
|
wxFrame* const frame = new wxFrame(NULL, wxID_ANY, "Maximized frame");
|
||||||
|
DestroyOnScopeExit destroy(frame);
|
||||||
|
|
||||||
EventCounter countShow(frame, wxEVT_SHOW);
|
EventCounter countShow(frame, wxEVT_SHOW);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user