Skip to content

Commit 3f89c7a

Browse files
Add unit test for in-game window positioning
1 parent 2663d8b commit 3f89c7a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/s25Main/UI/testIngameWindow.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "controls/ctrlPercent.h"
1515
#include "controls/ctrlProgress.h"
1616
#include "desktops/dskGameLobby.h"
17+
#include "drivers/VideoDriverWrapper.h"
1718
#include "helpers/format.hpp"
1819
#include "ingameWindows/IngameWindow.h"
1920
#include "ingameWindows/iwConnecting.h"
@@ -228,4 +229,20 @@ BOOST_AUTO_TEST_CASE(SaveAndRestoreMinimized)
228229
}
229230
}
230231

232+
BOOST_AUTO_TEST_CASE(WindowPositioning)
233+
{
234+
const auto renderSize = VIDEODRIVER.GetRenderSize();
235+
IngameWindow wnd(0, DrawPoint(0, 0), Extent(100, 100), "Test Window", nullptr);
236+
237+
// start in bottom right corner; window should stick to the corner when resizing
238+
wnd.SetPos(DrawPoint(renderSize.x, renderSize.y));
239+
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
240+
241+
wnd.Resize(Extent(200, 200));
242+
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
243+
244+
wnd.Resize(Extent(100, 100));
245+
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
246+
}
247+
231248
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)