44#include <boost/test/unit_test.hpp>
55#include <wx/filename.h>
63static int countEntities(
const std::filesystem::path& aFile,
const std::string& aToken )
65 std::ifstream in( aFile );
66 BOOST_REQUIRE_MESSAGE( in.good(),
"Cannot open exported STEP file for inspection" );
68 std::stringstream buf;
70 const std::string contents = buf.str();
75 while( ( pos = contents.find( aToken, pos ) ) != std::string::npos )
100 const std::filesystem::path sourceModel =
102 /
"step_model_colors" /
"TO-252-2.step";
104 BOOST_REQUIRE_MESSAGE( std::filesystem::exists( sourceModel ),
105 "Missing test model " << sourceModel.string() );
107 const std::filesystem::path outputFile =
108 std::filesystem::temp_directory_path() /
"kicad_step_model_color_test.step";
110 if( std::filesystem::exists( outputFile ) )
111 std::filesystem::remove( outputFile );
117 model.SetCopperColor( 0.75, 0.61, 0.23 );
118 model.SetPadColor( 0.9, 0.9, 0.9 );
130 const wxString modelPath = wxString::FromUTF8( sourceModel.string().c_str() );
132 const bool added =
model.AddComponent( wxT(
"TO-252-2" ), modelPath, {}, wxT(
"U1" ),
false,
137 BOOST_REQUIRE_MESSAGE( added,
"AddComponent failed for TO-252-2.step" );
139 const wxString outputPath = wxString::FromUTF8( outputFile.string().c_str() );
141 BOOST_REQUIRE_MESSAGE(
model.WriteSTEP( outputPath,
false,
false ),
142 "WriteSTEP returned failure" );
146 const int styled = countEntities( outputFile,
"STYLED_ITEM" );
147 const int colors = countEntities( outputFile,
"COLOUR_RGB" );
150 <<
" COLOUR_RGB entities" );
157 "Exported STEP has no STYLED_ITEM entities; component colors were dropped" );
160 "Expected > 2 COLOUR_RGB entities (component + board); got " << colors
161 <<
". Component model colors were not transferred." );
164 if( styled > 0 && colors > 2 && std::filesystem::exists( outputFile ) )
165 std::filesystem::remove( outputFile );
General utilities for PCB file IO for QA programs.
A singleton reporter that reports to nowhere.
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
VECTOR3< double > VECTOR3D