|
KiCad PCB EDA Suite
|
#include <algorithm>#include <memory>#include <set>#include <vector>#include <qa_utils/wx_utils/unit_test_utils.h>#include <database/database_lib_settings.h>#include <eda_pattern_match.h>#include <ki_exception.h>#include <lib_symbol.h>#include <libraries/library_manager.h>#include <libraries/symbol_library_adapter.h>#include <sch_io/database/sch_io_database.h>Go to the source code of this file.
Functions | |
| BOOST_AUTO_TEST_CASE (UnchangedDataReusesCache) | |
| SCH_IO_DATABASE::cacheLib() must not rebuild its materialized LIB_SYMBOL cache when a re-query returns the same rows. | |
| BOOST_AUTO_TEST_CASE (FieldMappedDescriptionMatchesShownDescription) | |
| Regression test for issue #23977. | |
| BOOST_AUTO_TEST_CASE (CreateConnectionExpandsCwdAndPrefersConnectionString) | |
| CreateConnection() picks the connection string over the DSN when one is set, and expands ${CWD} to the folder holding the settings file. | |
| BOOST_AUTO_TEST_CASE (PreviewSymbolsMatchCachedNames) | |
| The settings editor previews a table by running sampled rows through BuildPreviewSymbols, so its names must match the ones the library itself lists for that table. | |
| BOOST_AUTO_TEST_CASE | ( | CreateConnectionExpandsCwdAndPrefersConnectionString | ) |
CreateConnection() picks the connection string over the DSN when one is set, and expands ${CWD} to the folder holding the settings file.
Definition at line 157 of file test_sch_io_database.cpp.
References BOOST_REQUIRE(), DATABASE_SOURCE::connection_string, SCH_IO_DATABASE::CreateConnection(), DATABASE_SOURCE::dsn, KI_TEST::GetTestDataRootDir(), JSON_SETTINGS::LoadFromFile(), DATABASE_LIB_SETTINGS::m_Source, and JSON_SETTINGS::SetReadOnly().
| BOOST_AUTO_TEST_CASE | ( | FieldMappedDescriptionMatchesShownDescription | ) |
Regression test for issue #23977.
The symbol chooser tree column and search read the cached shown description (LIB_SYMBOL::GetShownDescription), while the details panel reads the live Description field. When a database library maps the Description through a regular field mapping, the plugin set the field with SCH_FIELD::SetText, which does not refresh the cache, so the two chooser panels disagreed. The plugin must refresh the chooser caches after populating the symbol so both read the database value.
Definition at line 102 of file test_sch_io_database.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), DESCRIPTION, FOR_GUI, KI_TEST::GetTestDataRootDir(), SCH_IO_DATABASE::LoadSymbol(), SCH_IO_DATABASE::SetLibraryManagerAdapter(), and IO_ERROR::What().
| BOOST_AUTO_TEST_CASE | ( | PreviewSymbolsMatchCachedNames | ) |
The settings editor previews a table by running sampled rows through BuildPreviewSymbols, so its names must match the ones the library itself lists for that table.
Definition at line 187 of file test_sch_io_database.cpp.
References BOOST_REQUIRE(), SCH_IO_DATABASE::BuildPreviewSymbols(), SCH_IO_DATABASE::CreateConnection(), SCH_IO_DATABASE::EnumerateSymbolLib(), expected, DATABASE_LIB_SETTINGS::m_GloballyUniqueKeys, DATABASE_LIB_SETTINGS::m_Tables, SCH_IO_DATABASE::SetLibraryManagerAdapter(), SCH_IO_DATABASE::Settings(), and table.
| BOOST_AUTO_TEST_CASE | ( | UnchangedDataReusesCache | ) |
SCH_IO_DATABASE::cacheLib() must not rebuild its materialized LIB_SYMBOL cache when a re-query returns the same rows.
Before the signature-comparison fix, the cache was rebuilt on every max_age expiry and on any change to the global library modify hash; the async library loader bumps that hash whenever an unrelated library finishes loading, freezing the symbol chooser for seconds at a time on large database libraries.
Forcing max_age to zero makes every EnumerateSymbolLib call re-query the database, so the signature-comparison path is exercised. With the fix, unchanged data leaves the existing LIB_SYMBOL objects in place and the returned pointers are stable; with the fix reverted the cache is rebuilt and the pointers change.
See https://gitlab.com/kicad/code/kicad/-/issues/23509
Definition at line 53 of file test_sch_io_database.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_REQUIRE(), SCH_IO_DATABASE::EnumerateSymbolLib(), DATABASE_LIB_SETTINGS::m_Cache, DATABASE_CACHE_SETTINGS::max_age, SCH_IO_DATABASE::SetLibraryManagerAdapter(), and SCH_IO_DATABASE::Settings().