KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_footprint_library_adapter.cpp File Reference
#include <atomic>
#include <filesystem>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <memory>
#include <set>
#include <thread>
#include <vector>
#include <qa_utils/file_utils.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <pcbnew_utils/board_test_utils.h>
#include <board.h>
#include <footprint.h>
#include <footprint_library_adapter.h>
#include <libraries/library_manager.h>
#include <libraries/library_table.h>
#include <netinfo.h>
#include <pad.h>
#include <pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (IsFootprintLibWritableHandlesFailedLoad)
 Regression test for a null-plugin dereference crash.
 
 BOOST_AUTO_TEST_CASE (SaveFootprintReadOnlyFilePropagatesError)
 Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23850.
 
 BOOST_AUTO_TEST_CASE (SavedFootprintCacheDoesNotRetainBoardNets)
 A footprint cached after a library save must not retain net pointers owned by its source board.
 
 BOOST_AUTO_TEST_CASE (ConcurrentPluginAccessIsSerialized)
 
 BOOST_AUTO_TEST_CASE (RefreshChangedLibrariesPicksUpExternalAddition)
 
 BOOST_AUTO_TEST_CASE (RefreshChangedLibrariesSkipsUnchangedLibraries)
 
 BOOST_AUTO_TEST_CASE (EditorRoundTripKeepsFileUuids)
 The footprint editor enumerates a library into the tree, then loads from it with aKeepUUID set.
 
 BOOST_AUTO_TEST_CASE (RemovedLibraryStopsServingPreloadedFootprints)
 A preloaded footprint cache entry must not keep serving stale content after the library unloads.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/8]

BOOST_AUTO_TEST_CASE ( ConcurrentPluginAccessIsSerialized )

◆ BOOST_AUTO_TEST_CASE() [2/8]

BOOST_AUTO_TEST_CASE ( EditorRoundTripKeepsFileUuids )

The footprint editor enumerates a library into the tree, then loads from it with aKeepUUID set.

Serving that load from a cache built with Duplicate() rewrote every UUID in the .kicad_mod on the next save, churning the whole file in git.

Definition at line 453 of file test_footprint_library_adapter.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::SCOPED_TEMP_DIR::CreateChildDir(), LIBRARY_MANAGER::LoadProjectTables(), KI_TEST::SCOPED_TEMP_DIR::Path(), KI_TEST::SCOPED_TEMP_DIR::PathStr(), FOOTPRINT_LIBRARY_ADAPTER::SAVE_OK, source, table, and ToStdString().

◆ BOOST_AUTO_TEST_CASE() [3/8]

BOOST_AUTO_TEST_CASE ( IsFootprintLibWritableHandlesFailedLoad )

Regression test for a null-plugin dereference crash.

A footprint library that fails to load leaves a LOAD_ERROR sentinel with a null plugin in the adapter's map. IsFootprintLibWritable() is called for every table row by the footprint editor and chooser, so it must report such a library as not writable instead of dereferencing the null plugin.

Definition at line 114 of file test_footprint_library_adapter.cpp.

References BOOST_AUTO_TEST_CASE(), and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [4/8]

◆ BOOST_AUTO_TEST_CASE() [5/8]

◆ BOOST_AUTO_TEST_CASE() [6/8]

BOOST_AUTO_TEST_CASE ( RemovedLibraryStopsServingPreloadedFootprints )

◆ BOOST_AUTO_TEST_CASE() [7/8]

BOOST_AUTO_TEST_CASE ( SavedFootprintCacheDoesNotRetainBoardNets )

A footprint cached after a library save must not retain net pointers owned by its source board.

The footprint chooser later clones this cache entry and adds it to a preview board; if the source board has been destroyed, connectivity dereferences a dangling NETINFO_ITEM.

Definition at line 185 of file test_footprint_library_adapter.cpp.

References FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), CIRCLE, KI_TEST::SCOPED_TEMP_DIR::CreateChildDir(), F_Cu, FOOTPRINT, NETINFO_LIST::OrphanedItem(), PAD, pad, pcbIUScale, FOOTPRINT_LIBRARY_ADAPTER::SAVE_OK, and FOOTPRINT::SetFPID().

◆ BOOST_AUTO_TEST_CASE() [8/8]

BOOST_AUTO_TEST_CASE ( SaveFootprintReadOnlyFilePropagatesError )

Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23850.

A read-only target .kicad_mod inside a writable directory made the adapter swallow the plugin's IO_ERROR and return SAVE_SKIPPED, so the editor reported success and lost the user's edits. SaveFootprint() must now let the IO_ERROR propagate.

Definition at line 135 of file test_footprint_library_adapter.cpp.

References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), KI_TEST::SCOPED_TEMP_DIR::CreateChildDir(), FOOTPRINT, FOOTPRINT_LIBRARY_ADAPTER::SAVE_OK, and FOOTPRINT::SetFPID().