KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_board_loader.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
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
qa_utils/wx_utils/unit_test_utils.h
>
21
22
#include <
board.h
>
23
#include <
board_loader.h
>
24
#include <
board_design_settings.h
>
25
#include <
pcb_reference_image.h
>
26
#include <
pcb_io/pcb_io_mgr.h
>
27
#include <
pcbnew_utils/board_file_utils.h
>
28
#include <
project.h
>
29
#include <
settings/settings_manager.h
>
30
#include <wx/filename.h>
31
32
33
struct
BOARD_LOADER_TEST_FIXTURE
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
53
SETTINGS_MANAGER
m_settingsManager
;
54
};
55
56
57
BOOST_FIXTURE_TEST_CASE
( BoardLoaderWithInit,
BOARD_LOADER_TEST_FIXTURE
)
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"
),
63
PCB_IO_MGR::KICAD_SEXP
,
64
project
);
65
66
BOOST_REQUIRE
( board );
67
BOOST_CHECK_EQUAL
( board->GetProject(),
project
);
68
BOOST_CHECK( board->GetDesignSettings().m_DRCEngine );
69
BOOST_CHECK( board->GetConnectivity() );
70
BOOST_CHECK_GT( board->Drawings().size(), 0 );
71
}
72
73
74
BOOST_FIXTURE_TEST_CASE
( BoardLoaderWithoutInit,
BOARD_LOADER_TEST_FIXTURE
)
75
{
76
PROJECT
*
project
= loadProject(
"reference_images_load_save"
);
77
78
BOARD_LOADER::OPTIONS
options;
79
options.
initialize_after_load
=
false
;
80
81
std::unique_ptr<BOARD> board =
82
BOARD_LOADER::Load
( boardPath(
"reference_images_load_save"
),
83
PCB_IO_MGR::KICAD_SEXP
,
84
project
,
85
options );
86
87
BOOST_REQUIRE
( board );
88
BOOST_CHECK_NE( board->GetProject(),
project
);
89
BOOST_CHECK( board->GetDesignSettings().m_DRCEngine ==
nullptr
);
90
}
BITMAPS::project
@ project
Definition
bitmaps_list.h:482
board.h
board_design_settings.h
board_file_utils.h
General utilities for PCB file IO for QA programs.
board_loader.h
BOARD_LOADER::Load
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
Definition
board_loader.cpp:39
PCB_IO_MGR::KICAD_SEXP
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition
pcb_io_mgr.h:58
PROJECT
Container for project specific data.
Definition
project.h:66
SETTINGS_MANAGER
Definition
settings_manager.h:49
KI_TEST::GetPcbnewTestDataDir
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
Definition
board_file_utils.cpp:42
pcb_io_mgr.h
pcb_reference_image.h
project.h
settings_manager.h
BOARD_LOADER::OPTIONS
Definition
board_loader.h:43
BOARD_LOADER::OPTIONS::initialize_after_load
bool initialize_after_load
Definition
board_loader.h:54
BOARD_LOADER_TEST_FIXTURE
Definition
test_board_loader.cpp:34
BOARD_LOADER_TEST_FIXTURE::loadProject
PROJECT * loadProject(const wxString &aBoardName)
Definition
test_board_loader.cpp:35
BOARD_LOADER_TEST_FIXTURE::boardPath
wxString boardPath(const wxString &aBoardName) const
Definition
test_board_loader.cpp:48
BOARD_LOADER_TEST_FIXTURE::m_settingsManager
SETTINGS_MANAGER m_settingsManager
Definition
test_board_loader.cpp:53
BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(BoardLoaderWithInit, BOARD_LOADER_TEST_FIXTURE)
Definition
test_board_loader.cpp:57
BOOST_REQUIRE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
pcbnew
test_board_loader.cpp
Generated on Fri Apr 3 2026 00:07:25 for KiCad PCB EDA Suite by
1.13.2