Skip to content

Commit

Permalink
Add unit test for persistent window minimization
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger authored and Flow86 committed Jul 22, 2023
1 parent c439431 commit 5bf5c92
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/s25Main/UI/testIngameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

#include "DrawPoint.h"
#include "Point.h"
#include "PointOutput.h"
#include "Settings.h"
#include "WindowManager.h"
#include "controls/ctrlButton.h"
#include "controls/ctrlComboBox.h"
Expand All @@ -12,13 +15,15 @@
#include "controls/ctrlProgress.h"
#include "desktops/dskGameLobby.h"
#include "helpers/format.hpp"
#include "ingameWindows/IngameWindow.h"
#include "ingameWindows/iwConnecting.h"
#include "ingameWindows/iwDirectIPConnect.h"
#include "ingameWindows/iwHelp.h"
#include "ingameWindows/iwMapGenerator.h"
#include "ingameWindows/iwMsgbox.h"
#include "uiHelper/uiHelpers.hpp"
#include "gameTypes/GameTypesOutput.h"
#include "gameData/const_gui_ids.h"
#include "rttr/test/random.hpp"
#include "s25util/StringConversion.h"
#include <turtle/mock.hpp>
Expand Down Expand Up @@ -194,4 +199,33 @@ BOOST_AUTO_TEST_CASE(ConnectingWindow)
}
}

BOOST_AUTO_TEST_CASE(SaveAndRestoreMinimized)
{
constexpr auto id = CGI_MINIMAP;
auto it = SETTINGS.windows.persistentSettings.find(id);
BOOST_REQUIRE(it != SETTINGS.windows.persistentSettings.end());

{
it->second.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);
}

{
it->second.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_AUTO_TEST_SUITE_END()

0 comments on commit 5bf5c92

Please sign in to comment.