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

Test suite for embedded files in LIB_SYMBOL objects, including derived symbols. More...

#include <qa_utils/wx_utils/unit_test_utils.h>
#include <lib_symbol.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <sch_io/sch_io_mgr.h>
#include <embedded_files.h>
#include <mmh3_hash.h>
#include <schematic.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_symbol.h>
#include <project.h>
#include <lib_id.h>
#include <settings/settings_manager.h>
#include <wx/filename.h>
#include <wx/dir.h>

Go to the source code of this file.

Classes

class  SYMBOL_EMBEDDED_FILES_TEST_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (DerivedSymbolEmbeddedFiles)
 Test embedded files in parent and derived symbols: 1) Create a symbol and add an embedded file and save.
 
 BOOST_AUTO_TEST_CASE (CopySymbolPreservesEmbeddedFiles)
 Test that copying a symbol with embedded files preserves the files.
 
 BOOST_AUTO_TEST_CASE (AssignmentPreservesEmbeddedFiles)
 Test that assignment operator preserves embedded files.
 
 BOOST_AUTO_TEST_CASE (AddEmbeddedFileToPlacedSymbolSurvivesSave)
 Adding a new embedded file to a placed schematic symbol must not drop the existing files.
 

Detailed Description

Test suite for embedded files in LIB_SYMBOL objects, including derived symbols.

Definition in file test_symbol_embedded_files.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( AddEmbeddedFileToPlacedSymbolSurvivesSave )

Adding a new embedded file to a placed schematic symbol must not drop the existing files.

The schematic serializes the screen's cached library symbols, while the symbol properties dialog edits the placed instance's library symbol. SCH_SCREEN::Append must reconcile the cache with the instance even when only the embedded files changed (LIB_SYMBOL::Compare ignores them); without it the edits are lost on save.

Definition at line 296 of file test_symbol_embedded_files.cpp.

References EMBEDDED_FILES::AddFile(), SCH_SCREEN::Append(), BOOST_REQUIRE(), SCH_SYMBOL::GetEmbeddedFiles(), SCH_SCREEN::GetLibSymbols(), SCH_SHEET::GetScreen(), EMBEDDED_FILES::HasFile(), SETTINGS_MANAGER::LoadProject(), SCH_IO_KICAD_SEXPR::LoadSchematicFile(), SCH_SYMBOL::Move(), name, SETTINGS_MANAGER::Prj(), SCH_SHEET_PATH::push_back(), SCH_SCREEN::Remove(), SCH_IO_KICAD_SEXPR::SaveSchematicFile(), SCH_SYMBOL::SetRef(), and SCH_SHEET::SetScreen().

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( AssignmentPreservesEmbeddedFiles )

Test that assignment operator preserves embedded files.

Definition at line 262 of file test_symbol_embedded_files.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), and EMBEDDED_FILES::EMBEDDED_FILE::Validate().

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( CopySymbolPreservesEmbeddedFiles )

Test that copying a symbol with embedded files preserves the files.

Definition at line 234 of file test_symbol_embedded_files.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), copy, and EMBEDDED_FILES::EMBEDDED_FILE::Validate().

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( DerivedSymbolEmbeddedFiles )

Test embedded files in parent and derived symbols: 1) Create a symbol and add an embedded file and save.

2) Close and reload the symbol to verify that the embedded file still exists. 3) Create a derived symbol based on the first symbol and save. 4) Close and re-open the derived symbol. Ensure that the embedded file does not exist in the derived symbol. 5) Embed a new file in the derived symbol. 6) Close and reopen the derived symbol. Ensure that the new embedded file exists. 7) Add only the derived symbol to a new schematic sheet. Ensure that both embedded files are present in the schematic.

Definition at line 110 of file test_symbol_embedded_files.cpp.

References EMBEDDED_FILES::AddFile(), SCH_SCREEN::Append(), BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), EMBEDDED_FILES::EmbeddedFileMap(), SCH_SYMBOL::GetLibSymbolRef(), EMBEDDED_FILES::HasFile(), SCH_SHEET_PATH::push_back(), LIB_SYMBOL::SetParent(), and SCH_SHEET::SetScreen().