KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue25880.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
21
22#include <board.h>
23#include <footprint.h>
24#include <pcb_field.h>
28
29#include <filesystem>
30
31// Regression test for https://gitlab.com/kicad/code/kicad/-/work_items/25880
32//
33// Saving a scaled footprint unbaked and rebaked text size through a lossy round trip, so the live
34// text and the saved library-frame size both drifted by a nanometre.
35
36BOOST_AUTO_TEST_SUITE( Issue25880 )
37
38
39BOOST_AUTO_TEST_CASE( SaveKeepsFootprintTextLibrarySize )
40{
41 SETTINGS_MANAGER settingsManager;
42 std::unique_ptr<BOARD> board;
43
44 KI_TEST::LoadBoard( settingsManager, "issue18", board );
45
46 FOOTPRINT* fp = *board->Footprints().begin();
47 BOOST_REQUIRE( fp );
48
49 fp->SetTransformScale( 1.0 / 3.0, 1.0 / 3.0 );
50
51 const VECTOR2I libSize = fp->Reference().EDA_TEXT::GetTextSize();
52 const int libThickness = fp->Reference().EDA_TEXT::GetTextThickness();
53
54 const std::filesystem::path savePath = std::filesystem::temp_directory_path() / "issue25880.kicad_pcb";
55
56 KI_TEST::DumpBoardToFile( *board, savePath );
57
58 BOOST_CHECK( fp->Reference().EDA_TEXT::GetTextSize() == libSize );
59 BOOST_CHECK_EQUAL( fp->Reference().EDA_TEXT::GetTextThickness(), libThickness );
60
61 std::unique_ptr<BOARD> reloaded = KI_TEST::ReadBoardFromFileOrStream( savePath.string() );
62 BOOST_REQUIRE( reloaded );
63
64 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
65 BOOST_REQUIRE( fp2 );
66
67 BOOST_CHECK( fp2->Reference().EDA_TEXT::GetTextSize() == libSize );
68 BOOST_CHECK_EQUAL( fp2->Reference().EDA_TEXT::GetTextThickness(), libThickness );
69
70 std::filesystem::remove( savePath );
71}
72
73
General utilities for PCB file IO for QA programs.
void SetTransformScale(double aScaleX, double aScaleY)
PCB_FIELD & Reference()
Definition footprint.h:832
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708