OpenTTD Source  20240919-master-gdf0233f4c2
test_window_desc.cpp File Reference
#include "../stdafx.h"
#include "../3rdparty/catch2/catch.hpp"
#include "mock_environment.h"
#include "../window_gui.h"

Go to the source code of this file.

Data Structures

class  WindowDescTestsFixture
 

Functions

 TEST_CASE ("WindowDesc - ini_key uniqueness")
 
 TEST_CASE ("WindowDesc - ini_key validity")
 
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 number of EndContainer() parts. More...
 
 TEST_CASE ("WindowDesc - NWidgetParts properly closed")
 
 TEST_CASE_METHOD (WindowDescTestsFixture, "WindowDesc - NWidgetPart validity")
 

Variables

std::vector< WindowDesc * > * _window_descs
 List of WindowDescs. More...
 

Detailed Description

Test WindowDescs for valid widget parts.

Definition in file test_window_desc.cpp.

Function Documentation

◆ IsNWidgetTreeClosed()

static bool IsNWidgetTreeClosed ( std::span< const NWidgetPart nwid_parts)
static

Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the number of EndContainer() parts.

Parameters
nwid_partsSpan of nested widget parts.
Returns
True iff nested tree is properly closed.

Definition at line 66 of file test_window_desc.cpp.

References IsContainerWidgetType(), and WPT_ENDCONTAINER.

Variable Documentation

◆ _window_descs

std::vector<WindowDesc*>* _window_descs

List of WindowDescs.

Defined in window.cpp but not exposed as this unit-test is the only other place that needs it. WindowDesc is a self-registering class so all WindowDescs will be included in the list.

List of WindowDescs.

This is a pointer to ensure initialisation order with the various static WindowDesc instances.

Definition at line 99 of file window.cpp.

Referenced by WindowDesc::LoadFromConfig(), WindowDesc::SaveToConfig(), and WindowDesc::WindowDesc().