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 <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 (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.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( ConcurrentPluginAccessIsSerialized )

◆ BOOST_AUTO_TEST_CASE() [2/6]

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 405 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, table, and ToStdString().

◆ BOOST_AUTO_TEST_CASE() [3/6]

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 112 of file test_footprint_library_adapter.cpp.

References BOOST_AUTO_TEST_CASE(), and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [4/6]

◆ BOOST_AUTO_TEST_CASE() [5/6]

◆ BOOST_AUTO_TEST_CASE() [6/6]

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 133 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().