25#include <wx/textfile.h>
43 void SeedLoadError(
const wxString& aNickname )
50 void SeedLoadError(
const wxString& aNickname,
const wxString& aMessage )
53 m_libraries[aNickname].status.error = LIBRARY_ERROR( aMessage );
57 void SeedLoaded(
const wxString& aNickname )
65class SCOPED_SYM_LIB_TABLE
68 SCOPED_SYM_LIB_TABLE(
const std::vector<wxString>& aNicknamesInTableOrder )
71 m_dir = std::filesystem::temp_directory_path( ec )
72 / std::filesystem::path( wxString::Format( wxS(
"kicad_qa_symlibtbl_%p" ), (
void*)
this )
74 std::filesystem::create_directories( m_dir, ec );
76 wxTextFile file( wxString( ( m_dir /
"sym-lib-table" ).
string() ) );
78 file.AddLine( wxS(
"(sym_lib_table" ) );
79 file.AddLine( wxS(
" (version 7)" ) );
81 for(
const wxString& nickname : aNicknamesInTableOrder )
83 file.AddLine( wxString::Format(
84 wxS(
" (lib (name \"%s\")(type \"KiCad\")(uri \"${KIPRJMOD}/%s.kicad_sym\")(options \"\")(descr \"\"))" ),
85 nickname, nickname ) );
88 file.AddLine( wxS(
")" ) );
93 ~SCOPED_SYM_LIB_TABLE()
96 std::filesystem::remove_all( m_dir, ec );
99 wxString Path()
const {
return wxString( m_dir.string() ); }
102 std::filesystem::path m_dir;
122 TEST_SYMBOL_LIBRARY_ADAPTER adapter( manager );
124 adapter.SeedLoadError( wxS(
"BadLib" ) );
143 const std::vector<wxString> tableOrder = { wxS(
"Zebra" ), wxS(
"amplifier" ), wxS(
"Device" ),
144 wxS(
"Board_2" ), wxS(
"Board_10" ) };
146 SCOPED_SYM_LIB_TABLE tableFile( tableOrder );
151 TEST_SYMBOL_LIBRARY_ADAPTER adapter( manager );
153 for(
const wxString& nickname : tableOrder )
154 adapter.SeedLoaded( nickname );
156 const std::vector<wxString> names = adapter.GetLibraryNames();
158 const std::vector<wxString>
expected = { wxS(
"amplifier" ), wxS(
"Board_2" ), wxS(
"Board_10" ),
159 wxS(
"Device" ), wxS(
"Zebra" ) };
161 BOOST_CHECK_EQUAL_COLLECTIONS( names.begin(), names.end(),
expected.begin(),
expected.end() );
178 const std::vector<wxString> tableOrder = { wxS(
"Device" ), wxS(
"Connector" ), wxS(
"Amplifier" ),
179 wxS(
"Regulator" ), wxS(
"BadLib" ) };
181 SCOPED_SYM_LIB_TABLE tableFile( tableOrder );
186 TEST_SYMBOL_LIBRARY_ADAPTER adapter( manager );
190 adapter.SeedLoaded( wxS(
"Device" ) );
191 adapter.SeedLoaded( wxS(
"Connector" ) );
192 adapter.SeedLoadError( wxS(
"BadLib" ), wxS(
"File is corrupt" ) );
194 const wxString errors = adapter.GetLibraryLoadErrors();
197 BOOST_CHECK( !errors.Contains( wxS(
"not found in library table" ) ) );
198 BOOST_CHECK( !errors.Contains( wxS(
"Amplifier" ) ) );
199 BOOST_CHECK( !errors.Contains( wxS(
"Regulator" ) ) );
202 BOOST_CHECK( errors.Contains( wxS(
"BadLib" ) ) );
203 BOOST_CHECK( errors.Contains( wxS(
"File is corrupt" ) ) );
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)
static std::string ToStdString(const wxString &aStr)
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")