KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_3d_viewer_layer_presets.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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
28
30
31#include <layer_ids.h>
33
34#include <bitset>
35
36
37BOOST_AUTO_TEST_SUITE( Viewer3DLayerPresets )
38
39
40// A preset that enables named user layers, numbered User.N layers and the grid axes
41// must survive a Store()/Load() round-trip unchanged.
42BOOST_AUTO_TEST_CASE( PresetLayerVisibilityRoundTrip )
43{
45
46 LAYER_PRESET_3D preset( wxS( "regression" ) );
47 preset.layers.reset();
48 preset.layers.set( LAYER_3D_BOARD );
49 preset.layers.set( LAYER_3D_USER_COMMENTS );
50 preset.layers.set( LAYER_3D_USER_1 );
51 preset.layers.set( LAYER_3D_USER_45 );
52 preset.layers.set( LAYER_GRID_AXES );
53
54 const std::bitset<LAYER_3D_END> expected = preset.layers;
55
56 cfg.m_LayerPresets.push_back( preset );
57
58 cfg.Store();
59 cfg.m_LayerPresets.clear();
60 cfg.Load();
61
62 BOOST_REQUIRE_EQUAL( cfg.m_LayerPresets.size(), 1u );
63
64 const std::bitset<LAYER_3D_END>& actual = cfg.m_LayerPresets[0].layers;
65
66 BOOST_CHECK( actual.test( LAYER_3D_USER_COMMENTS ) );
67 BOOST_CHECK( actual.test( LAYER_3D_USER_1 ) );
68 BOOST_CHECK( actual.test( LAYER_3D_USER_45 ) );
69 BOOST_CHECK( actual.test( LAYER_GRID_AXES ) );
70
71 // Unknown layer names also corrupt bit 0 on load, so the full set must match.
72 BOOST_CHECK( actual == expected );
73}
74
75
std::vector< LAYER_PRESET_3D > m_LayerPresets
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
@ LAYER_3D_USER_1
Definition layer_ids.h:565
@ LAYER_3D_USER_COMMENTS
Definition layer_ids.h:561
@ LAYER_3D_BOARD
Definition layer_ids.h:552
@ LAYER_3D_USER_45
Definition layer_ids.h:609
@ LAYER_GRID_AXES
Definition layer_ids.h:251
std::bitset< LAYER_3D_END > layers
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
int actual