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

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

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 95 of file test_sch_io_database.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), DESCRIPTION, KI_TEST::GetTestDataRootDir(), SCH_IO_DATABASE::LoadSymbol(), SCH_IO_DATABASE::SetLibraryManagerAdapter(), and IO_ERROR::What().

◆ BOOST_AUTO_TEST_CASE() [2/2]

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().