44#include <wx/filename.h>
45#include <wx/stdpaths.h>
52struct MULTI_TOP_LEVEL_PLOT_FIXTURE
54 MULTI_TOP_LEVEL_PLOT_FIXTURE()
57 + wxS(
"issue25198/SVG-Test.kicad_sch" );
61 wxFileName outDir( wxFileName::CreateTempFileName(
62 wxStandardPaths::Get().GetTempDir() + wxFileName::GetPathSeparator()
63 + wxS(
"issue25198" ) ) );
65 wxRemoveFile( outDir.GetFullPath() );
66 m_outputDir = outDir.GetFullPath();
67 wxFileName::Mkdir( m_outputDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
70 ~MULTI_TOP_LEVEL_PLOT_FIXTURE()
72 if( !m_outputDir.IsEmpty() )
73 wxFileName::Rmdir( m_outputDir, wxPATH_RMDIR_RECURSIVE );
77 void AddTopLevelSheet(
const wxString& aName,
const wxString& aFileName )
79 SCH_SHEET* sheet =
new SCH_SHEET( m_schematic.get() );
80 SCH_SCREEN* screen =
new SCH_SCREEN( m_schematic.get() );
86 m_schematic->AddTopLevelSheet( sheet );
89 std::vector<wxString> PlotAll(
PLOT_FORMAT aFormat )
91 SCH_RENDER_SETTINGS renderSettings;
98 SCH_PLOTTER plotter( m_schematic.get() );
99 plotter.Plot( aFormat, opts, &renderSettings,
nullptr );
101 return plotter.GetOutputFilePaths();
104 std::unique_ptr<SCHEMATIC> m_schematic;
105 wxString m_outputDir;
109int CountPdfPages(
const wxString& aPath )
111 std::string contents;
123BOOST_FIXTURE_TEST_SUITE( Issue25198MultiTopLevelPlot, MULTI_TOP_LEVEL_PLOT_FIXTURE )
132 BOOST_REQUIRE_EQUAL( m_schematic->GetTopLevelSheets().size(), 3u );
135 std::set<wxString> names;
137 for(
const SCH_SHEET* sheet : m_schematic->GetTopLevelSheets() )
138 names.insert( sheet->
GetName() );
154 BOOST_REQUIRE_EQUAL( outputs.size(), 1u );
169 BOOST_REQUIRE_EQUAL( outputs.size(), 3u );
171 std::set<wxString> unique( outputs.begin(), outputs.end() );
172 BOOST_REQUIRE_EQUAL( unique.size(), 3u );
174 std::set<wxString> baseNames;
176 for(
const wxString&
path : outputs )
182 BOOST_CHECK_MESSAGE( contents.find(
"<svg" ) != std::string::npos,
183 path.ToStdString() +
" is not an SVG" );
184 BOOST_CHECK_MESSAGE( contents.find(
"</svg>" ) != std::string::npos,
185 path.ToStdString() +
" is truncated" );
187 baseNames.insert( wxFileName(
path ).GetName() );
203 AddTopLevelSheet( wxS(
"Toplevel4" ), wxS(
"toplevel4.kicad_sch" ) );
204 AddTopLevelSheet( wxS(
"Toplevel5" ), wxS(
"toplevel5.kicad_sch" ) );
206 BOOST_REQUIRE_EQUAL( m_schematic->GetTopLevelSheets().size(), 5u );
210 BOOST_REQUIRE_EQUAL( outputs.size(), 5u );
212 std::set<wxString> unique( outputs.begin(), outputs.end() );
215 std::set<wxString> baseNames;
217 for(
const wxString&
path : outputs )
219 BOOST_CHECK_MESSAGE( wxFileName::FileExists(
path ),
220 path.ToStdString() +
" was not written" );
221 baseNames.insert( wxFileName(
path ).GetName() );
static SCHEMATIC * LoadSchematic(const wxString &aFileName, bool aSetActive, bool aForceDefaultProject, PROJECT *aProject=nullptr, bool aCalculateConnectivity=true, REPORTER *aRootReporter=nullptr)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void SetText(const wxString &aText) override
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
std::string LoadStringData(const wxString &aPath)
Load the contents of a file into a string.
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
int CountOccurrences(const std::string &aHaystack, const std::string &aNeedle)
Count occurrences of a substring in a string (overlapping allowed).
bool ReadPdfWithDecompressedStreams(const wxString &aPdfPath, std::string &aOutBuffer)
Read a PDF file and append best-effort decompressed contents of any Flate streams to the returned buf...
PLOT_FORMAT
The set of supported output plot formats.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< FAB_LAYER_COLOR > dummy
wxString m_outputDirectory
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LoadsEveryTopLevelSheet)
BOOST_CHECK_EQUAL(result, "25.4")