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, see <https://www.gnu.org/licenses/>.
18 */
19
21#include <boost/test/data/test_case.hpp>
22
23#include <board.h>
24#include <kiid.h>
25#include <pcb_shape.h>
29
30namespace
31{
32
33struct GRAPHICS_LOAD_TEST_CASE
34{
35 // Which one to look at in the file?
36 KIID m_searchUuid;
37 // Expected values
38 bool m_expectedFilled;
39};
40
41
42struct GRAPHICS_LOAD_BOARD_TEST_CASE: public KI_TEST::BOARD_LOAD_TEST_CASE
43{
44 // List of images to check
45 std::vector<GRAPHICS_LOAD_TEST_CASE> m_generatorCases;
46};
47
48const std::vector<GRAPHICS_LOAD_BOARD_TEST_CASE> GraphicsLoad_testCases{
49 {
50 // Before 20241129, 'fill' would be solid or none
51 // in PCB shapes
52 "graphics_load_save_v20240108",
53 20240108,
54 {
55 // Filled poly
56 {
57 "65596b4f-7b03-48e9-8be7-5824316ea7fd",
58 true,
59 },
60 // Unfilled poly
61 {
62 "cf265305-49c9-43d8-bb2a-ad34997b22d6",
63 false,
64 },
65 // Filled rect
66 {
67 "d0669ae2-442f-427f-af0f-bc3008af779a",
68 true,
69 },
70 // Unfilled rect
71 {
72 "fd1649a3-9a92-4dd3-96b4-88469cb257ba",
73 false,
74 },
75 },
76 },
77};
78
79} // namespace
80
81BOOST_DATA_TEST_CASE( GraphicsLoad, boost::unit_test::data::make( GraphicsLoad_testCases ),
82 testCase )
83{
84 const auto doBoardTest =
85 [&]( const BOARD& aBoard )
86 {
87 for( const GRAPHICS_LOAD_TEST_CASE& testCase : testCase.m_generatorCases )
88 {
89 BOOST_TEST_MESSAGE( "Checking for graphic with UUID: "
90 << testCase.m_searchUuid.AsString() );
91
92 const auto& graphic =
94 aBoard, PCB_SHAPE_T, testCase.m_searchUuid ) );
95
96 BOOST_CHECK_EQUAL( graphic.IsSolidFill(), testCase.m_expectedFilled );
97 }
98 };
99
100 KI_TEST::LoadAndTestBoardFile( testCase.m_BoardFileRelativePath, true, doBoardTest,
101 testCase.m_ExpectedBoardVersion );
102}
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
wxString AsString() const
Definition kiid.cpp:242
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_DATA_TEST_CASE(GraphicsLoad, boost::unit_test::data::make(GraphicsLoad_testCases), testCase)
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:81