KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_api_proto.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 (C) 2024 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
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
21#include <boost/test/unit_test.hpp>
22#include <import_export.h>
27
28#include <api/board/board_types.pb.h>
29
30#include <board.h>
31#include <footprint.h>
32#include <pcb_barcode.h>
33#include <pcb_dimension.h>
34#include <pcb_reference_image.h>
35#include <pcb_track.h>
36#include <zone.h>
37
38
39BOOST_AUTO_TEST_SUITE( ApiProto )
40
49
50
52{
53 KI_TEST::LoadBoard( m_settingsManager, "api_kitchen_sink", m_board );
54
55 int barcodeCount = 0;
56 int referenceImageCount = 0;
57
58 for( PCB_TRACK* track : m_board->Tracks() )
59 {
60 switch( track->Type() )
61 {
62 case PCB_TRACE_T:
64 break;
65
66 case PCB_ARC_T:
68 m_board.get() );
69 break;
70
71 case PCB_VIA_T:
72 // Vias are not strict-checked at the moment because m_zoneLayerOverrides is not
73 // currently exposed to the API
74 // TODO(JE) enable strict when fixed
76 m_board.get(), false );
77 break;
78
79 default:
80 wxFAIL;
81 }
82 }
83
84 for( FOOTPRINT* footprint : m_board->Footprints() )
86
87 for( ZONE* zone : m_board->Zones() )
89
90 for( BOARD_ITEM* item : m_board->Drawings() )
91 {
92 switch( item->Type() )
93 {
96 static_cast<PCB_DIM_ALIGNED*>( item ), m_board.get() );
97 break;
98
101 static_cast<PCB_DIM_ORTHOGONAL*>( item ), m_board.get() );
102 break;
103
104 case PCB_DIM_CENTER_T:
106 static_cast<PCB_DIM_CENTER*>( item ), m_board.get() );
107 break;
108
109 case PCB_DIM_LEADER_T:
111 static_cast<PCB_DIM_LEADER*>( item ), m_board.get() );
112 break;
113
114 case PCB_DIM_RADIAL_T:
116 static_cast<PCB_DIM_RADIAL*>( item ), m_board.get() );
117 break;
118
119 case PCB_BARCODE_T:
121 static_cast<PCB_BARCODE*>( item ), m_board.get() );
122 ++barcodeCount;
123 break;
124
127 static_cast<PCB_REFERENCE_IMAGE*>( item ), m_board.get() );
128 ++referenceImageCount;
129 break;
130
131 default: break;
132 }
133 // TODO(JE) Shapes
134
135 // TODO(JE) Text
136 }
137
138 BOOST_CHECK_GT( barcodeCount, 0 );
139 BOOST_CHECK_GT( referenceImageCount, 0 );
140}
141
142
144{
145 KI_TEST::LoadBoard( m_settingsManager, "padstacks", m_board );
146
147 for( PCB_TRACK* track : m_board->Tracks() )
148 {
149 switch( track->Type() )
150 {
151 case PCB_VIA_T:
152 // Vias are not strict-checked at the moment because m_zoneLayerOverrides is not
153 // currently exposed to the API
154 // TODO(JE) enable strict when fixed
156 m_board.get(), false );
157 break;
158
159 default:
160 wxFAIL;
161 }
162 }
163
164 for( FOOTPRINT* footprint : m_board->Footprints() )
166}
167
void testProtoFromKiCadObject(KiCadClass *aInput, Factory &&aCreateOutput)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
For better understanding of the points that make a dimension:
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
Object to handle a bitmap image that can be inserted in a PCB.
Handle a list of polygons defining a copper zone.
Definition zone.h:74
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
BARCODE class definition.
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
BOOST_FIXTURE_TEST_CASE(BoardTypes, PROTO_TEST_FIXTURE)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:103
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:100
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:101
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:86
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:98
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:99
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:95
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:102