KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_footprint_library_adapter.cpp File Reference
#include <filesystem>
#include <memory>
#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.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

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

References BOOST_AUTO_TEST_CASE(), and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [2/2]

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

References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), FOOTPRINT, KI_TEST::TEMPORARY_DIRECTORY::GetPath(), FOOTPRINT_LIBRARY_ADAPTER::SAVE_OK, and FOOTPRINT::SetFPID().