10 #include "../stdafx.h"
12 #include "../3rdparty/catch2/catch.hpp"
16 #include "../window_gui.h"
31 TEST_CASE(
"WindowDesc - ini_key uniqueness")
33 std::set<std::string> seen;
37 if (window_desc->ini_key ==
nullptr)
continue;
39 CAPTURE(window_desc->ini_key);
40 CHECK((seen.find(window_desc->ini_key) == std::end(seen)));
42 seen.insert(window_desc->ini_key);
46 TEST_CASE(
"WindowDesc - ini_key validity")
50 bool has_inikey = window_desc->
ini_key !=
nullptr;
51 bool has_widget = std::any_of(std::begin(window_desc->
nwid_parts), std::end(window_desc->
nwid_parts), [](
const NWidgetPart &part) { return part.type == WWT_DEFSIZEBOX || part.type == WWT_STICKYBOX; });
57 CHECK((has_widget == has_inikey));
69 for (
const auto nwid : nwid_parts) {
76 TEST_CASE(
"WindowDesc - NWidgetParts properly closed")
92 std::unique_ptr<NWidgetBase> root =
nullptr;
95 CHECK((root !=
nullptr));
Singleton class to set up the mock environemnt once.
Singleton instance to create a mock FontCache/SpriteCache environment.
High level window description.
const char * ini_key
Key to store window defaults in openttd.cfg. nullptr if nothing shall be stored.
const std::source_location source_location
Source location of this definition.
const std::span< const NWidgetPart > nwid_parts
Span of nested widget parts describing the window.
static bool IsNWidgetTreeClosed(std::span< const NWidgetPart > nwid_parts)
Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the numb...
std::vector< WindowDesc * > * _window_descs
List of WindowDescs.