KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_text_variable_resolution.cpp File Reference

Unit tests for text variable resolution in PCB, specifically testing that project text variables are resolved dynamically rather than from cached values. More...

#include <qa_utils/wx_utils/unit_test_utils.h>
#include <boost/test/unit_test.hpp>
#include <board.h>
#include <pcb_text.h>
#include <project.h>
#include <settings/settings_manager.h>

Go to the source code of this file.

Classes

struct  TEXT_VAR_RESOLUTION_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (ProjectTextVarsTakePrecedence)
 Project text variables must win over the board's cached properties so an external edit (schematic, project settings) is reflected without reloading the board.
 
 BOOST_AUTO_TEST_CASE (ProjectTextVarsUpdateDynamically)
 Updating a project text variable is reflected immediately, without a SynchronizeProperties call.
 
 BOOST_AUTO_TEST_CASE (TitleBlockVarsTakePrecedence)
 Title block fields win over both the project text variables and the board's cached properties, matching the resolution order used by the schematic.
 
 BOOST_AUTO_TEST_CASE (BoardPropertiesFallback)
 Board properties are used as a fallback when the variable is not defined in the project, keeping legacy boards (and boards loaded without a project) working.
 
 BOOST_AUTO_TEST_CASE (PcbTextResolvesProjectVars)
 PCB_TEXT::GetShownText resolves variables through the board with project precedence and reflects a project variable update on the next call.
 

Detailed Description

Unit tests for text variable resolution in PCB, specifically testing that project text variables are resolved dynamically rather than from cached values.

This addresses GitLab issue #14360 where text variables were not updated when the project file changed externally.

Definition in file test_text_variable_resolution.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( BoardPropertiesFallback )

Board properties are used as a fallback when the variable is not defined in the project, keeping legacy boards (and boards loaded without a project) working.

Definition at line 127 of file test_text_variable_resolution.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( PcbTextResolvesProjectVars )

PCB_TEXT::GetShownText resolves variables through the board with project precedence and reflects a project variable update on the next call.

The colliding board property guards the ordering, so the test fails under the old properties-first ordering.

Definition at line 145 of file test_text_variable_resolution.cpp.

References BOOST_CHECK_EQUAL(), and text.

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( ProjectTextVarsTakePrecedence )

Project text variables must win over the board's cached properties so an external edit (schematic, project settings) is reflected without reloading the board.

This is the core regression guard for issue #14360 and fails under the old properties-first ordering.

Definition at line 65 of file test_text_variable_resolution.cpp.

References BOOST_AUTO_TEST_CASE(), and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( ProjectTextVarsUpdateDynamically )

Updating a project text variable is reflected immediately, without a SynchronizeProperties call.

Definition at line 84 of file test_text_variable_resolution.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( TitleBlockVarsTakePrecedence )

Title block fields win over both the project text variables and the board's cached properties, matching the resolution order used by the schematic.

The colliding project var and board property exercise the title-block-over-properties ordering that this fix changed; the test fails under the old properties-first ordering.

Definition at line 107 of file test_text_variable_resolution.cpp.

References BOOST_CHECK_EQUAL().