21#include <fmt/format.h>
37constexpr const char* kDeviceLibNickname =
"Device";
50 std::make_unique<SYMBOL_LIBRARY_ADAPTER>( aManager ) );
52 std::optional<LIBRARY_MANAGER_ADAPTER*> adapterOpt =
61 fn.AppendDir(
"libraries" );
62 fn.AppendDir(
"test_project" );
71 if( !wxGetEnv( wxT(
"KICAD9_SYMBOL_DIR" ),
nullptr ) )
74 path += wxT(
"/libraries" );
75 wxSetEnv( wxT(
"KICAD9_SYMBOL_DIR" ),
path );
84 if( !wxGetEnv( wxT(
"KICAD_CONFIG_HOME_IS_QA" ),
nullptr ) )
94 fn.AppendDir(
"libraries" );
95 fn.AppendDir(
"test_project" );
110 BOOST_REQUIRE( rows[0]->URI() ==
"${KIPRJMOD}/Device.kicad_sym" );
115 std::vector<LIB_SYMBOL*> symbols = adapter.
GetSymbols(
"Device" );
138 auto tstart = std::chrono::high_resolution_clock::now();
141 constexpr static int interval = 250;
142 constexpr static int timeLimit = 20000;
147 std::this_thread::sleep_for( std::chrono::milliseconds( interval ) );
149 if( std::optional<float> loadStatus = adapter.
AsyncLoadProgress(); loadStatus.has_value() )
151 BOOST_TEST_MESSAGE( fmt::format(
"Loading libraries: ({:.1f}%)", *loadStatus * 100 ) );
153 if( loadStatus >= 1 )
165 if( elapsed > timeLimit )
167 BOOST_TEST_FAIL(
"Exceeded timeout" );
172 auto duration = std::chrono::high_resolution_clock::now() - tstart;
175 fmt::format(
"took {}ms",
176 std::chrono::duration_cast<std::chrono::milliseconds>( duration ).count() ) );
182 BOOST_REQUIRE_GE( rows.size(), 2 );
186 wxString msg = nickname;
189 switch( status.load_status )
193 msg <<
": loaded OK";
199 msg <<
": error: " << status.error->message;
216 if( !wxGetEnv( wxT(
"KICAD_CONFIG_HOME_IS_QA" ),
nullptr ) )
234 adapter->
LoadOne( kDeviceLibNickname );
246 BOOST_REQUIRE_MESSAGE( !adapter->
IsLibraryLoaded( kDeviceLibNickname ),
247 "Project library cache must be cleared by LoadProjectTables "
248 "to prevent dangling LIB_DATA::row pointers" );
252 adapter->
LoadOne( kDeviceLibNickname );
269 if( !wxGetEnv( wxT(
"KICAD_CONFIG_HOME_IS_QA" ),
nullptr ) )
275 EnsureGlobalSymbolDir();
293 adapter->
LoadOne( kDeviceLibNickname );
304 adapter->
LoadOne( kDeviceLibNickname );
317 BOOST_REQUIRE_MESSAGE( !adapter->
IsLibraryLoaded( kDeviceLibNickname ),
318 "Project library reload must preserve project-over-global "
319 "shadowing for cached nicknames" );
322 adapter->
LoadOne( kDeviceLibNickname );
336 if( !wxGetEnv( wxT(
"KICAD_CONFIG_HOME_IS_QA" ),
nullptr ) )
342 EnsureGlobalSymbolDir();
353 adapter->
LoadOne( kDeviceLibNickname );
362 adapter->
LoadOne( kDeviceLibNickname );
378 "Removing a project library must expose the same-named global "
379 "library rather than leave a permanent sentinel mask" );
388 if( !wxGetEnv( wxT(
"KICAD_CONFIG_HOME_IS_QA" ),
nullptr ) )
A generic fixture for loading schematics and associated settings for qa tests.
std::optional< float > AsyncLoadProgress() const
Returns async load progress between 0.0 and 1.0, or nullopt if load is not in progress.
bool IsLibraryLoaded(const wxString &aNickname)
std::optional< wxString > GetLibraryDescription(const wxString &aNickname) const
void AsyncLoad()
Loads all available libraries for this adapter type in the background.
std::vector< std::pair< wxString, LIB_STATUS > > GetLibraryStatuses() const
Returns a list of all library nicknames and their status (even if they failed to load)
std::optional< LIBRARY_MANAGER_ADAPTER * > Adapter(LIBRARY_TABLE_TYPE aType) const
void RegisterAdapter(LIBRARY_TABLE_TYPE aType, std::unique_ptr< LIBRARY_MANAGER_ADAPTER > &&aAdapter)
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
std::vector< LIBRARY_TABLE_ROW * > Rows(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH, bool aIncludeInvalid=false) const
Returns a flattened list of libraries of the given type.
void LoadGlobalTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the global library tables in the given list, or all tables if no list is given
void ProjectChanged()
Notify all adapters that the project has changed.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Container for project specific data.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
std::vector< LIB_SYMBOL * > GetSymbols(const wxString &aNickname, SYMBOL_TYPE aType=SYMBOL_TYPE::ALL_SYMBOLS)
wxFileName GetTestProjectSchPath() const
void EnsureGlobalSymbolDir()
Ensure KICAD9_SYMBOL_DIR points at the QA data libraries so the global sym-lib-table's ${KICAD9_SYMBO...
SYMBOL_LIBRARY_ADAPTER * RegisterSymbolAdapter(LIBRARY_MANAGER &aManager)
Register a fresh SYMBOL_LIBRARY_ADAPTER on the manager and return it.
std::string GetTestDataRootDir()
PGM_BASE & Pgm()
The global program "get" accessor.
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_AUTO_TEST_CASE(ProjectLibraryTable)