KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_lib_tree_model_adapter.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
20#include <boost/test/unit_test.hpp>
21
23#include <project.h>
25
26
33{
34public:
36 LIB_TREE_MODEL_ADAPTER( nullptr, wxT( "pinned" ), aSettings )
37 {
38 }
39
41
42 int LoadedWidth( const wxString& aColumn ) const
43 {
44 auto it = m_colWidths.find( aColumn );
45 return it != m_colWidths.end() ? it->second : -1;
46 }
47};
48
49
50BOOST_AUTO_TEST_SUITE( LibTreeModelAdapter )
51
52
58BOOST_AUTO_TEST_CASE( CorruptPersistedColumnWidthIgnoredOnLoad )
59{
61 settings.column_widths[ wxT( "Item" ) ] = 427218649;
62 settings.column_widths[ wxT( "Description" ) ] = 450;
63
65
66 // The corrupt width must not overwrite the default; the legitimate one must be applied.
67 BOOST_CHECK_EQUAL( adapter->LoadedWidth( wxT( "Item" ) ), 300 );
68 BOOST_CHECK_EQUAL( adapter->LoadedWidth( wxT( "Description" ) ), 450 );
69
70 adapter->DecRef();
71}
72
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, const wxString &aPinnedKey, APP_SETTINGS_BASE::LIB_TREE &aSettingsStruct)
Create the adapter.
std::map< wxString, int > m_colWidths
@ SYMBOL_LIB
Definition project.h:190
Minimal concrete adapter exposing the loaded column widths.
PROJECT::LIB_TYPE_T getLibType() override
TEST_LIB_TREE_MODEL_ADAPTER(APP_SETTINGS_BASE::LIB_TREE &aSettings)
int LoadedWidth(const wxString &aColumn) const
std::map< wxString, int > column_widths
Column widths, keyed by header name.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")