KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_graphics_load_save.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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25#include <boost/test/data/test_case.hpp>
26
27#include <board.h>
28#include <kiid.h>
29#include <pcb_shape.h>
33
34namespace
35{
36
37struct GRAPHICS_LOAD_TEST_CASE
38{
39 // Which one to look at in the file?
40 KIID m_searchUuid;
41 // Expected values
42 bool m_expectedFilled;
43};
44
45
46struct GRAPHICS_LOAD_BOARD_TEST_CASE: public KI_TEST::BOARD_LOAD_TEST_CASE
47{
48 // List of images to check
49 std::vector<GRAPHICS_LOAD_TEST_CASE> m_generatorCases;
50};
51
52const std::vector<GRAPHICS_LOAD_BOARD_TEST_CASE> GraphicsLoad_testCases{
53 {
54 // Before 20241129, 'fill' would be solid or none
55 // in PCB shapes
56 "graphics_load_save_v20240108",
57 20240108,
58 {
59 // Filled poly
60 {
61 "65596b4f-7b03-48e9-8be7-5824316ea7fd",
62 true,
63 },
64 // Unfilled poly
65 {
66 "cf265305-49c9-43d8-bb2a-ad34997b22d6",
67 false,
68 },
69 // Filled rect
70 {
71 "d0669ae2-442f-427f-af0f-bc3008af779a",
72 true,
73 },
74 // Unfilled rect
75 {
76 "fd1649a3-9a92-4dd3-96b4-88469cb257ba",
77 false,
78 },
79 },
80 },
81};
82
83} // namespace
84
85BOOST_DATA_TEST_CASE( GraphicsLoad, boost::unit_test::data::make( GraphicsLoad_testCases ),
86 testCase )
87{
88 const auto doBoardTest = [&]( const BOARD& aBoard )
89 {
90 for( const GRAPHICS_LOAD_TEST_CASE& testCase : testCase.m_generatorCases )
91 {
93 "Checking for graphic with UUID: " << testCase.m_searchUuid.AsString() );
94
95 const auto& graphic =
97 aBoard, PCB_SHAPE_T, testCase.m_searchUuid ) );
98
99 BOOST_CHECK_EQUAL( graphic.IsFilled(), testCase.m_expectedFilled );
100 }
101 };
102
103 KI_TEST::LoadAndTestBoardFile( testCase.m_BoardFileRelativePath, true, doBoardTest,
104 testCase.m_ExpectedBoardVersion );
105}
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:295
Definition: kiid.h:49
void LoadAndTestBoardFile(const wxString aRelativePath, bool aRoundtrip, std::function< void(BOARD &)> aBoardTestFunction, std::optional< int > aExpectedBoardVersion)
Perform "some test" on a board file loaded from the path, then optionally save and reload and run the...
BOARD_ITEM & RequireBoardItemWithTypeAndId(const BOARD &aBoard, KICAD_T aItemType, const KIID &aID)
Get an item from the given board with a certain type and UUID.
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_DATA_TEST_CASE(GraphicsLoad, boost::unit_test::data::make(GraphicsLoad_testCases), testCase)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88