Skip to content

Commit

Permalink
Add unit test for in-game window positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger committed Jul 22, 2023
1 parent d96af72 commit 6c52c86
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/s25Main/UI/testIngameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "controls/ctrlPercent.h"
#include "controls/ctrlProgress.h"
#include "desktops/dskGameLobby.h"
#include "drivers/VideoDriverWrapper.h"
#include "helpers/format.hpp"
#include "ingameWindows/IngameWindow.h"
#include "ingameWindows/iwConnecting.h"
Expand Down Expand Up @@ -228,4 +229,21 @@ BOOST_AUTO_TEST_CASE(SaveAndRestoreMinimized)
}
}

BOOST_AUTO_TEST_CASE(WindowPositioning)
{
const auto renderSize = VIDEODRIVER.GetRenderSize();
// Use a window with persistent settings
IngameWindow wnd(CGI_MINIMAP, DrawPoint(0, 0), Extent(100, 100), "Test Window", nullptr);

// start in bottom right corner; window should stick to the corner when resizing
wnd.SetPos(DrawPoint(renderSize.x, renderSize.y));
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));

wnd.Resize(Extent(200, 200));
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));

wnd.Resize(Extent(100, 100));
BOOST_TEST(wnd.GetPos() == DrawPoint(renderSize - wnd.GetSize()));
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 6c52c86

Please sign in to comment.