diff --git a/autotest/CtrlFrame/CtrlFrame.upp b/autotest/CtrlFrame/CtrlFrame.upp new file mode 100644 index 000000000..5872304d3 --- /dev/null +++ b/autotest/CtrlFrame/CtrlFrame.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/autotest/CtrlFrame/main.cpp b/autotest/CtrlFrame/main.cpp new file mode 100644 index 000000000..c66d05e64 --- /dev/null +++ b/autotest/CtrlFrame/main.cpp @@ -0,0 +1,53 @@ +#include + +using namespace Upp; + +GUI_APP_MAIN +{ + NullFrameClass fr[50]; + for(int q = 0; q < 10000; q++) { + DLOG("=========="); + Ctrl h; + Vector h1; + int N = Random(40) + 1; + h1.Add(&NullFrame()); + for(int i = 0; i < N; i++) { + int pos = Random(h.GetFrameCount() + 1); + CtrlFrame& val = fr[Random(50)]; + h.InsertFrame(pos, val); + h1.Insert(pos, &val); + DDUMP(h.GetFrameCount()); + DDUMP(h1.GetCount()); + ASSERT(h1.GetCount() == h.GetFrameCount()); + for(int i = 0; i < h.GetFrameCount(); i++) + ASSERT(&h.GetFrame(i) == h1[i]); +#if 0 + DLOG("==========="); + DDUMP(pos); + DDUMP(val); + DDUMP(h.GetFrameCount()); + for(int i = 0; i < h.GetFrameCount(); i++) + DLOG(i << " " << h.GetFrame(i)); +#endif + } + while(h.GetFrameCount() > 1) { + int pos = Random(h.GetFrameCount()); + h.RemoveFrame(pos); + h1.Remove(pos); + DDUMP(h.GetFrameCount()); + DDUMP(h1.GetCount()); + ASSERT(h1.GetCount() == h.GetFrameCount()); + for(int i = 0; i < h.GetFrameCount(); i++) + ASSERT(&h.GetFrame(i) == h1[i]); +#if 0 + DLOG("==========="); + DDUMP(pos); + DDUMP(h.GetFrameCount()); + for(int i = 0; i < h.GetFrameCount(); i++) + DLOG(i << " " << h.GetFrame(i)); +#endif + } + } + + DLOG("================ OK"); +}