KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_headless_board_context.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22
24#include <board.h>
25#include <board_loader.h>
26#include <pcb_io/pcb_io_mgr.h>
29#include <tool/tool_manager.h>
30#include <wx/filename.h>
31
32
34{
35 PROJECT* loadProject( const wxString& aBoardName )
36 {
37 wxFileName projectFile( wxString::FromUTF8( KI_TEST::GetPcbnewTestDataDir() )
38 + aBoardName + ".kicad_pro" );
39
40 m_settingsManager.LoadProject( projectFile.GetFullPath() );
41
42 PROJECT* project = m_settingsManager.GetProject( projectFile.GetFullPath() );
43
44 BOOST_REQUIRE_MESSAGE( project, "Could not load project" );
45 return project;
46 }
47
48 wxString boardPath( const wxString& aBoardName ) const
49 {
50 return wxString::FromUTF8( KI_TEST::GetPcbnewTestDataDir() ) + aBoardName + ".kicad_pcb";
51 }
52
54};
55
56
58{
59 PROJECT* project = loadProject( "reference_images_load_save" );
60
61 std::unique_ptr<BOARD> board =
62 BOARD_LOADER::Load( boardPath( "reference_images_load_save" ),
64 project );
65
66 BOOST_REQUIRE( board );
67
68 HEADLESS_BOARD_CONTEXT context( std::move( board ), project, nullptr );
69
70 BOOST_CHECK( context.GetBoard() );
72 BOOST_CHECK_EQUAL( context.Prj().GetProjectFullName(), project->GetProjectFullName() );
73 BOOST_CHECK( context.GetToolManager() );
74 BOOST_CHECK_EQUAL( context.GetToolManager()->GetModel(), context.GetBoard() );
76 BOOST_CHECK( context.CanAcceptApiCommands() );
77}
General utilities for PCB file IO for QA programs.
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
const wxString & GetFileName() const
Definition board.h:360
PROJECT * GetProject() const
Definition board.h:587
PROJECT & Prj() const override
bool CanAcceptApiCommands() const override
TOOL_MANAGER * GetToolManager() const override
BOARD * GetBoard() const override
wxString GetCurrentFileName() const override
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition pcb_io_mgr.h:58
Container for project specific data.
Definition project.h:66
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition project.cpp:171
EDA_ITEM * GetModel() const
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
PROJECT * loadProject(const wxString &aBoardName)
wxString boardPath(const wxString &aBoardName) const
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE(HeadlessBoardContextBasics, HEADLESS_BOARD_CONTEXT_TEST_FIXTURE)
BOOST_CHECK_EQUAL(result, "25.4")