12#include "../3rdparty/catch2/catch.hpp"
16#include "../window_gui.h"
18#include "../safeguards.h"
33TEST_CASE(
"WindowDesc - ini_key uniqueness")
35 std::set<std::string_view> seen;
39 if (window_desc->ini_key.empty())
continue;
41 CAPTURE(window_desc->ini_key);
42 CHECK((seen.find(window_desc->ini_key) == std::end(seen)));
44 seen.insert(window_desc->ini_key);
48TEST_CASE(
"WindowDesc - ini_key validity")
52 bool has_inikey = !window_desc->
ini_key.empty();
53 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; });
59 CHECK((has_widget == has_inikey));
71 for (
const auto nwid : nwid_parts) {
78TEST_CASE(
"WindowDesc - NWidgetParts properly closed")
94 std::unique_ptr<NWidgetBase> root =
nullptr;
97 CHECK((root !=
nullptr));
Singleton class to set up the mock environment once.
Singleton instance to create a mock FontCache/SpriteCache environment.
High level window description.
const std::string_view ini_key
Key to store window defaults in openttd.cfg. An empty string 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.