Skip to content

Commit 206ea1f

Browse files
Add unit test for ingame window positioning
1 parent 5fa683e commit 206ea1f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/s25Main/UI/testIngameWindow.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include "controls/ctrlPercent.h"
1212
#include "controls/ctrlProgress.h"
1313
#include "desktops/dskGameLobby.h"
14+
#include "drivers/VideoDriverWrapper.h"
1415
#include "helpers/format.hpp"
16+
#include "ingameWindows/IngameWindow.h"
1517
#include "ingameWindows/iwConnecting.h"
1618
#include "ingameWindows/iwDirectIPConnect.h"
1719
#include "ingameWindows/iwHelp.h"
@@ -194,4 +196,20 @@ BOOST_AUTO_TEST_CASE(ConnectingWindow)
194196
}
195197
}
196198

199+
BOOST_AUTO_TEST_CASE(WindowPositioning)
200+
{
201+
const auto renderSize = VIDEODRIVER.GetRenderSize();
202+
IngameWindow wnd(0, DrawPoint(0, 0), Extent(100, 100), "", nullptr);
203+
204+
// start in bottom right corner; window should stick to the corner when resizing
205+
wnd.SetPos(DrawPoint(renderSize.x, renderSize.y));
206+
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
207+
208+
wnd.Resize(Extent(200, 200));
209+
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
210+
211+
wnd.Resize(Extent(100, 100));
212+
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
213+
}
214+
197215
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)