25#include <wx/textfile.h>
43 void SeedLoadError(
const wxString& aNickname )
49 void SeedLoaded(
const wxString& aNickname )
57class SCOPED_SYM_LIB_TABLE
60 SCOPED_SYM_LIB_TABLE(
const std::vector<wxString>& aNicknamesInTableOrder )
63 m_dir = std::filesystem::temp_directory_path( ec )
64 / std::filesystem::path( wxString::Format( wxS(
"kicad_qa_symlibtbl_%p" ), (
void*)
this )
66 std::filesystem::create_directories( m_dir, ec );
68 wxTextFile file( wxString( ( m_dir /
"sym-lib-table" ).
string() ) );
70 file.AddLine( wxS(
"(sym_lib_table" ) );
71 file.AddLine( wxS(
" (version 7)" ) );
73 for(
const wxString& nickname : aNicknamesInTableOrder )
75 file.AddLine( wxString::Format(
76 wxS(
" (lib (name \"%s\")(type \"KiCad\")(uri \"${KIPRJMOD}/%s.kicad_sym\")(options \"\")(descr \"\"))" ),
77 nickname, nickname ) );
80 file.AddLine( wxS(
")" ) );
85 ~SCOPED_SYM_LIB_TABLE()
88 std::filesystem::remove_all( m_dir, ec );
91 wxString Path()
const {
return wxString( m_dir.string() ); }
94 std::filesystem::path m_dir;
114 TEST_SYMBOL_LIBRARY_ADAPTER adapter( manager );
116 adapter.SeedLoadError( wxS(
"BadLib" ) );
135 const std::vector<wxString> tableOrder = { wxS(
"Zebra" ), wxS(
"amplifier" ), wxS(
"Device" ),
136 wxS(
"Board_2" ), wxS(
"Board_10" ) };
138 SCOPED_SYM_LIB_TABLE tableFile( tableOrder );
143 TEST_SYMBOL_LIBRARY_ADAPTER adapter( manager );
145 for(
const wxString& nickname : tableOrder )
146 adapter.SeedLoaded( nickname );
148 const std::vector<wxString> names = adapter.GetLibraryNames();
150 const std::vector<wxString>
expected = { wxS(
"amplifier" ), wxS(
"Board_2" ), wxS(
"Board_10" ),
151 wxS(
"Device" ), wxS(
"Zebra" ) };
153 BOOST_CHECK_EQUAL_COLLECTIONS( names.begin(), names.end(),
expected.begin(),
expected.end() );
void LoadProjectTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the project library tables in the given list, or all tables if no list is given
An interface to the global shared library manager that is schematic-specific and linked to one projec...
SYMBOL_LIBRARY_ADAPTER(LIBRARY_MANAGER &aManager)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_AUTO_TEST_CASE(IsSymbolLibWritableHandlesFailedLoad)
Regression test for a null-plugin dereference crash.
BOOST_CHECK_EQUAL(result, "25.4")