Add unit test for wxWrapSizer::CalcMinFromMinor

Add a unit test for a special case of a wrap sizer min size caclulation.
Test wxWrapSizer::CalcMinFromMinor function for this case, when a wrap
sizer used inside a sizer with the same alignment.
This commit is contained in:
Ilya Sinitsyn
2019-03-15 00:09:35 +07:00
parent e2a9fb1fba
commit d5a6a5a627

View File

@@ -74,3 +74,42 @@ TEST_CASE("wxWrapSizer::CalcMin", "[wxWrapSizer]")
CHECK( sizeMinExpected == sizer->CalcMin() );
}
TEST_CASE("wxWrapSizer::CalcMinFromMinor", "[wxWrapSizer]")
{
wxScopedPtr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
win->SetClientSize(180, 240);
wxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
win->SetSizer(boxSizer);
// To test CalcMinFromMinor function the wrap sizer with the
// horizonral align added to the box sizer with horizontal align.
wxSizer* wrapSizer = new wxWrapSizer(wxHORIZONTAL);
boxSizer->Add(wrapSizer);
// Add three child windows. Sum of the first and the second windows widths should
// be less than the width of the third window.
const wxSize sizeChild1 = wxSize(40, 60);
wxWindow * const
child1 = new wxWindow(win.get(), wxID_ANY, wxDefaultPosition, sizeChild1);
child1->SetBackgroundColour(*wxRED);
wrapSizer->Add(child1);
const wxSize sizeChild2 = wxSize(50, 80);
wxWindow * const
child2 = new wxWindow(win.get(), wxID_ANY, wxDefaultPosition, sizeChild2);
child2->SetBackgroundColour(*wxGREEN);
wrapSizer->Add(child2);
const wxSize sizeChild3 = wxSize(100, 120);
wxWindow * const
child3 = new wxWindow(win.get(), wxID_ANY, wxDefaultPosition, sizeChild3);
child3->SetBackgroundColour(*wxBLUE);
wrapSizer->Add(child3);
// First two windows should be in a first row and the third in a second row.
const wxSize sizeMinExpected = wxSize(sizeChild3.x, sizeChild2.y + sizeChild3.y);
win->Layout();
CHECK(sizeMinExpected == wrapSizer->CalcMin());
}