Skip to content

Commit 8e5821d

Browse files
FlamefireFlow86
authored andcommitted
Add simple test
1 parent 6471ed4 commit 8e5821d

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

tests/s25Main/UI/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2005 - 2021 Settlers Freaks <sf-team at siedler25.org>
1+
# Copyright (C) 2005 - 2025 Settlers Freaks <sf-team at siedler25.org>
22
#
33
# SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -7,6 +7,6 @@
77
add_subdirectory(uiHelper)
88

99
add_testcase(NAME UI
10-
LIBS s25Main testUIHelper rttr::vld
10+
LIBS s25Main testUIHelper rttr::vld testWorldFixtures
1111
COST 45
1212
)

tests/s25Main/UI/testWindows.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -10,17 +10,25 @@
1010
#include "controls/ctrlGroup.h"
1111
#include "controls/ctrlImage.h"
1212
#include "controls/ctrlMultiline.h"
13+
#include "controls/ctrlTextButton.h"
1314
#include "desktops/Desktop.h"
1415
#include "ingameWindows/iwAddons.h"
16+
#include "ingameWindows/iwSkipGFs.h"
1517
#include "ingameWindows/iwVictory.h"
1618
#include "uiHelper/uiHelpers.hpp"
19+
#include "worldFixtures/CreateEmptyWorld.h"
20+
#include "worldFixtures/WorldFixture.h"
21+
#include "world/GameWorldView.h"
22+
#include "world/GameWorldViewer.h"
1723
#include <turtle/mock.hpp>
1824
#include <boost/test/unit_test.hpp>
1925
#include <mygettext/mygettext.h>
2026

2127
//-V:MOCK_METHOD:813
2228
//-V:MOCK_EXPECT:807
2329

30+
using SmallWorldFixture = WorldFixture<CreateEmptyWorld, 1, 10, 10>;
31+
2432
BOOST_FIXTURE_TEST_SUITE(Windows, uiHelper::Fixture)
2533

2634
BOOST_AUTO_TEST_CASE(Victory)
@@ -78,6 +86,19 @@ BOOST_AUTO_TEST_CASE(AddonWindow)
7886
}
7987
}
8088

89+
BOOST_FIXTURE_TEST_CASE(JumpWindow, SmallWorldFixture)
90+
{
91+
// Test if it is constructible only, accesses GameClient for buttons
92+
GameWorldViewer gwv(0, world);
93+
GameWorldView view(gwv, Position(0, 0), Extent(100, 100));
94+
iwSkipGFs wnd(view);
95+
// At least 4 buttons for "jump by x" and at least 1 extra for "jump to"
96+
const auto bts = wnd.GetCtrls<ctrlTextButton>();
97+
BOOST_TEST(bts.size() > 4);
98+
const auto numIncBts = helpers::count_if(bts, [](const ctrlTextButton* bt) { return bt->GetText().at(0) == '+'; });
99+
BOOST_TEST(numIncBts >= 4);
100+
}
101+
81102
namespace {
82103
MOCK_BASE_CLASS(TestWindow, Window)
83104
{

0 commit comments

Comments
 (0)