27#include <boost/test/unit_test.hpp>
32#include <wx/filename.h>
33#include <wx/stdpaths.h>
38#include <nlohmann/json.hpp>
51const std::string TP1_NET =
"unconnected-(TP1-Pad1)";
52const std::string TP2_NET =
"unconnected-(TP2-Pad1)";
58 RULE_AREA_NETCLASS_FIXTURE()
60 wxString reserved = wxFileName::CreateTempFileName(
61 wxStandardPaths::Get().GetTempDir() + wxFileName::GetPathSeparator()
62 + wxS(
"kicad_qa_25223_" ) );
65 wxRemoveFile( reserved );
67 m_tempDir.AssignDir( reserved );
73 source.AppendDir( wxS(
"issue25223" ) );
78 wxFileName from( source.GetPath(), wxS(
"proj" ), ext );
80 BOOST_REQUIRE( wxCopyFile( from.GetFullPath(), ProjFile( ext ).GetFullPath() ) );
84 ~RULE_AREA_NETCLASS_FIXTURE()
89 SettingsManager().UnloadProject( &SettingsManager().
Prj(),
false );
91 m_tempDir.Rmdir( wxPATH_RMDIR_RECURSIVE );
94 wxFileName ProjFile(
const std::string& aExt )
const
96 return wxFileName( m_tempDir.GetPath(), wxS(
"proj" ), aExt );
99 nlohmann::json ReadNetclassAssignments()
const
102 std::ifstream in(
path.GetFullPath().fn_str(), std::ios::binary );
106 nlohmann::json
project = nlohmann::json::parse( in );
111 return project[
"net_settings"][
"netclass_assignments"];
114 wxFileName m_tempDir;
120BOOST_FIXTURE_TEST_SUITE( Issue25223RuleAreaNetclass, RULE_AREA_NETCLASS_FIXTURE )
125 BOOST_REQUIRE( ReadNetclassAssignments().contains( TP1_NET ) );
129 NET_SETTINGS& netSettings = *m_schematic->Project().GetProjectFile().m_NetSettings;
134 SettingsManager().SaveProject();
136 nlohmann::json assignments = ReadNetclassAssignments();
138 BOOST_CHECK( !assignments.contains( TP1_NET ) );
139 BOOST_CHECK( assignments.contains( TP2_NET ) );
143 SettingsManager().SaveProject();
145 assignments = ReadNetclassAssignments();
147 BOOST_CHECK( assignments.is_object() );
148 BOOST_CHECK( assignments.empty() );
A generic fixture for loading schematics and associated settings for qa tests.
NET_SETTINGS stores various net-related settings in a project context.
void ClearNetclassLabelAssignments()
Clears all net name to netclasses assignments Calling user is responsible for resetting the effective...
bool HasNetclassLabelAssignment(const wxString &netName) const
Determines if a given net name has netclasses assigned.
static const std::string ProjectFileExtension
static const std::string KiCadSchematicFileExtension
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
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()
Definition of file extensions used in Kicad.