From 5bf5c923ae9aa822e05050021ac159e9ecdc68ab Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Wed, 19 Jul 2023 15:34:55 +0200 Subject: [PATCH] Add unit test for persistent window minimization --- tests/s25Main/UI/testIngameWindow.cpp | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/s25Main/UI/testIngameWindow.cpp b/tests/s25Main/UI/testIngameWindow.cpp index e9ab1392a..f5c69499a 100644 --- a/tests/s25Main/UI/testIngameWindow.cpp +++ b/tests/s25Main/UI/testIngameWindow.cpp @@ -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" @@ -12,6 +15,7 @@ #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" @@ -19,6 +23,7 @@ #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 @@ -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()