KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_eagle_plugin.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <map>
#include <set>
#include <core/ignore.h>
#include <kiway.h>
#include <pgm_base.h>
#include <sch_io/sch_io.h>
#include <schematic.h>
#include <sch_sheet.h>
#include <sch_screen.h>
#include <sch_symbol.h>
#include <sch_pin.h>
#include <sch_label.h>
#include <sch_sheet_path.h>
#include <settings/settings_manager.h>
#include <wildcards_and_files_ext.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include <libraries/library_manager.h>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (FindPlugin)
 Checks that the SCH_IO manager finds the Eagle plugin.
 
static wxFileName getEagleTestSchematic (const wxString &sch_file)
 Get a schematic file from the test data eagle subdir.
 
static SCH_SHEETloadEagleSchematic (const wxFileName &aEagleFn, const wxString &aProjectStem, std::unique_ptr< SCHEMATIC > &aSchematic)
 Common Eagle-import scaffolding: stage a fresh project under tempDir, configure the library manager, run the Eagle SCH_IO plugin, and return the loaded virtual root.
 
 BOOST_AUTO_TEST_CASE (ImportHierarchy)
 Verify that a multi-page Eagle import produces the correct top-level sheet hierarchy.
 
 BOOST_AUTO_TEST_CASE (LabelsRemainGlobalForFlatNamespace)
 Verify that Eagle-named nets remain global after import, preserving the flat namespace Eagle uses for net names.
 
 BOOST_AUTO_TEST_CASE (PinNameTagStripped)
 Verify that the Eagle "@<tag>" linking hint on a pin name is stripped from the displayed pin name while still resolving the device <connect> mapping correctly.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( FindPlugin )

Checks that the SCH_IO manager finds the Eagle plugin.

Definition at line 51 of file test_eagle_plugin.cpp.

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( ImportHierarchy )

Verify that a multi-page Eagle import produces the correct top-level sheet hierarchy.

Regression test for issue #23645: Eagle import was inserting a spurious empty default sheet at index 0 in m_topLevelSheets, causing GetTopLevelSheet(0) to return an empty sheet that then received the project filename. On save, only that empty sheet was written; on re-open all components were missing.

Definition at line 126 of file test_eagle_plugin.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), getEagleTestSchematic(), SCH_SYMBOL::GetInstances(), SCH_SCREEN::Items(), loadEagleSchematic(), EDA_ITEM::m_Uuid, niluuid, EE_RTREE::OfType(), path, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( LabelsRemainGlobalForFlatNamespace )

Verify that Eagle-named nets remain global after import, preserving the flat namespace Eagle uses for net names.

Regression test for issue #24311 (and #24296): the Eagle importer was creating local SCH_LABEL elements for nets that appeared on only one sheet, which caused KiCad to prepend a sheet-path prefix to the resulting net name (e.g. "+24V_SWD" became "/+24V_SWD"). The Eagle PCB importer keeps signal names verbatim, so on Update PCB from Schematic the netlist updater reported "Reconnect via from +24V_SWD to /+24V_SWD" and the copper pour for the affected net was orphaned on the old name. The fix is to emit SCH_GLOBALLABEL for every explicit Eagle net label and every fallback label, so KiCad and the matching Eagle BRD agree on net names.

Definition at line 214 of file test_eagle_plugin.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), getEagleTestSchematic(), SCH_SCREEN::Items(), loadEagleSchematic(), EE_RTREE::OfType(), SCH_GLOBAL_LABEL_T, and SCH_LABEL_T.

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( PinNameTagStripped )

Verify that the Eagle "@<tag>" linking hint on a pin name is stripped from the displayed pin name while still resolving the device <connect> mapping correctly.

Regression test for issue #24483: Eagle disambiguates duplicate pin names within a symbol with a trailing "@<tag>" (e.g. "IN@1", "IN@2", "NC@3"). This tag is metadata used only to link pins to pads via <connect>; it should not appear as visible pin text. The importer was setting the raw Eagle name as the KiCad pin name, leaking "@1"/"@2"/"@3" into the schematic.

Definition at line 287 of file test_eagle_plugin.cpp.

References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), getEagleTestSchematic(), SCH_SYMBOL::GetLibId(), LIB_ID::GetLibItemName(), SCH_SCREEN::Items(), loadEagleSchematic(), EE_RTREE::OfType(), pin, SCH_SYMBOL_T, and UTF8::wx_str().

◆ getEagleTestSchematic()

static wxFileName getEagleTestSchematic ( const wxString & sch_file)
static

Get a schematic file from the test data eagle subdir.

Definition at line 61 of file test_eagle_plugin.cpp.

References KI_TEST::GetEeschemaTestDataDir().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ loadEagleSchematic()

static SCH_SHEET * loadEagleSchematic ( const wxFileName & aEagleFn,
const wxString & aProjectStem,
std::unique_ptr< SCHEMATIC > & aSchematic )
static

Common Eagle-import scaffolding: stage a fresh project under tempDir, configure the library manager, run the Eagle SCH_IO plugin, and return the loaded virtual root.

Eagle import uses Pgm().GetLibraryManager() for the symbol-library adapter, so the project has to come through the global settings manager rather than a bare PROJECT instance. Writing to a temp dir keeps the generated .kicad_sym out of the source tree.

Definition at line 80 of file test_eagle_plugin.cpp.

References BOOST_REQUIRE(), PGM_BASE::GetLibraryManager(), PGM_BASE::GetSettingsManager(), SETTINGS_MANAGER::LoadProject(), LIBRARY_MANAGER::LoadProjectTables(), Pgm(), SETTINGS_MANAGER::Prj(), and project.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().