Skip to content

Commit 67b6ab0

Browse files
Add unit test for persistent window minimization
1 parent 1c7ea7e commit 67b6ab0

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/s25Main/UI/testIngameWindow.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

5+
#include "DrawPoint.h"
6+
#include "Point.h"
57
#include "PointOutput.h"
8+
#include "Settings.h"
69
#include "WindowManager.h"
710
#include "controls/ctrlButton.h"
811
#include "controls/ctrlComboBox.h"
@@ -12,13 +15,15 @@
1215
#include "controls/ctrlProgress.h"
1316
#include "desktops/dskGameLobby.h"
1417
#include "helpers/format.hpp"
18+
#include "ingameWindows/IngameWindow.h"
1519
#include "ingameWindows/iwConnecting.h"
1620
#include "ingameWindows/iwDirectIPConnect.h"
1721
#include "ingameWindows/iwHelp.h"
1822
#include "ingameWindows/iwMapGenerator.h"
1923
#include "ingameWindows/iwMsgbox.h"
2024
#include "uiHelper/uiHelpers.hpp"
2125
#include "gameTypes/GameTypesOutput.h"
26+
#include "gameData/const_gui_ids.h"
2227
#include "rttr/test/random.hpp"
2328
#include "s25util/StringConversion.h"
2429
#include <turtle/mock.hpp>
@@ -194,4 +199,33 @@ BOOST_AUTO_TEST_CASE(ConnectingWindow)
194199
}
195200
}
196201

202+
BOOST_AUTO_TEST_CASE(SaveAndRestoreMinimized)
203+
{
204+
constexpr auto id = CGI_MINIMAP;
205+
auto it = SETTINGS.windows.persistentSettings.find(id);
206+
BOOST_REQUIRE(it !=SETTINGS.windows.persistentSettings.end());
207+
208+
{
209+
it->second.isMinimized = false;
210+
211+
IngameWindow wnd(id, IngameWindow::posLastOrCenter, Extent(100, 100), "Test Window", nullptr);
212+
BOOST_TEST(!wnd.IsMinimized());
213+
BOOST_TEST(wnd.GetSize() == Extent(100, 100));
214+
215+
wnd.SetMinimized(true);
216+
BOOST_TEST(it->second.isMinimized);
217+
}
218+
219+
{
220+
it->second.isMinimized = true;
221+
222+
IngameWindow wnd(id, IngameWindow::posLastOrCenter, Extent(100, 100), "Test Window", nullptr);
223+
BOOST_TEST(wnd.IsMinimized());
224+
BOOST_TEST(wnd.GetSize() != Extent(100, 100));
225+
226+
wnd.SetMinimized(false);
227+
BOOST_TEST(!it->second.isMinimized);
228+
}
229+
}
230+
197231
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)