Test that adding window to 2 sizers results in an assert
Check that adding a window to either the same, or different, sizer the second time asserts -- but that it can still be moved to another sizer if it is detached from the first one first. Also document that SetContainingSizer() should never be called from outside the library. See #17166.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/caret.h"
|
||||
#include "wx/cshelp.h"
|
||||
#include "wx/scopedptr.h"
|
||||
#include "wx/tooltip.h"
|
||||
|
||||
class WindowTestCase
|
||||
@@ -379,3 +380,19 @@ TEST_CASE_METHOD(WindowTestCase, "Window::FindWindowBy", "[window]")
|
||||
CHECK( wxWindow::FindWindowByName("noname") == NULL );
|
||||
CHECK( wxWindow::FindWindowByLabel("nolabel") == NULL );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::SizerErrors", "[window][sizer][error]")
|
||||
{
|
||||
wxWindow* const child = new wxWindow(m_window, wxID_ANY);
|
||||
wxScopedPtr<wxSizer> const sizer1(new wxBoxSizer(wxHORIZONTAL));
|
||||
wxScopedPtr<wxSizer> const sizer2(new wxBoxSizer(wxHORIZONTAL));
|
||||
|
||||
REQUIRE_NOTHROW( sizer1->Add(child) );
|
||||
CHECK_THROWS_AS( sizer1->Add(child), TestAssertFailure );
|
||||
CHECK_THROWS_AS( sizer2->Add(child), TestAssertFailure );
|
||||
|
||||
CHECK_NOTHROW( sizer1->Detach(child) );
|
||||
CHECK_NOTHROW( sizer2->Add(child) );
|
||||
|
||||
REQUIRE_NOTHROW( delete child );
|
||||
}
|
||||
|
Reference in New Issue
Block a user