Skip to content

Commit

Permalink
Add unit test for persistent window pinning
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger committed Jul 28, 2023
1 parent 631e363 commit 6ed192d
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions tests/s25Main/UI/testIngameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,27 +208,57 @@ BOOST_AUTO_TEST_CASE(SaveAndRestoreMinimized)
constexpr auto id = CGI_MINIMAP;
auto it = SETTINGS.windows.persistentSettings.find(id);
BOOST_REQUIRE(it != SETTINGS.windows.persistentSettings.end());
auto& settings = it->second;

{
it->second.isMinimized = false;
settings.isMinimized = false;

IngameWindow wnd(id, IngameWindow::posLastOrCenter, Extent(100, 100), "Test Window", nullptr);
BOOST_TEST(!wnd.IsMinimized());
BOOST_TEST(wnd.GetSize() == Extent(100, 100));

wnd.SetMinimized(true);
BOOST_TEST(it->second.isMinimized);
BOOST_TEST(settings.isMinimized);
}

{
it->second.isMinimized = true;
settings.isMinimized = true;

IngameWindow wnd(id, IngameWindow::posLastOrCenter, Extent(100, 100), "Test Window", nullptr);
BOOST_TEST(wnd.IsMinimized());
BOOST_TEST(wnd.GetSize() != Extent(100, 100));

wnd.SetMinimized(false);
BOOST_TEST(!it->second.isMinimized);
BOOST_TEST(!settings.isMinimized);
}
}

BOOST_AUTO_TEST_CASE(SaveAndRestorePinned)
{
constexpr auto id = CGI_MINIMAP;
auto it = SETTINGS.windows.persistentSettings.find(id);
BOOST_REQUIRE(it != SETTINGS.windows.persistentSettings.end());
auto& settings = it->second;

{
settings.isPinned = false;

IngameWindow wnd(id, IngameWindow::posLastOrCenter, Extent(100, 100), "Test Window", nullptr);
BOOST_TEST(!wnd.IsPinned());
BOOST_TEST(wnd.GetSize() == Extent(100, 100));

wnd.SetPinned();
BOOST_TEST(settings.isPinned);
}

{
settings.isPinned = true;

IngameWindow wnd(id, IngameWindow::posLastOrCenter, Extent(100, 100), "Test Window", nullptr);
BOOST_TEST(wnd.IsPinned());

wnd.SetPinned(false);
BOOST_TEST(!settings.isPinned);
}
}

Expand Down

0 comments on commit 6ed192d

Please sign in to comment.